def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("name") args = parser.parse_args() if is_name_valid(args.name): template_basename = 'script_template' script_exe_name = 'git_' + args.name script_py_name = args.name + '.py' templates = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'misc', template_basename) # CREATE EXECUTABLE FILE script_exe_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), script_exe_name) create_file(templates, script_exe_path, { r'<name>': args.name }) st = os.stat(script_exe_path) os.chmod(script_exe_path, st.st_mode | stat.S_IEXEC) # CREATE PYTHON FILE template_py_path = templates + '_py' script_py_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), script_py_name) create_file(template_py_path, script_py_path, { r'<name>': args.name }) # CREATE PYTHON TEST FILE template_test_py_path = templates + '_test_py' script_test_py_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'test', script_py_name) create_file(template_test_py_path, script_test_py_path, { r'<name>': args.name, r'<main_method_name>': inflection.camelize(args.name) }) # DONE print('Templates for new script successfuly created. Run "' + script_exe_name + '" to try it out.') else: print('The name has to be of the form "new_script_name"') sys.exit(-1)
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-d", "--description") parser.add_argument("-n", "--nobranch", action="store_true") parser.add_argument("title") args = parser.parse_args() if len(args.title) < 5: print "The title should be 5 characters or longer" parser.print_usage() sys.exit(2) owner, repo = Helper.owner_and_repo() api = GithubAPIGateway(owner, repo, token=os.environ['GITHUB_TOKEN']) username = api.call('user')[0]['login'] data = { 'title': args.title, 'assignee': username } if args.description is not None: data.update(body=args.description) issue = api.call('create_issue', owner=owner, repo=repo, data=data)[0] print issue['html_url'] branch_name = Helper.branch_name(issue) if args.nobranch == False: Helper.create_branch(branch_name) else: print branch_name
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("infolder", nargs = '?', help = "Specify folder. Example: Current/RoboEMS" ) list_wrike_folders(parser.parse_args())
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-i", "--issue_number", required=True) group = parser.add_mutually_exclusive_group(required=True) group.add_argument("-l", "--label") group.add_argument("-a", "--all-labels", dest='all_labels', action='store_true') parser.set_defaults(all_labels=False) remove_label_from_issue(parser.parse_args())
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-c", "--circleci-ignore", action = "store_true") parser.add_argument("-f", "--force", action = "store_true") parser.add_argument("-u", "--pr-ignore", action = "store_true") parser.add_argument("-b", "--branch-name") args = parser.parse_args() try: Push(args).doit() except (ProtectedBranchException, PushException) as e: print(str(e)) sys.exit(e.exit_code())
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("item_counter") args = parser.parse_args() owner, repo = Helper.owner_and_repo() api = PyRollbarAPI(repo) item = api.get_item_from_counter(args.item_counter) branch_name = Helper.branch_name_from_item(item['id'], item['title']) result = Helper2().create_branch(branch_name) if result[0] != 0: print(result[1]) sys.exit(result[0])
def run(): # GET ARGUMENTS parser = argparse.ArgumentParser(prog=get_script_name_from_python_file(__file__)) parser.add_argument("title") parser.add_argument("-g", "--github-issue", action="store_true", help="Create github issue") parser.add_argument( "-n", "--nobranch", action="store_true", help="Don't create branch. Relevant only if -g is specified." ) parser.add_argument("-s", "--self-assign", action="store_true", help="Assign task and issue to self") parser.add_argument("-d", "--description") group = parser.add_mutually_exclusive_group(required=True) group.add_argument("-i", "--id-folder", help="Use git_list_wrike_folders to find out folder ids") group.add_argument("-t", "--title-folder", help="Use git_list_wrike_folders to find out folder titles") create_task(parser.parse_args())
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-t", "--title") parser.add_argument("-b", "--body") parser.add_argument("-w", "--wrike-task") parser.add_argument("-g", "--github-issue") parser.add_argument("-r", "--rollbar-item") parser.add_argument("-d", "--debug", action="store_true") parser.add_argument("-c", "--changes", action="store_true") parser.add_argument("-a", "--authors", action="store_true") try: create_pr(parser.parse_args()) except ObjectNotFoundException as e: print(str(e)) except InvalidTitleException as e: print(str(e)) parser.print_usage()
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-i", "--issues", action = 'store_true') parser.add_argument("-p", "--pull-requests", action = 'store_true') args = parser.parse_args() main_url = 'https://github.com/{0}/{1}'.format(*Helper2().owner_and_repo()) urls = [] if args.issues: urls.append(main_url + '/issues') if args.pull_requests: urls.append(main_url + '/pulls') if len(urls) <= 0: urls.append(main_url) for url in urls: webbrowser.open(url)
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 run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-l", "--list-only", action="store_true") args = parser.parse_args() h2 = Helper2() owner, repo = h2.owner_and_repo() api = GithubAPIGateway(owner, repo, token=os.environ['GITHUB_TOKEN']) branch = str(h2.current_branch()) prs = api.call('list_pr', owner=owner, repo=repo, data={ 'head': branch })[0] url = None for pr in prs: if pr['head']['ref'] == branch: url = pr['html_url'] break if url is not None: print url if not args.list_only: webbrowser.open(url) else: print "No PRs on this branch"
import os import datetime import argparse import re import sys from misc.helper2 import get_script_name_from_python_file parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("title") args = parser.parse_args() if re.match('\w+$', args.title) is None: print "The title can only contain alphanumeric characters" sys.exit(-1) dirpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'misc', 'release_notes') filename = '{0}_{1}'.format(datetime.datetime.now().strftime('%Y%m%d%H%M%S'), args.title) filepath = os.path.join(dirpath, filename) with open(filepath, 'w') as f: pass print filepath
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-l", "--links", action="store_true") list_reviewers(parser.parse_args())
def run(): # PARSE ARGUMENTS parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-n", "--nobranch", action="store_true") parser.add_argument("taskids", nargs='+') issue_from_wrike(parser.parse_args())
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-o", "--option") parser.add_argument("-f", "--flag", action="store_true") parser.add_argument("positional", nargs='?') <name>(parser.parse_args())
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) print(open_item(parser.parse_args()))
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-i", "--issue_number") list_labels(parser.parse_args())