本文整理汇总了Python中youtrack.connection.Connection类的典型用法代码示例。如果您正苦于以下问题:Python Connection类的具体用法?Python Connection怎么用?Python Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Connection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: jira2youtrack
def jira2youtrack(source_url, source_login, source_password, target_url, target_login, target_password, project_id):
print("source_url : " + source_url)
print("source_login : " + source_login)
print("source_password : " + source_password)
print("target_url : " + target_url)
print("target_login : " + target_login)
print("target_password : " + target_password)
print("project_id : " + project_id)
source = JiraClient(source_url, source_login, source_password)
target = Connection(target_url, target_login, target_password)
#
# target.createProjectDetailed(project_id, project_id, "", target_login)
#
# for i in range(0, 5500):
# try:
# jira_issues = source.get_issues(project_id, i * 10, (i + 1) * 10)
# target.importIssues(project_id, project_id + " assignees",
# [create_yt_issue_from_jira_issue(target, issue, project_id) for issue in
# jira_issues])
# for issue in jira_issues:
# process_labels(target, issue)
# process_attachments(source, target, issue)
# except BaseException, e:
# print(str(e))
for i in range(0, 5500):
jira_issues = source.get_issues(project_id, i * 50, (i + 1) * 50)
links = []
for issue in jira_issues:
process_links(target, issue, links)
print(target.importLinks(links))
开发者ID:BluewireTechnologies,项目名称:youtrack-rest-python-library,代码行数:32,代码来源:jira2youtrack.py
示例2: main
def main(argv):
project_name = ''
project_id = ''
project_desc = ''
project_usr = 'root'
project_pwd = 'Sarasa12'
svn_cli = pysvn.Client()
svn_working_path = '/tmp'
youtrack_url = 'http://localhost:80'
try:
opts, args = getopt.getopt(argv,"hp:i:d:",["project_name=","project_id=", "project_desc="])
except getopt.GetoptError:
print 'test.py -p <project_name> -i <project_id> -d <project_desc>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'test.py -p <project_name> -i <project_id> -d <project_desc>'
sys.exit()
elif opt in ("-p", "--project_name"):
project_name = arg
elif opt in ("-i", "--project_id"):
project_id = arg
elif opt in ("-d", "--project_desc"):
project_desc = arg
#yt = Connection('http://v-rot-mne-nogi.myjetbrains.com/youtrack', 'root', 'root')
#, proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'localhost', 8888))
yt = Connection(youtrack_url, project_usr, project_pwd)
#def createProjectDetailed(self, projectId, name, description, projectLeadLogin, startingNumber=1)
print yt.createProjectDetailed(project_id, project_name, project_desc, project_usr, 1)
开发者ID:we-are-around,项目名称:youtrack,代码行数:31,代码来源:aroundCreateProject.py
示例3: jira2youtrack
def jira2youtrack(source_url, source_login, source_password,
target_url, target_login, target_password,
projects, flags, field_mappings, value_mappings):
print 'source_url : ' + source_url
print 'source_login : ' + source_login
print 'target_url : ' + target_url
print 'target_login : ' + target_login
source = JiraClient(source_url, source_login, source_password)
target = Connection(target_url, target_login, target_password)
issue_links = []
chunk_size = 10
for project in projects:
project_id, start, end = project
try:
target.createProjectDetailed(project_id, project_id, '', target_login)
except YouTrackException:
pass
while True:
_end = start + chunk_size - 1
if end and _end > end:
_end = end
if start > _end:
break
print 'Processing issues: %s [%d .. %d]' % (project_id, start, _end)
try:
jira_issues = source.get_issues(project_id, start, _end)
start += chunk_size
if not (jira_issues or end):
break
# Filter out moved issues
jira_issues = [issue for issue in jira_issues
if issue['key'].startswith('%s-' % project_id)]
if flags & FI_ISSUES:
issues2import = []
for issue in jira_issues:
issues2import.append(
to_yt_issue(target, issue, project_id,
field_mappings, value_mappings))
if not issues2import:
continue
target.importIssues(
project_id, '%s assignees' % project_id, issues2import)
except YouTrackException, e:
print e
continue
for issue in jira_issues:
if flags & FI_LINKS:
process_links(target, issue, issue_links)
if flags & FI_LABELS:
process_labels(target, issue)
if flags & FI_ATTACHMENTS:
process_attachments(source, target, issue,
flags & FI_REPLACE_ATTACHMENTS > 0)
if flags & FI_WORK_LOG:
process_worklog(source, target, issue)
开发者ID:OpenSorceress,项目名称:youtrack-rest-python-library,代码行数:59,代码来源:jira2youtrack.py
示例4: agilezen2youtrack
def agilezen2youtrack(source_url, source_token, target_url, target_login, target_password, project_names_to_import):
source = Client(source_url, source_token)
target = Connection(target_url, target_login, target_password)
last_page = False
current_page = 1
try:
target.createCustomFieldDetailed("State", "state[1]", False, True, True, {"attachBundlePolicy": "2"})
except YouTrackException, e:
print str(e)
开发者ID:BluewireTechnologies,项目名称:youtrack-rest-python-library,代码行数:9,代码来源:agilezen2youtrack.py
示例5: submit
def submit(self):
try:
connection = Connection(settings.YOUTRACK_URL, settings.YOUTRACK_LOGIN, settings.YOUTRACK_PASSWORD)
response, content = connection.createIssue(self.project, assignee=None,
summary=u'Issue from feedback form',
description=self.cleaned_data['description'])
print response
issue_id = response['location'].split('/')[-1]
connection.executeCommand(issue_id, 'Customer email ' + self.cleaned_data['email'])
return True
except YouTrackException:
return False
开发者ID:lowks,项目名称:django_youtrack,代码行数:12,代码来源:forms.py
示例6: add_tags
def add_tags(tag_file,target_url, target_login, target_password):
"""
Add tags from the tag file (run after known creation)
:param tag_file:
:return:
"""
target = Connection(target_url, target_login, target_password)
with open(tag_file) as tag_o_file:
reader = csv.reader(tag_o_file)
for row in reader:
issue = row[0]
for t in row[1:]:
print "executing tag for %s" %(issue)
target.executeCommand(issue, "tag %s" % (t))
开发者ID:KoanCode,项目名称:youtrack-rest-python-library,代码行数:14,代码来源:pivotalTracker2youtrack.py
示例7: process_commits
def process_commits(secret=None):
if context_secret and secret != context_secret:
abort(403)
yt = Connection(yt_url, yt_login, yt_password)
try:
cmd_pattern = re.compile(
r'#((?:%s)-\d+)(?:\s+(.+))?' % '|'.join(yt.getProjects().keys()),
re.IGNORECASE | re.MULTILINE)
except YouTrackException:
app.logger.warning('Cannot get projects from YT')
cmd_pattern = re.compile(r'#([A-z]+-\d+)(?:\s+(.+))?', re.MULTILINE)
payload = json.loads(request.form.get('payload'))
commits_url_template = get_commits_url_template(payload)
for commit in payload['commits']:
message = commit['message'].encode('utf-8')
issue_refs = cmd_pattern.findall(message)
if not issue_refs:
continue
commit_node = commit['node']
commit_url = commits_url_template % commit['raw_node']
timestamp = commit['utctimestamp']
author = commit['author'].encode('utf-8')
match = re.search(r'<(.+?)>', commit['raw_author'])
if not match:
app.logger.error("Cannot get author's email address.")
abort(400)
users = yt.getUsers(params={'q': match.group(1)})
if not users:
app.logger.error('Cannot find user with email ' + match.group(1))
abort(400)
if len(users) != 1:
app.logger.error('Not unique email address ' + match.group(1))
abort(400)
comment = "Commit [%s %s] made by '''%s''' on ''%s''\n{quote}%s{quote}" \
% (commit_url, commit_node, author, timestamp, message)
cmd_exec_result = True
for issue_id, command in issue_refs:
if command is None:
command = ''
try:
app.logger.info("Adding commit %s to issue %s (command: %s)" %
(commit_node, issue_id, command))
yt.executeCommand(issue_id, command, comment, run_as=users[0].login)
except YouTrackException as e:
cmd_exec_result = False
app.logger.error('Failed to add commit %s to issue %s: %s' %
(commit_node, issue_id, e.message))
if not cmd_exec_result:
abort(500)
return 'success'
开发者ID:OpenSorceress,项目名称:youtrack-rest-python-library,代码行数:50,代码来源:bitbucket-broker.py
示例8: submit
def submit(self):
try:
connection = Connection(settings.YOUTRACK_URL, settings.YOUTRACK_LOGIN, settings.YOUTRACK_PASSWORD)
response, content = connection.createIssue(self.project, assignee=None,
summary=self.get_summary().encode('utf-8'),
description=self.cleaned_data['description'].encode('utf-8'))
issue_id = response['location'].split('/')[-1]
commands = ''
if self.subsystem is not None:
commands += ' Subsystem %s' % self.subsystem
commands += ' Customer email ' + self.cleaned_data['email']
connection.executeCommand(issue_id, commands)
return True
except YouTrackException:
return False
开发者ID:ookami-kb,项目名称:django_youtrack,代码行数:15,代码来源:forms.py
示例9: main
def main():
target_url, target_login, target_password, issue_source = sys.argv[1:5]
target = Connection(target_url, target_login, target_password)
if os.path.exists(issue_source): #"treat as a file of issues to delete"
issues = open(issue_source).readlines()
else:
issues = []
issues.append(issue_source)
for issue in issues:
if str(issue).strip() == "": continue
print "deleting %s" % (issue,)
try:
result = target._req("DELETE", "/issue/%s" % (str(issue).strip(),))
print result
except Exception as e:
print e
开发者ID:KoanCode,项目名称:youtrack-rest-python-library,代码行数:16,代码来源:deleteIssue.py
示例10: youtrack2youtrack
def youtrack2youtrack(source_url, source_login, source_password, target_url, target_login, target_password,
project_ids, query = ''):
if not len(project_ids):
print "You should sign at least one project to import"
return
source = Connection(source_url, source_login, source_password)
target = Connection(target_url, target_login,
target_password) #, proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'localhost', 8888)
print "Import issue link types"
for ilt in source.getIssueLinkTypes():
try:
print target.createIssueLinkType(ilt)
except youtrack.YouTrackException, e:
print e.message
开发者ID:rtfpessoa,项目名称:youtrack-rest-python-library,代码行数:16,代码来源:youtrack2youtrack.py
示例11: jira2youtrack
def jira2youtrack(source_url, source_login, source_password, target_url, target_login, target_password, project_id,
issues_count, skip_count):
print("source_url : " + source_url)
print("source_login : " + source_login)
print("target_url : " + target_url)
print("target_login : " + target_login)
print("project_id : " + project_id)
print("issues_count : ", issues_count)
print("skip_count : ", skip_count)
first_chunk = skip_count / 10
last_chunk = issues_count / 10
if issues_count % 10:
last_chunk += 1
source = JiraClient(source_url, source_login, source_password)
target = Connection(target_url, target_login, target_password)
try:
target.createProjectDetailed(project_id, project_id, "", target_login)
except YouTrackException:
pass
for i in range(first_chunk, last_chunk):
start = i * 10 + 1
end = (i + 1) * 10 + 1
if start <= skip_count: start = skip_count + 1
if end > issues_count + 1: end = issues_count + 1
try:
jira_issues = source.get_issues(project_id, start, end)
target.importIssues(project_id, project_id + " assignees",
[create_yt_issue_from_jira_issue(target, issue, project_id) for issue in
jira_issues])
for issue in jira_issues:
try:
process_labels(target, issue)
except YouTrackException, e:
print e
try:
process_attachments(source, target, issue)
except YouTrackException, e:
print e
try:
process_worklog(source, target, issue)
except YouTrackException, e:
print e
开发者ID:rtfpessoa,项目名称:youtrack-rest-python-library,代码行数:46,代码来源:jira2youtrack.py
示例12: googlecode2youtrack
def googlecode2youtrack(project_name, source_login, source_password, target_url, target_login, target_password,
project_id):
target = Connection(target_url, target_login, target_password)
try:
target.getProject(project_id)
except YouTrackException:
target.createProjectDetailed(project_id, project_name, "", target_login)
for field_name, field_type in googleCode.FIELD_TYPES.items():
create_and_attach_custom_field(target, project_id, field_name, field_type)
start = 1
max = 30
while True:
source = gdata.projecthosting.client.ProjectHostingClient()
source.client_login(source_login, source_password, source="youtrack", service="code")
print "Get issues from " + str(start) + " to " + str(start + max)
query = gdata.projecthosting.client.Query(start_index=start, max_results=max)
issues = source.get_issues(project_name, query=query).entry
start += max
if len(issues) <= 0:
break
target.importIssues(project_id, project_name + " assignees",
[to_yt_issue(target, project_id, issue, source.get_comments(project_name, issue_id(issue)).entry) for issue
in issues])
for issue in issues:
import_tags(target, project_id, issue)
import_attachments(target, project_id, project_name, issue, target_login)
开发者ID:BluewireTechnologies,项目名称:youtrack-rest-python-library,代码行数:32,代码来源:googleCode2youtrack.py
示例13: main
def main(args):
""" Add / Update / Remove items from the specified bundle
"""
enum_dest = EnumValueDest
cnx = Connection(args.youtrack, args.yusername, args.ypassword)
enum_bundle = cnx.getEnumBundle(args.bundle)
list_items = {}
for i in enum_bundle.values:
list_items[v.element_name] = v.description
enum_src = EnumValueSrc(args)
for name, desc_data in enum_src.get_src_values():
desc = build_desc(args.desc, desc_data)
if name in list_items.keys():
if not (desc == list_items[name]):
pass
pass
else:
print("%s: %s" % (name, str(desc_data)))
开发者ID:pacopablo,项目名称:YouTrack,代码行数:21,代码来源:manage_enum.py
示例14: import_attachments_only
def import_attachments_only(source_url, source_login, source_password,
target_url, target_login, target_password,
project_ids):
if not project_ids:
print 'No projects to import. Exit...'
return
start = 0
max = 20
source = Connection(source_url, source_login, source_password)
target = Connection(target_url, target_login, target_password)
user_importer = UserImporter(source, target, caching_users=True)
for projectId in project_ids:
while True:
try:
print 'Get issues from %d to %d' % (start, start + max)
issues = source.getIssues(projectId, '', start, max)
if len(issues) <= 0:
break
for issue in issues:
print 'Process attachments for issue %s' % issue.id
attachments = issue.getAttachments()
users = set([])
for a in attachments:
author = a.getAuthor()
if author is not None:
users.add(author)
user_importer.importUsersRecursively(users)
for a in attachments:
print 'Transfer attachment of %s: %s' % (issue.id, a.name.encode('utf-8'))
try:
target.createAttachmentFromAttachment(issue.id, a)
except BaseException, e:
print 'Cannot import attachment [ %s ]' % a.name.encode('utf-8')
print repr(e)
except Exception, e:
print 'Cannot process issues from %d to %d' % (start, start + max)
traceback.print_exc()
raise e
start += max
开发者ID:rtfpessoa,项目名称:youtrack-rest-python-library,代码行数:39,代码来源:youtrack2youtrack.py
示例15: receive_hook
def receive_hook():
payload = request.json
user_name = payload['user_name']
repo_url = payload['repository']['url']
app.logger.debug('Received payload for a push by %s on repository %s', user_name, repo_url)
for commit in payload['commits']:
app.logger.debug('Processing commit %s by %s (%s) in %s', commit['id'], commit['author']['name'], commit['author']['email'], commit['url'])
commit_time = dateutil.parser.parse(commit['timestamp'])
refs = re.findall(app.config['REGEX'], commit['message'], re.MULTILINE)
if not refs:
app.logger.info('''Didn't find any referenced issues in commit %s''', commit['id'])
else:
app.logger.info('Found %d referenced issues in commit %s', len(refs), commit['id'])
yt = Connection(app.config['YOUTRACK_URL'], app.config['YOUTRACK_USERNAME'], app.config['YOUTRACK_PASSWORD'])
user = app.config['DEFAULT_USER']
users = yt.getUsers({ 'q': commit['author']['email'] })
if not users:
app.logger.warn('''Couldn't find user with email address %s. Using default user.''', commit['author']['email'])
elif len(users) > 1:
app.logger.warn('''Found more than one user with email address %s. Using default user.''', commit['author']['email'])
else:
user = users[0]['login']
for ref in refs:
app.logger.info('Processing reference to issue %s', ref)
try:
issue = yt.getIssue(ref)
comment_string = 'Commit [%(url)s %(id)s] made by %(author)s on %(date)s\n{quote}%(message)s{quote}' % {'url': commit['url'], 'id': commit['id'], 'author': commit['author']['name'], 'date': str(commit_time), 'message': commit['message']}
app.logger.debug(comment_string)
yt.executeCommand(issueId=ref, command='comment', comment=comment_string, run_as=user)
except YouTrackException:
app.logger.warn('''Couldn't find issue %s''', ref)
return Response('Payload processed. Thanks!', mimetype='text/plain')
开发者ID:redaphid,项目名称:youtrack-githook,代码行数:36,代码来源:githook.py
示例16: csv2youtrack
def csv2youtrack(source_file, target_url, target_login, target_password):
target = Connection(target_url, target_login, target_password)
source = Client(source_file)
import_custom_fields(source.get_header(), target)
max = 100
while True:
issues = source.get_issue_list(max)
if not len(issues):
break
projects = get_projects(issues)
for p in projects:
try:
target.getProject(p)
except YouTrackException:
target.createProjectDetailed(p, p, "", target_login)
target.importIssues(p, p + " Assignees", [to_yt_issue(issue, target)
for issue in issues if (get_project(issue) == p)])
开发者ID:BluewireTechnologies,项目名称:youtrack-rest-python-library,代码行数:20,代码来源:csv2youtrack.py
示例17: push_event_hook
def push_event_hook():
push_event = request.json
app.logger.debug(push_event)
user_name = push_event['user_name']
repo_name = push_event['repository']['name']
repo_url = push_event['repository']['url']
repo_homepage = push_event['repository']['homepage']
refspec = push_event['ref']
app.logger.debug('Received push event by %s in branch %s on repository %s', user_name, refspec, repo_url)
for commit in push_event['commits']:
app.logger.debug('Processing commit %s by %s (%s) in %s', commit['id'], commit['author']['name'], commit['author']['email'], commit['url'])
commit_time = dateutil.parser.parse(commit['timestamp'])
issues = re.findall(app.config['REGEX'], commit['message'], re.MULTILINE)
if not issues:
app.logger.debug('''Didn't find any referenced issues in commit %s''', commit['id'])
else:
app.logger.debug('Found %d referenced issues in commit %s', len(issues), commit['id'])
yt = Connection(app.config['YOUTRACK_URL'], app.config['YOUTRACK_USERNAME'], app.config['YOUTRACK_PASSWORD'])
default_user = yt.getUser(app.config['DEFAULT_USER'])
user_login = default_user['login']
users = yt.getUsers({ 'q': commit['author']['email'] })
if not users:
app.logger.warn('''Couldn't find user with email address %s. Using default user.''', commit['author']['email'])
elif len(users) > 1:
app.logger.warn('''Found more than one user with email address %s. Using default user.''', commit['author']['email'])
else:
user_login = users[0]['login']
for issue_id in issues:
app.logger.debug('Processing reference to issue %s', issue_id)
try:
issue = yt.getIssue(issue_id)
comment_string = 'Commit [%(url)s %(id)s] on branch %(refspec)s in [%(repo_homepage)s %(repo_name)s] made by %(author)s on %(date)s\n{quote}%(message)s{quote}' % {'url': commit['url'], 'id': commit['id'], 'author': commit['author']['name'], 'date': str(commit_time), 'message': commit['message'], 'repo_homepage': repo_homepage, 'repo_name': repo_name, 'refspec': refspec}
app.logger.debug(comment_string)
yt.executeCommand(issueId=issue_id, command='comment', comment=comment_string.encode('utf-8'),
run_as=user_login.encode('utf-8'))
except YouTrackException:
app.logger.warn('''Couldn't find issue %s''', ref)
return Response('Push event processed. Thanks!', mimetype='text/plain')
开发者ID:gbpepe,项目名称:youtrack-githook,代码行数:42,代码来源:githook.py
示例18: not
target_cf = target.getCustomField(cf_name)
if not(target_cf.type == source_cf.type):
print "In your target and source YT instances you have field with name [ %s ]" % cf_name.encode('utf-8')
print "They have different types. Source field type [ %s ]. Target field type [ %s ]" %\
(source_cf.type, target_cf.type)
print "exiting..."
exit()
else:
if hasattr(source_cf, "defaultBundle"):
create_bundle_from_bundle(source, target, source_cf.defaultBundle, source_cf.type, user_importer)
target.createCustomField(source_cf)
failed_commands = []
for projectId in project_ids:
source = Connection(source_url, source_login, source_password)
target = Connection(target_url, target_login,
target_password) #, proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'localhost', 8888)
#reset connections to avoid disconnections
user_importer.resetConnections(source, target)
link_importer.resetConnections(target)
# copy project, subsystems, versions
project = source.getProject(projectId)
link_importer.addAvailableIssuesFrom(projectId)
project_custom_fields = source.getProjectCustomFields(projectId)
# create bundles and additional values
for pcf_ref in project_custom_fields:
pcf = source.getProjectCustomField(projectId, pcf_ref.name)
if hasattr(pcf, "bundle"):
开发者ID:IQYottabit,项目名称:youtrack-rest-python-library,代码行数:31,代码来源:youtrack2youtrack.py
示例19: import_attachments_only
def import_attachments_only(source_url, source_login, source_password,
target_url, target_login, target_password,
project_ids, params=None):
if not project_ids:
print 'No projects to import. Exit...'
return
if params is None:
params = {}
start = 0
max = 20
source = Connection(source_url, source_login, source_password)
target = Connection(target_url, target_login, target_password)
user_importer = UserImporter(source, target, caching_users=params.get('enable_user_caching', True))
for projectId in project_ids:
while True:
try:
print 'Get issues from %d to %d' % (start, start + max)
issues = source.getIssues(projectId, '', start, max)
if len(issues) <= 0:
break
for issue in issues:
print 'Process attachments for issue %s' % issue.id
existing_attachments = dict()
try:
for a in target.getAttachments(issue.id):
existing_attachments[a.name + '\n' + a.created] = a
except youtrack.YouTrackException, e:
if e.response.status == 404:
print "Skip importing attachments because issue %s doesn't exist" % issue.id
continue
raise e
attachments = []
users = set([])
for a in issue.getAttachments():
if a.name + '\n' + a.created in existing_attachments and not params.get('replace_attachments'):
print "Skip attachment '%s' (created: %s) because it's already exists" \
% (a.name.encode('utf-8'), a.created)
continue
attachments.append(a)
author = a.getAuthor()
if author is not None:
users.add(author)
user_importer.importUsersRecursively(users)
for a in attachments:
print 'Transfer attachment of %s: %s' % (issue.id, a.name.encode('utf-8'))
try:
target.createAttachmentFromAttachment(issue.id, a)
except BaseException, e:
print 'Cannot import attachment [ %s ]' % a.name.encode('utf-8')
print repr(e)
continue
if params.get('replace_attachments'):
try:
old_attachment = existing_attachments.get(a.name + '\n' + a.created)
if old_attachment:
print 'Deleting old attachment'
target.deleteAttachment(issue.id, old_attachment.id)
except BaseException, e:
print "Cannot delete attachment '%s' from issue %s" % (a.name.encode('utf-8'), issue.id)
print e
开发者ID:IQYottabit,项目名称:youtrack-rest-python-library,代码行数:63,代码来源:youtrack2youtrack.py
示例20: bugzilla2youtrack
def bugzilla2youtrack(target_url, target_login, target_pass, bz_db, bz_host, bz_port, bz_login, bz_pass,
bz_product_names, issues_filter):
# connecting to bz
client = Client(bz_host, int(bz_port), bz_login, bz_pass, db_name=bz_db)
if not len(bz_product_names):
answer = raw_input("All projects will be imported. Are you sure? [y/n]")
if answer.capitalize() != "Y":
sys.exit()
bz_product_names = client.get_product_names()
print "bz_product_names : " + repr(bz_product_names)
# connecting to yt
target = Connection(target_url, target_login, target_pass)
print "Creating issue link types"
link_types = client.get_issue_link_types()
for link in link_types:
print "Processing link type [ %s ]" % link.name
try:
target.createIssueLinkType(to_yt_issue_link_type(link))
except YouTrackException:
print "Can't create link type [ %s ] (maybe because it already exists)" % link.name
print "Creating issue link types finished"
print "Creating custom fields"
custom_fields = client.get_custom_fields()
for cf in custom_fields:
create_yt_custom_field(cf, target)
print "Creating custom fields finished"
for key in bugzilla.FIELD_TYPES:
if key not in youtrack.EXISTING_FIELDS:
create_custom_field(target, bugzilla.FIELD_TYPES[key], key, True, bundle_policy="1")
bz_product_ids = []
for name in bz_product_names:
product_id = str(client.get_product_id_by_name(name))
bz_product_ids.append(product_id)
print "Creating project [ %s ] with name [ %s ]" % (product_id, name)
try:
target.getProject(str(product_id))
except YouTrackException:
target.createProjectDetailed(str(product_id), name, client.get_project_description(product_id),
target_login)
print "Importing components for project [ %s ]" % product_id
process_components(client.get_components(product_id), product_id, target)
print "Importing components finished for project [ %s ]" % product_id
print "Importing versions for project [ %s ]" % product_id
process_versions(client.get_versions(product_id), product_id, target)
print "Importing versions finished for project [ %s ] finished" % product_id
print "Importing issues to project [ %s ]" % product_id
max_count = 100
count = 0
from_id = 0
bz_issues_count = client.get_issues_count(product_id)
while count < bz_issues_count:
batch = client.get_issues(product_id, from_id, from_id + max_count)
batch = [bz_issue for bz_issue in batch if (issues_filter(bz_issue))]
count += len(batch)
from_id += max_count
target.importIssues(product_id, product_id + " assignees",
[to_yt_issue(bz_issue, product_id, target) for bz_issue in batch])
# todo convert to good tags import
for issue in batch:
tags = issue["keywords"] | issue["flags"]
for t in tags:
print "Processing tag [ %s ]" % t.encode('utf8')
target.executeCommand(str(product_id) + "-" + str(issue[get_number_in_project_field_name()]),
"tag " + t.encode('utf8'))
for issue in batch:
for attach in issue["attachments"]:
print "Processing attachment [ %s ]" % (attach.name.encode('utf8'))
content = StringIO(attach.content)
target.createAttachment(str(product_id) + "-" + str(issue[get_number_in_project_field_name()]),
attach.name, content, attach.reporter
, created=str(int(attach.created) * 1000))
print "Importing issues to project [ %s ] finished" % product_id
# todo add pagination to links
print "Importing issue links"
cf_links = client.get_issue_links()
duplicate_links = client.get_duplicate_links()
if len(duplicate_links):
try:
target.createIssueLinkTypeDetailed("Duplicate", "duplicates", "is duplicated by", True)
except YouTrackException:
print "Can't create link type [ Duplicate ] (maybe because it already exists)"
depend_links = client.get_dependencies_link()
if len(depend_links):
try:
target.createIssueLinkTypeDetailed("Depend", "depends on", "is required for", True)
except YouTrackException:
print "Can't create link type [ Depend ] (maybe because it already exists)"
links = cf_links | duplicate_links | depend_links
#.........这里部分代码省略.........
开发者ID:Couchsurfing,项目名称:youtrack-rest-python-library,代码行数:101,代码来源:bugzilla2youtrack.py
注:本文中的youtrack.connection.Connection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论