本文整理汇总了Python中jira.JIRA.project方法的典型用法代码示例。如果您正苦于以下问题:Python JIRA.project方法的具体用法?Python JIRA.project怎么用?Python JIRA.project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jira.JIRA
的用法示例。
在下文中一共展示了JIRA.project方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
def GET(self):
gl.GL_WEBINPUT = web.input()
projectname = gl.GL_WEBINPUT.product_name
productline_list = gl.GL_DB.query("select distinct version from crashinfo where appName='" + projectname + "'")
# select *, count(distinct name) from table group by name
result = []
result_g_version = []
result_jira_version = []
#jira = JIRA(server='http://127.0.0.1:1194', basic_auth=('wangyang', 'qwerty123456'))
jira = JIRA(server=jira_server, basic_auth=(user_accout, user_pass))
for name in project:
if name in projectname:
jira_name = project[name]["projectname"]
versions = jira.project_versions(jira.project(jira_name))
for item in productline_list:
item_dict = {"game_version": item.version}
result_g_version.append(item_dict)
[result_jira_version.append({"jira_version": v.name}) for v in reversed(versions)]
result.append(result_g_version)
result.append(result_jira_version)
encodedjson = json.dumps(result)
return encodedjson
示例2: get_project
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
def get_project(params):
api_server = params['api_url']
api_username = params['api_username']
api_password = params['api_password']
auth = (api_username, api_password)
jira = JIRA( {'server': api_server}, basic_auth=auth)
key = params['project_key']
try:
return jira.project(key)
except:
return None
示例3: validate_config_value
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
def validate_config_value(config):
"""
:param config: Project XML config class object
:return: bool True if Project XML config values are valid else raises Exception
"""
try:
logger.debug("Connecting with Project JIRA server at URL [{}]".format(config.url))
jira = JIRA(server=config.url, basic_auth=(config.user, config.passwd))
logger.debug("Successfully connected!")
logger.debug("Checking if project key exists [{0}] in server".format(config.key))
name = jira.project(config.key).name
logger.debug("Project key [{0}] with name [{1}] exists in server".format(config.key, name))
return True
except Exception:
raise
示例4: AND
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
class JIRAProject:
"""
Custom class which represents a JIRA project for DSR report
"""
JQL = 'project="{project}" AND ((created >= "{start}" and created <= "{end}") ' \
'OR (updated >= "{start}" and updated <= "{end}")) order by updated asc'
def __init__(self, config, start_date, end_date):
self.config = config
self.start_date = start_date
self.end_date = end_date
self.jira = JIRA(server=config.url, basic_auth=(config.user,
config.passwd))
self.timezone = pytz.timezone(config.timezone)
self.name = self.jira.project(config.key).name
def __str__(self):
return self.name
def __eq__(self, other):
return self.config.key == other
def get_project_issues(self):
"""
This method returns a list of JIRA issue objects which have
any activities within specified start and end date
s
:return: [JIRAIssue objects]
"""
jira_issues_in_proj = self.jira.search_issues(
JIRAProject.JQL.format(project=self.config.key, start=self.start_date, end=self.end_date))
if jira_issues_in_proj:
project_issues = list()
for issue in jira_issues_in_proj:
project_issue = JIRAIssue(self,
self.jira,
issue.key,
self.start_date,
self.end_date)
project_issues.append(project_issue)
return project_issues
示例5: create_project
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
def create_project(params):
api_server = params['api_url']
api_username = params['api_username']
api_password = params['api_password']
auth = (api_username, api_password)
jira = JIRA( {'server': api_server}, basic_auth=auth)
project_key = params['project_key']
project_name = params['project_name']
assignee = params['assignee']
# create project and view
if not jira.create_project(project_key, name=project_name, assignee=assignee):
return None
proj = jira.project(project_key)
board = jira.create_board("{0} View".format(project_name), project_key, preset='scrum')
issue = jira.create_issue(
project=project_key,
summary="Sample Issue for {0}".format(project_name),
description="This is just sample",
issuetype={"name":"Task"}
)
return proj
示例6: Api
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
class Api(object):
versions = None
def __init__(self):
self.j = JIRA(
server=settings.JIRA_URL,
basic_auth=(settings.JIRA_USERNAME, settings.JIRA_PASSWORD),
)
self.project = self.j.project(settings.JIRA_PROJECT)
def get_versions(self):
return self.j.project_versions(self.project)
def get_issues(self, version_name, username):
if self.versions is None:
self.versions = self.get_versions()
version = next(
(v for v in self.versions
if version_name in v.name
and '1C' not in v.name
and '1С' not in v.name
and 'WWW' not in v.name
), None
)
if version is None:
return []
else:
jql = 'project=VIP ' \
'AND resolution=Unresolved ' \
'AND fixVersion="{fixVersion}"' \
'AND assignee in ({assignee})'.format(
fixVersion=version.name,
assignee=username,
)
return self.j.search_issues(jql)
示例7: prettyXML
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
failureDetails = failureDetails + '{code:title=' + testurl + '' + className_re + '/' + name_re + '}\n'
failureDetails = failureDetails + prettyXML(s)
failureDetails = failureDetails + '\n{code}\n\n'
#print failureDetails
rootJBIDE_dict = {
'project' : { 'key': 'JBIDE' },
'summary' : str(len(testcaselist)) + ' Test Failure(s) in JBIDE ' + jbide_affectedversion + ' for ' + component + ' component',
'description' : failureSummary + failureDetails,
'issuetype' : { 'name' : 'Task' },
'priority' : { 'name' :'Critical'},
'versions' : [{ "name" : jbide_affectedversion }],
'components' : [{ "name" : component }],
'labels' : [ "testfailure" ]
}
jira = JIRA(options={'server':jiraserver}, basic_auth=(options.usernameJIRA, options.passwordJIRA))
CLJBIDE = jira.project_components(jira.project('JBIDE')) # full list of components in JBIDE
rootJBIDE = jira.create_issue(fields=rootJBIDE_dict)
componentLead = queryComponentLead(CLJBIDE, component, 0)
try:
jira.assign_issue(rootJBIDE, componentLead)
except:
print "[WARNING] Unexpected error! User {0} tried to assign {1} to {2}: {3}".format(options.usernameJIRA, rootJBIDE, componentLead, sys.exc_info()[0])
accept = raw_input("\nAccept new JIRA " + jiraserver + '/browse/' + rootJBIDE.key + " => " + componentLead + " ? [Y/n] ")
if accept.capitalize() in ["N"] :
rootJBIDE.delete()
# see JIRA_components listing in components.py
# Sample usage: see createTestFailureJIRA.py.examples.txt
示例8: print
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
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)
cizo = jira.project('SEN')
curago = jira.project('CUR')
print ('Project: ', cizo.name)
print ('Cizo Lead: ', cizo.lead.displayName)
print ('==============================')
print ('Project: ', curago.name)
print ('Cizo Lead: ', curago.lead.displayName)
示例9: JiraAPI
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
class JiraAPI(object):
def __init__(self, hostname=None, username=None, password=None, path="", debug=False, clean_obsolete=True, max_time_window=12):
self.logger = logging.getLogger('JiraAPI')
if debug:
self.logger.setLevel(logging.DEBUG)
if "https://" not in hostname:
hostname = "https://{}".format(hostname)
self.username = username
self.password = password
self.jira = JIRA(options={'server': hostname}, basic_auth=(self.username, self.password))
self.logger.info("Created vjira service for {}".format(hostname))
self.all_tickets = []
self.JIRA_REOPEN_ISSUE = "Reopen Issue"
self.JIRA_CLOSE_ISSUE = "Close Issue"
self.max_time_tracking = max_time_window #in months
#<JIRA Resolution: name=u'Obsolete', id=u'11'>
self.JIRA_RESOLUTION_OBSOLETE = "Obsolete"
self.JIRA_RESOLUTION_FIXED = "Fixed"
self.clean_obsolete = clean_obsolete
self.template_path = 'vulnwhisp/reporting/resources/ticket.tpl'
if path:
self.download_tickets(path)
else:
self.logger.warn("No local path specified, skipping Jira ticket download.")
def create_ticket(self, title, desc, project="IS", components=[], tags=[]):
labels = ['vulnerability_management']
for tag in tags:
labels.append(str(tag))
self.logger.info("creating ticket for project {} title[20] {}".format(project, title[:20]))
self.logger.info("project {} has a component requirement: {}".format(project, self.PROJECT_COMPONENT_TABLE[project]))
project_obj = self.jira.project(project)
components_ticket = []
for component in components:
exists = False
for c in project_obj.components:
if component == c.name:
self.logger.debug("resolved component name {} to id {}".format(c.name, c.id))
components_ticket.append({ "id": c.id })
exists=True
if not exists:
self.logger.error("Error creating Ticket: component {} not found".format(component))
return 0
new_issue = self.jira.create_issue(project=project,
summary=title,
description=desc,
issuetype={'name': 'Bug'},
labels=labels,
components=components_ticket)
self.logger.info("Ticket {} created successfully".format(new_issue))
return new_issue
#Basic JIRA Metrics
def metrics_open_tickets(self, project=None):
jql = "labels= vulnerability_management and resolution = Unresolved"
if project:
jql += " and (project='{}')".format(project)
self.logger.debug('Executing: {}'.format(jql))
return len(self.jira.search_issues(jql, maxResults=0))
def metrics_closed_tickets(self, project=None):
jql = "labels= vulnerability_management and NOT resolution = Unresolved AND created >=startOfMonth(-{})".format(self.max_time_tracking)
if project:
jql += " and (project='{}')".format(project)
return len(self.jira.search_issues(jql, maxResults=0))
def sync(self, vulnerabilities, project, components=[]):
#JIRA structure of each vulnerability: [source, scan_name, title, diagnosis, consequence, solution, ips, risk, references]
self.logger.info("JIRA Sync started")
# [HIGIENE] close tickets older than 12 months as obsolete
# Higiene clean up affects to all tickets created by the module, filters by label 'vulnerability_management'
if self.clean_obsolete:
self.close_obsolete_tickets()
for vuln in vulnerabilities:
# JIRA doesn't allow labels with spaces, so making sure that the scan_name doesn't have spaces
# if it has, they will be replaced by "_"
if " " in vuln['scan_name']:
vuln['scan_name'] = "_".join(vuln['scan_name'].split(" "))
exists = False
to_update = False
ticketid = ""
ticket_assets = []
exists, to_update, ticketid, ticket_assets = self.check_vuln_already_exists(vuln)
if exists:
# If ticket "resolved" -> reopen, as vulnerability is still existent
self.reopen_ticket(ticketid)
self.add_label(ticketid, vuln['risk'])
continue
elif to_update:
self.ticket_update_assets(vuln, ticketid, ticket_assets)
self.add_label(ticketid, vuln['risk'])
continue
#.........这里部分代码省略.........
示例10: update_or_create_jira_issue
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
def update_or_create_jira_issue(study_id, user_token, is_curator):
try:
params = app.config.get('JIRA_PARAMS')
user_name = params['username']
password = params['password']
updated_studies = []
try:
jira = JIRA(options=options, basic_auth=(user_name, password))
except:
return False, 'Could not connect to JIRA server, incorrect username or password?', updated_studies
# Get the MetaboLights project
mtbls_project = jira.project(project)
studies = [study_id]
if not study_id and is_curator:
studies = get_all_studies(user_token)
for study in studies:
study_id = study[0]
user_name = study[1]
release_date = study[2]
update_date = study[3]
study_status = study[4]
curator = study[5]
issue = []
summary = None
# Get an issue based on a study accession search pattern
search_param = "project='" + mtbls_project.key + "' AND summary ~ '" + study_id + " \\\-\\\ 20*'"
issues = jira.search_issues(search_param) # project = MetaboLights AND summary ~ 'MTBLS121 '
new_summary = study_id + ' - ' + release_date.replace('-', '') + ' - ' + \
study_status + ' (' + user_name + ')'
try:
if issues:
issue = issues[0]
else:
if study_status == 'Submitted':
logger.info("Could not find Jira issue for " + search_param)
print("Creating new Jira issue for " + search_param)
issue = jira.create_issue(project=mtbls_project.key, summary='MTBLS study - To be updated',
description='Created by API', issuetype={'name': 'Story'})
else:
continue # Only create new cases if the study is in status Submitted
except Exception: # We could not find or create a Jira issue
continue
summary = issue.fields.summary # Follow pattern 'MTBLS123 - YYYYMMDD - Status'
try:
assignee = issue.fields.assignee.name
except:
assignee = ""
valid_curator = False
jira_curator = ""
if curator:
if curator.lower() == 'mark':
jira_curator = 'mwilliam'
valid_curator = True
elif curator.lower() == 'keeva':
jira_curator = 'keeva'
valid_curator = True
else:
jira_curator = ""
# Release date or status has changed, or the assignee (curator) has changed
if summary.startswith('MTBLS') and (summary != new_summary or assignee != jira_curator):
# Add "Curation" Epic
issues_to_add = [issue.key]
jira.add_issues_to_epic(curation_epic, issues_to_add) # Add the Curation Epic
labels = maintain_jira_labels(issue, study_status, user_name)
# Add a comment to the issue.
comment_text = 'Status ' + study_status + '. Database update date ' + update_date
jira.add_comment(issue, comment_text)
# Change the issue's summary, comments and description.
issue.update(summary=new_summary, fields={"labels": labels}, notify=False)
if valid_curator: # ToDo, what if the curation log is not up to date?
issue.update(assignee={'name': jira_curator})
updated_studies.append(study_id)
logger.info('Updated Jira case for study ' + study_id)
print('Updated Jira case for study ' + study_id)
except Exception:
return False, 'Update failed', updated_studies
return True, 'Ticket(s) updated successfully', updated_studies
示例11: JiraTestManager
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project [as 别名]
#.........这里部分代码省略.........
self.jira_sysadmin = JIRA(self.CI_JIRA_URL,
logging=False, max_retries=self.max_retries)
if OAUTH:
self.jira_normal = JIRA(oauth={
'access_token': 'ZVDgYDyIQqJY8IFlQ446jZaURIz5ECiB',
'access_token_secret':
'5WbLBybPDg1lqqyFjyXSCsCtAWTwz1eD',
'consumer_key': CONSUMER_KEY,
'key_cert': KEY_CERT_DATA})
else:
if self.CI_JIRA_ADMIN:
self.jira_normal = JIRA(self.CI_JIRA_URL,
basic_auth=(self.CI_JIRA_USER,
self.CI_JIRA_USER_PASSWORD),
validate=True, logging=False, max_retries=self.max_retries)
else:
self.jira_normal = JIRA(self.CI_JIRA_URL,
validate=True, logging=False, max_retries=self.max_retries)
# now we need some data to start with for the tests
# jira project key is max 10 chars, no letter.
# [0] always "Z"
# [1-6] username running the tests (hope we will not collide)
# [7-8] python version A=0, B=1,..
# [9] A,B -- we may need more than one project
prefix = 'Z' + (re.sub("[^A-Z]", "",
getpass.getuser().upper()))[0:6] + \
chr(ord('A') + sys.version_info[0]) + \
chr(ord('A') + sys.version_info[1])
self.project_a = prefix + 'A' # old XSS
self.project_a_name = "Test user=%s python=%s.%s A" \
% (getpass.getuser(), sys.version_info[0],
sys.version_info[1])
self.project_b_name = "Test user=%s python=%s.%s B" \
% (getpass.getuser(), sys.version_info[0],
sys.version_info[1])
self.project_b = prefix + 'B' # old BULK
try:
self.jira_admin.project(self.project_a)
except Exception as e:
logging.warning(e)
pass
else:
self.jira_admin.delete_project(self.project_a)
try:
self.jira_admin.project(self.project_b)
except Exception as e:
logging.warning(e)
pass
else:
self.jira_admin.delete_project(self.project_b)
self.jira_admin.create_project(self.project_a,
self.project_a_name)
self.project_a_id = self.jira_admin.project(self.project_a).id
self.jira_admin.create_project(self.project_b,
self.project_b_name)
self.project_b_issue1_obj = self.jira_admin.create_issue(project=self.project_b,