我用SonarQube创建了自己的服务器,我想用gitlab连接它.每次我将提交我的提交sonarqube扫描仪将运行并在代码中创建结果+注释.
我已经下载了这个插件:https: //gitlab.talanlabs.com/gabriel-allaigre/sonar-gitlab-plugin
根据 Gitlab与SonarQube的集成, 这些只有2个插件
我在我的SonarQube服务器上安装了这个插件.在插件选项中,将gitlab API密钥和url添加到我的存储库中,就像在文档中一样.
好的,所以它已经完成......但现在呢?我必须在gitlab中改变,当我推送提交gitlab时会知道"好吧,我必须用这个sonarqube服务器分析这段代码"
我是全新的(sonarqube和gitlab),3天前我对SonarQube一无所知,我不知道我可以在gitlab中开始一个跑步者.
插件文档中有一些例子,但我不理解它们,我的意思是我不知道在gitlab上的"示例"部分放置此代码,以使其正常工作.
被困在原地.我不是在谈论这个.gitlab-ci.yml因为我认为它适用于java项目,而且没关系,但我想分析python和其他......但是如何; /?
请帮忙
我还在学习 python,有什么方法可以将 python 字符串转换为具有定义模式的几个变量吗?
例如图案和文字:
pattern = '{var1},{var2}::{var3}-:{var4}'
string_text = 'test1,test2::test3-:test4'
Run Code Online (Sandbox Code Playgroud)
转换成:
var1, var2, var3, var4 = magic method convert string_text using pattern
print(var1) # test1
print(var2) # test2
print(var3) # test3
print(var4) # test4
Run Code Online (Sandbox Code Playgroud)
我知道可以使用日期时间对象执行此类操作:
datetime.strptime('1992-12-22', "%Y-%m-%d")
Run Code Online (Sandbox Code Playgroud)
我也可以用正则表达式来做到这一点(不需要帮助;)但也许字符串对象中有相同的方法,我只是不知道如何使用?
我将不胜感激任何帮助!
我是初级后端开发人员。我不知道如何使用JS。
我不能设置
<input type="checkbox" name="player_check">
Run Code Online (Sandbox Code Playgroud)
真的...或反向我无法设置
<input type="checkbox" name="player_check" checked>
Run Code Online (Sandbox Code Playgroud)
错误的。
我的代码:
<table id="some_table">
<thead>
<tr>
<th>Prepared</th>
</tr>
</thead>
<tbody>
{% for player in players %}
<tr>
<td>
<input type="checkbox" name="player_check">
</td>
</tr>
{% endfor %}
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
假设在“玩家”中我有 5 个玩家,每个玩家都有一个值“player_check”。
其中两个有:
player.player_check = True
Run Code Online (Sandbox Code Playgroud)
休息:
player.player_check = False
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用 {{}} 或 {% %} 使用这些值在我的表中启动复选框
我试过了:
<input type="checkbox" name="player_check" value=1>
<input type="checkbox" name="player_check" value="1">
<input type="checkbox" name="player_check" value="True">
<input type="checkbox" name="player_check" value=True>
<input type="checkbox" name="player_check" value="checked">
Run Code Online (Sandbox Code Playgroud)
什么都不起作用......然后我发现复选框有一个参数被选中,所以:
<input type="checkbox" name="player_check" …Run Code Online (Sandbox Code Playgroud) 我有一个问题:(我正在研究Django 1.8,Python 2.7.15)我从数据库中获取了一个对象:
shop_users = ShopUsers.objects.get(pk=_id)
Run Code Online (Sandbox Code Playgroud)
然后,如果对象存在,我正在为View准备数据:
if shop_users:
data = {
'full_name': shop_users.full_name,
'shop': shop_users.shop.title,
'price_title': shop_users.price.title if shop_users.price.title else '',
'package_price': shop_users.price.price,
'user_price': shop_users.payment.operation_amount
}
Run Code Online (Sandbox Code Playgroud)
但是shop_users.price.title可能不存在.
我想在我准备上面的数据时检查它(我正在做'...如果......其他'),但如果shop_users.price.title不存在则提供AttributeError.
我可以在'data'声明之前使用try/except但这会使我的代码加倍...
有没有处理AttributeError的技巧(... if ... else)?
也许shop_users.price.title [0](不起作用)
或者获取(shop_users.price.title)?
我只是不想加倍我的代码...但我不知道任何诀窍:/
我很年轻.我感谢任何帮助!
我第一次使用unittest和selenium,但这也是我在python中的第一个更大的代码。我为这个问题找到了一些答案,但是对于具有__ init __继承和方法super()的类没有解释。__ init __()
TL; DR 我有一个可以一一继承的类。创建chrome实例的第一个类StartInstance从unittest.TestCase继承,问题出在继承和super()上。其他类中的init(),因为当我删除它时,测试正常开始
一切看起来像:
class StartInstance(unittest.TestCase):
@classmethod
def setUpClass(cls): pass
class A(StartInstance):
def __init__(self):
super().__init__() adding variables etc to init
class B(A):
def __init__(self):
super().__init__() adding variables etc to init
class C(A):
def __init__(self):
super().__init__() adding variables etc to init
class PrepareTests(B, C, D):
def all tests(self):
self.tests_B
self.tests_C
self.tests_D
class Tests(PrepareTests):
def test_click:
click()
all_tests()
#and finally somewhere a test runner
suite = loader.loadTestsFromTestCase(Tests)
runner.run(suite())
#when i run this i get this …Run Code Online (Sandbox Code Playgroud) python ×4
django ×2
attributes ×1
checkbox ×1
gitlab ×1
gitlab-ci ×1
inheritance ×1
javascript ×1
selenium ×1
sonarqube ×1
string ×1
super ×1
unit-testing ×1