def run(): owner, repo = Helper.owner_and_repo() github_gateway = GithubAPIGateway(owner, repo) wrike_gateway = Wrike(data_filepath=Helper.get_data_filepath('wrike')) printer = StatusPrinter(70) merge(printer, github_gateway) close_wrike_task(printer, github_gateway, wrike_gateway) remove_remote_branch(printer, owner, repo)
def create_task(args): # INITIALIZE DRIVERS AND HELPERS wrike_gateway = Wrike(wait_for_redirect=True, data_filepath=Helper.get_data_filepath("wrike")) github_helper = GithubAPIHelper() # GET FOLDER ID id_folder = args.id_folder should_check_folder_id_validity = True if id_folder is None: res = WrikeAPIHelper(wrike=wrike_gateway).get_folders_list(args.title_folder) if res["id"] is None: print 'Folder "{0}" could not be found'.format(res["prepend"]) sys.exit(-1) else: id_folder = res["id"] should_check_folder_id_validity = False if should_check_folder_id_validity: f = wrike_gateway.get_folder(id_folder) if f is None: print "Wrong folder id" sys.exit(-1) # CREATE TASK create_task_params = {"description": args.description} if args.self_assign: contact = wrike_gateway.get_current_contact() create_task_params.update({"responsibles": "['{0}']".format(contact["id"])}) task = wrike_gateway.create_task(id_folder, args.title, create_task_params) print task["permalink"] # CREATE ISSUE if args.github_issue: issue = github_helper.issue_from_task_object(task, args.self_assign) print issue["html_url"] wrike_gateway.create_task_comment(task["id"], issue["html_url"]) branch_name = Helper.branch_name(issue) if not args.nobranch: Helper.create_branch(branch_name) else: print branch_name wrike_gateway.redirect(task["permalink"])
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("taskid") args = parser.parse_args() taskid = args.taskid match = re.match(r'^https:\/\/www\.wrike\.com\/open\.htm\?id=(\d+)$', taskid) if match is not None: taskid = match.group(1) wrike_gateway = Wrike(data_filepath=Helper.get_data_filepath('wrike')) task = wrike_gateway.get_task(taskid) if task is not None: branch_name = Helper.branch_name_from_task(taskid, task['title']) result = Helper2().create_branch(branch_name) if result[0] != 0: print(result[1]) sys.exit(result[0]) else: print "Task not found"
def issue_from_wrike(args): # GET TASKS tasks = [] wrike_gateway = Wrike(data_filepath=Helper.get_data_filepath('wrike'), wait_for_redirect=True) github_gateway = GithubAPIGateway(*Helper.owner_and_repo()) for taskid in args.taskids: task = wrike_gateway.get_task(taskid) if task is None: print "'{0}' is not a valid taskid or it cannot be found".format(taskid) sys.exit(-1) tasks.append(task) # BODY OF ISSUE body = '' for task in tasks: body += '### {0}\n___\n\n{1}\n'.format(task['permalink'].encode('utf-8'), task['description'].encode('utf-8')) # TITLE OF ISSUE title = tasks[0]['title'] if len(tasks) > 1: title += ' (+{0} Wrike tasks)'.format(len(tasks) - 1) # CREATE ISSUE issue = github_gateway.create_issue(title, True, {'body': body}) print issue['html_url'] branch_name = Helper.branch_name(issue) if args.nobranch == False: Helper.create_branch(branch_name) else: print branch_name # WRITE LINK TO ISSUE ON EVERY TASK AND SET ASIGNEE wrike_gateway.redirect(issue['html_url']) contact = wrike_gateway.get_current_contact() for task in tasks: wrike_gateway.create_task_comment(task['id'], issue['html_url']) if contact['id'] not in task['responsibleIds']: wrike_gateway.change_task(task['id'], { 'addResponsibles': "['{0}']".format(contact['id']) })
def __init__(self, args, task_number): super(TaskHandler, self).__init__(args) self.task_number = task_number self.obj = Wrike(data_filepath=Helper.get_data_filepath('wrike')).get_task(task_number) if self.obj is None: raise ObjectNotFoundException('task', task_number)
def __init__(self, **gateways): self._wrike_gateway = ( Wrike(data_filepath=Helper.get_data_filepath("wrike")) if gateways.get("wrike") is None else gateways["wrike"] )