コード例 #1
0
    def mutate(parent, info, name: str, url: str):
        print(f'track repo root: {parent}')
        repo: Document = Document(db[REPOS])
        print(f'repo.modified: {repo.modified}')
        try:
            repo_root = path.join(GIT_ROOT, format_filename(name))
            repo = db[REPOS].createDocument({
                'name': name,
                'url': url,
                'path': repo_root,
            })
            repo.save()
            print(f'repo.modified (saved): {repo.modified}')

            clone(url, repo_root)

            return TrackRepo(repo=repo)
        except (pyArangoException, GraphQLLocatedError, AttributeError) as e:
            # TODO: log/report error
            # NB: document was saved.
            if repo.modified is False:
                # TODO: log/report error
                rmtree(repo.path, ignore_errors=True)
                repo.delete()
            raise e
コード例 #2
0
def main():
    """
    main function of the script
    """
    import argparse
    parser = argparse.ArgumentParser(description='make chromeos mirror')
    parser.add_argument('branches',
                        metavar='branch',
                        type=str,
                        nargs='*',
                        help='deprecated')
    args = parser.parse_args()

    if args.branches:
        sys.stdout.write(
            'passing branches in the command line is deprecated and now ignored.\n'
        )
        sys.stdout.write(
            'the branches for each kernel version are now hardcoded in the script.\n'
        )

    success = True

    with Tempdir() as tmpdir:
        output_tree_copy = os.path.join(tmpdir, 'out-pull')
        input_tree_copy = os.path.join(tmpdir, 'input')
        sys.stdout.write('Cloning input tree\n')
        sys.stdout.flush()
        git.clone(INPUT_TREE, input_tree_copy, options=['-q', '--mirror'])
        sys.stdout.write('Cloning output tree\n')
        sys.stdout.flush()
        git.clone(OUTPUT_TREE, output_tree_copy, options=['-q', '--mirror'])

        for version in VERSIONS:
            mirror = GitMirror(
                input_tree_copy,
                OUTPUT_TREE,
                version.branches,
                lambda config, ver=version: _create_chrome_driver(config, ver),
                'iwl7000-tree')
            mirror.output_branch_name = lambda x, ver=version: '%s__%s' % (
                ver.kbranch, x)
            mirror.git_name = 'Intel ChromeOS bot'
            mirror.git_email = '*****@*****.**'
            mirror.clean_output = False
            mirror.filter_message = _filter_message
            mirror.output_tree_pull = output_tree_copy
            mirror.debug('=========== working on %s' % version.kbranch)
            if not mirror.mirror():
                success = False

    if not success:
        sys.exit(1)
コード例 #3
0
ファイル: controler.py プロジェクト: 5l1v3r1/tools-2
def method_a():
    logger.info("Try to Clone straightly")
    git_dir = os.path.join(paths.GITHACK_DIST_TARGET_PATH, ".git")
    if os.path.exists(git_dir):
        logger.warning("[Skip][First Try] %s already exists." % (git_dir))
        return valid_git_repo()
    return clone()
コード例 #4
0
ファイル: blorgh.py プロジェクト: varl/blorgh
  args = parser.parse_args()

  if args.output_dir:
    output_dir = args.output_dir
  else:
    print("No output directory specified... Aborting.")
    sys.exit(1)

  if args.directory:
    input_dir = args.directory
  else:
    print("No source directory specified... Aborting.")
    sys.exit(1)

  if args.url:
    git.clone(args.url, input_dir)

  print("Generating static resources from '{}' to '{}'").format(
      input_dir, output_dir)

  mkd.generate_static(input_dir, output_dir)

  print("\n\nDone!")
  sys.exit(0)





コード例 #5
0
def monitor_chromeos(addrs):
    cachedir = CACHEDIR
    if not cachedir:
        cachedir = os.path.join(os.getcwd(), '..', 'kernel-cache')
    if not os.path.isdir(cachedir):
        git.clone(DBTREE, cachedir, options=['--quiet', '--bare'])
    git.set_origin(DBTREE, cachedir)
    git.remote_update(cachedir)
    os.chdir(cachedir)
    db = git.commit_message('origin/monitor').split('\n')
    for line in db:
        for v in VERSIONS:
            if line.startswith(v.kbranch + ': '):
                v.start = line.split(': ')[1]
    prev = None
    tree_id = git.get_commit_var('origin/monitor', 'T')
    parent_id = git.rev_parse('origin/monitor')
    db = []
    any_changes = False
    for v in VERSIONS:
        if v.ktree != prev:
            git.set_origin(v.ktree, cachedir)
            git.remote_update(cachedir)
            prev = v.ktree
        range = 'origin/' + v.kbranch
        if v.start:
            range = v.start + '..' + range
        try:
            log = git.log([
                range, '--',
                'drivers/net/wireless%s/iwl7000' % v.wifiversion
            ])
        except:
            # maybe they rebased? try again w/o start
            range = 'origin/' + v.kbranch
            log = git.log([
                range, '--',
                'drivers/net/wireless%s/iwl7000' % v.wifiversion
            ])
        if log:
            msg = MIMEText(log)
            msg['Subject'] = 'new changes in %s' % v.kbranch
            msg['From'] = '*****@*****.**'
            msg['To'] = ', '.join(addrs)
            s = smtplib.SMTP(SMTPSERVER)
            s.sendmail('*****@*****.**', addrs, msg.as_string())
            s.quit()
            any_changes = True
        db.append(v.kbranch + ': ' + git.rev_parse('origin/%s' % v.kbranch))
    db = ['update commit tracker', ''] + db + ['']
    msg = '\n'.join(db)

    git.set_origin(DBTREE)

    if any_changes:
        new_tree_id = git.commit_tree(tree_id, [parent_id],
                                      msg,
                                      env={
                                          'GIT_AUTHOR_NAME': 'cros-monitor',
                                          'GIT_AUTHOR_EMAIL': '',
                                          'GIT_COMMITTER_NAME': 'cros-monitor',
                                          'GIT_COMMITTER_EMAIL': '',
                                      })
        git.push(['origin', '%s:monitor' % new_tree_id])
コード例 #6
0
def monitor_chromeos(jira):
    n_tickets = 0
    cachedir = CACHEDIR
    if not cachedir:
        cachedir = os.path.join(os.getcwd(), '..', 'kernel-cache')
    if not os.path.isdir(cachedir):
        debug("Clone database tree to %s..." % cachedir)
        git.clone(DBTREE, cachedir, options=['--quiet', '--bare'])
    git.set_origin(DBTREE, cachedir)
    debug("Update database tree ...")
    git.remote_update(cachedir)
    os.chdir(cachedir)
    db = git.commit_message('origin/monitor').split('\n')
    for line in db:
        for v in VERSIONS:
            if line.startswith(v.kbranch + ': '):
                v.start = line.split(': ')[1]
    prev = None
    tree_id = git.get_commit_var('origin/monitor', 'T')
    parent_id = git.rev_parse('origin/monitor')
    db = []
    any_changes = False
    for v in VERSIONS:
        if v.ktree != prev:
            git.set_origin(v.ktree, cachedir)
            debug("Update kernel tree to %s" % v.ktree)
            git.remote_update(cachedir, env={'https_proxy': PROXY})
            prev = v.ktree
        range = 'origin/' + v.kbranch
        if v.start:
            range = v.start + '..' + range
        log_args_front = [
            '--no-merges',
            '--invert-grep',
            '--grep=iwl7000-tree:',
        ]
        log_args_back = [
            '--',
            'drivers/net/wireless/iwl7000',
        ]
        try:
            log = git.log(log_args_front + [range] + log_args_back)
        except:
            # maybe they rebased? try again w/o start
            range = 'origin/' + v.kbranch
            log = git.log(log_args_front + [range] + log_args_back)
        if log:
            any_changes = True
            # create a jira ticket with this info
            date = time.strftime('%Y-%m-%d')
            fields = {
                'summary': '[%s] google changed tree %s' % (v.kbranch, date),
                'description': '{noformat}\n%s\n{noformat}\n' % log,
            }
            fields.update(COMMON_JIRA_FIELDS)
            debug("creating new ticket ...")
            ticket = jira.create_issue(fields=fields)
            for watcher in WATCHERS:
                jira.add_watcher(ticket, watcher)
            jira.assign_issue(ticket, ASSIGNEE)
            debug("created ticket %s" % ticket)

        db.append(v.kbranch + ': ' + git.rev_parse('origin/%s' % v.kbranch))

    db = ['update commit tracker', ''] + db + ['']
    msg = '\n'.join(db)

    git.set_origin(DBTREE)

    if any_changes:
        new_tree_id = git.commit_tree(tree_id, [parent_id],
                                      msg,
                                      env={
                                          'GIT_AUTHOR_NAME': 'cros-monitor',
                                          'GIT_AUTHOR_EMAIL': '',
                                          'GIT_COMMITTER_NAME': 'cros-monitor',
                                          'GIT_COMMITTER_EMAIL': '',
                                      })
        git.push(['origin', '%s:monitor' % new_tree_id])