本文整理汇总了Python中jira.JIRA.projects方法的典型用法代码示例。如果您正苦于以下问题:Python JIRA.projects方法的具体用法?Python JIRA.projects怎么用?Python JIRA.projects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jira.JIRA
的用法示例。
在下文中一共展示了JIRA.projects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: JiraHamsterListener
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import projects [as 别名]
class JiraHamsterListener(HamsterListener):
short_name = 'jira'
config_values = [
('server_url', lambda: raw_input('Root url to your jira server [f.e. "http://jira.example.org"]\n')),
('username', lambda: raw_input('Your jira user name\n')),
('password', lambda: raw_input('Your jira password\n')),
('auto_start', lambda: raw_input('Automatically start the issue when you start the task in hamster? [y/n]\n'))
]
issue_from_title = re.compile('([A-Z][A-Z0-9]+-[0-9]+)')
# noinspection PyBroadException
def prepare(self):
server_url = self.config.get(self.short_name, 'server_url')
username = self.config.get(self.short_name, 'username')
password = self.config.get(self.short_name, 'password')
logger.info('Connecting as "%s" to "%s"', username, server_url)
self.jira = JIRA(server_url, basic_auth=(username, password))
try:
self.jira.projects()
except:
logger.exception('Can not connect to JIRA, please check ~/.hamster-bridge.cfg')
def __issue_from_fact(self, fact):
"""
Get the issue name from a fact
:param fact: the fact to search the issue in
"""
fields = [fact.activity] + fact.tags
logger.debug('Searching ticket in: %r', fields)
for field in fields:
for possible_issue in self.issue_from_title.findall(field):
logger.debug('Lookup issue for activity "%s"', possible_issue)
try:
self.jira.issue(possible_issue)
logger.debug('Found existing issue "%s" in "%s"', possible_issue, field)
return possible_issue
except JIRAError, e:
if e.text == 'Issue Does Not Exist':
logger.warning('Tried issue "%s", but does not exist. ', possible_issue)
else:
logger.exception('Error communicating with Jira')
示例2: index
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import projects [as 别名]
def index(request):
if request.method == "POST":
application_url = request.POST.get('application_url')
username = request.POST.get('username')
password = request.POST.get('password')
if not username or not password:
try:
dirty_data = request.POST.keys()[0]
data = json.loads(dirty_data)
username = data['username']
password = data['password']
application_url = data.get('application_url')
except:
raise Http404
else:
raise Http404
is_setting_up = False
if all([application_url, username, password]):
is_setting_up = True
elif all([username, password]):
try:
application_url = ApplicationURL.get_url(username)
except ApplicationURL.DoesNotExist:
raise Http404
jira = JIRA(server=application_url, basic_auth=(username, password), max_retries=1)
cache_time_to_live = 1000 # Seconds
cache.set(username, jira, cache_time_to_live)
available_projects = jira.projects()
if is_setting_up:
application_url_obj, created = ApplicationURL.objects.get_or_create(username=username)
# if created:
application_url_obj.url = application_url
application_url_obj.save()
data = []
for project in available_projects:
project_data = {
'id': project.id,
'name': project.name,
}
data.append(project_data)
data = {
'projects': data,
'token': username
}
data = json.dumps([data])
# import ipdb
# ipdb.set_trace()
response = HttpResponse(data)
response["Access-Control-Allow-Origin"] = "*"
response["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS"
response["Access-Control-Max-Age"] = "1000"
response["Access-Control-Allow-Headers"] = "*"
return response
示例3: __init__
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import projects [as 别名]
class Jira:
def __init__(self):
options = {
'server': jira_url, 'verify': False, 'check_update': False
}
self.jira = JIRA(options, basic_auth=(jira_user, jira_passwd))
def main(self, comment, group_name):
message = comment['message'].split('\n')[0]
commit_sha1 = comment['id']
author = comment['author_name']
commited_date = comment['committed_date'].split('+')[0]
date = datetime.datetime.strptime(commited_date, "%Y-%m-%dT%H:%M:%S.%f")
projects = self.jira.projects()
project_keys = sorted([project.key for project in projects])
for keys in project_keys:
if message.startswith(keys):
issue_id = message.split(' ')[0]
try:
comment_msg = ' '.join(message.split(' ')[1:])
except IndexError:
comment_msg = issue_id
compare_url = "%s/%s/%s/commit/%s" % (git_server_url, group_name, project_name, refs)
msg = '%s\n\nProject Repo: %s\nUser: %s\nCommit Time: %s\nCommit SHA1: [%s | %s]\n\n' %\
(comment_msg, project_name, author, date, commit_sha1, compare_url)
comment = self.jira.add_comment(issue_id, msg)
示例4: JIRA
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import projects [as 别名]
from jira import JIRA
import requests
from config import JIRA_DOMAIN, JIRA_PASSWORD, JIRA_USERNAME
jira = JIRA(JIRA_DOMAIN, basic_auth=(JIRA_USERNAME, JIRA_PASSWORD))
projects = jira.projects()
boards = jira.boards()
for board in boards:
print('BOARD: ', board)
dashboards = jira.dashboards()
for dash in dashboards:
print(dash.name, dash.id)
cizo_dashboard = jira.dashboard(id=11105)
# curago_dashboard = jira.dashboard('CURAGO')
cizo_dash_page = requests.get(cizo_dashboard.view).text
print(cizo_dash_page)
for project in projects:
print (project)
示例5: JiraHamsterListener
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import projects [as 别名]
class JiraHamsterListener(HamsterListener):
short_name = 'jira'
config_values = [
ConfigValue(
key='server_url',
setup_func=lambda: raw_input('Root url of your jira server [f.e. "http://jira.example.org"]: '),
sensitive=False,
),
ConfigValue(
key='username',
setup_func=lambda: raw_input('Your jira user name: '),
sensitive=False,
),
ConfigValue(
key='password',
setup_func=lambda: getpass('Your jira password: ') if sys.stdin.isatty() else raw_input(),
sensitive=True,
),
ConfigValue(
key='auto_start',
setup_func=lambda: raw_input('Automatically start the issue when '
'you start the task in hamster? You can also specify the name of '
'the JIRA transition to use. [y/n/TRANSITION_NAME]: '),
sensitive=False,
),
ConfigValue(
key='verify_ssl',
setup_func=lambda: raw_input('Verify HTTPS/SSL connections? '
'You can also specify the path to a CA certificate bundle. [y/n/PATH]: '),
sensitive=False,
),
]
issue_from_title = re.compile('([A-Z][A-Z0-9]+-[0-9]+)')
# noinspection PyBroadException
def prepare(self):
server_url = self.get_from_config('server_url')
username = self.get_from_config('username')
password = self.get_from_config('password')
verify_ssl = self.get_from_config('verify_ssl')
options = {}
if verify_ssl.lower() in ('y', 'true'):
logger.info("Enabling SSL/TLS certificate verification (default CA path)")
options['verify'] = True
elif verify_ssl.lower() in ('n', 'false'):
logger.warn("Disabling SSL/TLS certificate verification")
options['verify'] = False
elif os.path.isfile(verify_ssl):
logger.info("Enabling SSL/TLS certificate verification (custom CA "
"path) '%s'", verify_ssl)
options['verify'] = verify_ssl
else:
logger.error("verify_ssl = '%s' is not a valid CA cert path nor a "
"valid option. Falling back to enabling SSL/TLS verification "
"with default CA path", verify_ssl)
options['verify'] = True
logger.info('Connecting as "%s" to "%s"', username, server_url)
self.jira = JIRA(
server_url,
options=options,
basic_auth=(username, password)
)
try:
self.jira.projects()
except:
logger.exception('Can not connect to JIRA, please check ~/.hamster-bridge.cfg')
def __issue_from_fact(self, fact):
"""
Get the issue name from a fact
:param fact: the fact to search the issue in
"""
fields = [fact.activity] + fact.tags
logger.debug('Searching ticket in: %r', fields)
for field in fields:
for possible_issue in self.issue_from_title.findall(field):
logger.debug('Lookup issue for activity "%s"', possible_issue)
try:
self.jira.issue(possible_issue)
logger.debug('Found existing issue "%s" in "%s"', possible_issue, field)
return possible_issue
except JIRAError, e:
if e.text == 'Issue Does Not Exist':
logger.warning('Tried issue "%s", but does not exist. ', possible_issue)
else:
logger.exception('Error communicating with Jira')
示例6: submit_jira_ticket
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import projects [as 别名]
def submit_jira_ticket(request):
jira_setting = jirasetting.objects.all()
for jira in jira_setting:
jira_url = jira.jira_server
username = jira.jira_username
password = jira.jira_password
jira_server = jira_url
jira_username = signing.loads(username)
jira_password = signing.loads(password)
options = {'server': jira_server}
jira_ser = JIRA(options, basic_auth=(jira_username, jira_password))
jira_projects = jira_ser.projects()
if request.method == 'GET':
summary = request.GET['summary']
description = request.GET['description']
scanner = request.GET['scanner']
vuln_id = request.GET['vuln_id']
scan_id = request.GET['scan_id']
return render(request, 'submit_jira_ticket.html', {'jira_projects': jira_projects,
'summary': summary,
'description': description,
'scanner': scanner,
'vuln_id': vuln_id,
'scan_id': scan_id
})
if request.method == 'POST':
summary = request.POST.get('summary')
description = request.POST.get('description')
project_id = request.POST.get('project_id')
issue_type = request.POST.get('issue_type')
vuln_id = request.POST.get('vuln_id')
scanner = request.POST.get('scanner')
scan_id = request.POST.get('scan_id')
issue_dict = {
'project': {'id': project_id},
'summary': summary,
'description': description,
'issuetype': {'name': issue_type},
}
new_issue = jira_ser.create_issue(fields=issue_dict)
print new_issue
if scanner == 'zap':
zap_scan_results_db.objects.filter(vuln_id=vuln_id).update(jira_ticket=new_issue)
return HttpResponseRedirect('/webscanners/zap_vul_details/?scan_id=%s&scan_name=%s' % (
scan_id,
summary
)
)
elif scanner == 'burp':
burp_scan_result_db.objects.filter(vuln_id=vuln_id).update(jira_ticket=new_issue)
return HttpResponseRedirect('/webscanners/burp_vuln_out/?scan_id=%s&scan_name=%s' % (
scan_id,
summary
)
)
elif scanner == 'arachni':
arachni_scan_result_db.objects.filter(vuln_id=vuln_id).update(jira_ticket=new_issue)
return HttpResponseRedirect('/webscanners/arachni_vuln_out/?scan_id=%s&scan_name=%s' % (scan_id, summary))
elif scanner == 'open_vas':
ov_scan_result_db.objects.filter(vul_id=vuln_id).update(jira_ticket=new_issue)
return HttpResponseRedirect('/networkscanners/vul_details/?scan_id=%s' % scan_id)
elif scanner == 'nessus':
nessus_report_db.objects.filter(vul_id=vuln_id).update(jira_ticket=new_issue)
return HttpResponseRedirect('/networkscanners/nessus_vuln_details/?scan_id=%s' % scan_id)
示例7: JIRA
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import projects [as 别名]
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 23 06:05:32 2016
@author: bkunneke
"""
# Great write up on how to do everything in JIRA here:
# https://pythonhosted.org/jira/
from jira import JIRA
jira = JIRA(server='https://te2web.atlassian.net', basic_auth=('user', 'pwd')) # a username/password tuple
projects = jira.projects() # Gets a list of all projects
# Create an issue
new_issue = jira.create_issue(project='PROJ_key_or_id', summary='New issue from jira-python',
description='Look into this one', issuetype={'name': 'Bug'})
# Find a specific issue
issues = jira.search_issues("key = 'HIL-163'")