コード例 #1
0
ファイル: pep8.py プロジェクト: felixsan/githooks
def main():
    if skip_check(DISPLAY_NAME):
        print "* Skipping %s check..." % DISPLAY_NAME
        return
    files = get_modified_files(FILE_EXT)
    if files:
        print "* Running %s check..." % DISPLAY_NAME
        tempdir = tempfile.mkdtemp()
        for name in files:
            filename = os.path.join(tempdir, name)
            filepath = os.path.dirname(filename)
            if not os.path.exists(filepath):
                os.makedirs(filepath)
            with file(filename, 'w') as f:
                system('git', 'show', ':%s' % name, stdout=f)
        output = system('pep8',
                        '--show-source',
                        '--statistics',
                        '--ignore=E501,E121,E125,E126,E128',
                        '.',
                        cwd=tempdir)
        shutil.rmtree(tempdir)
        if output:
            print "Not committing since there are %s errors.\n" % DISPLAY_NAME
            print output,
            print
            sys.exit(1)
コード例 #2
0
ファイル: httpc.py プロジェクト: huangdehui2013/pcl
 def _random_tmp_file(self, key):
     from datetime import datetime
     name = str(datetime.now())
     name = name.replace(' ', '_')
     name = name.replace(':', '_')
     name = name.replace('.', '_')
     system ('find "%s" -amin +%d 2>/dev/null | xargs rm -f 2>/dev/null 1>/dev/null' % (self.tmp_dir, self.keep_minute), log_fun=None)
     return self.tmp_dir + key + name
コード例 #3
0
ファイル: pep8.py プロジェクト: felixsan/githooks
def main():
    if skip_check(DISPLAY_NAME):
        print "* Skipping %s check..." % DISPLAY_NAME
        return
    files = get_modified_files(FILE_EXT)
    if files:
        print "* Running %s check..." % DISPLAY_NAME
        tempdir = tempfile.mkdtemp()
        for name in files:
            filename = os.path.join(tempdir, name)
            filepath = os.path.dirname(filename)
            if not os.path.exists(filepath):
                os.makedirs(filepath)
            with file(filename, 'w') as f:
                system('git', 'show', ':%s' % name, stdout=f)
        output = system('pep8', '--show-source', '--statistics', '--ignore=E501,E121,E125,E126,E128', '.', cwd=tempdir)
        shutil.rmtree(tempdir)
        if output:
            print "Not committing since there are %s errors.\n" % DISPLAY_NAME
            print output,
            print
            sys.exit(1)
コード例 #4
0
def main():
    os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))

    parser = common.create_parser(True)
    args = parser.parse_args()

    # Clone depot_tools
    if not os.path.exists("depot_tools"):
        subprocess.check_call([
            "git", "clone",
            "https://chromium.googlesource.com/chromium/tools/depot_tools.git",
            "depot_tools"
        ])

    # Clone Skia
    match = re.match('(m\\d+)(?:-([0-9a-f]+)(?:-([1-9][0-9]*))?)?',
                     args.version)
    if not match:
        raise Exception('Expected --version "m<ver>-<sha>", got "' +
                        args.version + '"')
    branch = "chrome/" + match.group(1)
    commit = match.group(2)
    iteration = match.group(3)

    if os.path.exists("skia"):
        os.chdir("skia")
        if subprocess.check_output(["git", "branch", "--list", branch]):
            print("> Advancing", branch)
            subprocess.check_call(["git", "checkout", "-B", branch])
            subprocess.check_call(["git", "fetch"])
            subprocess.check_call(
                ["git", "reset", "--hard", "origin/" + branch])
        else:
            print("> Fetching", branch)
            subprocess.check_call(["git", "reset", "--hard"])
            subprocess.check_call([
                "git", "fetch", "origin", branch + ":remotes/origin/" + branch
            ])
            subprocess.check_call(["git", "checkout", branch])
    else:
        print("> Cloning", branch)
        subprocess.check_call([
            "git", "clone", "https://skia.googlesource.com/skia", "--quiet",
            "--branch", branch, "skia"
        ])
        os.chdir("skia")

    # Checkout commit
    print("> Checking out", commit)
    subprocess.check_call(
        ["git", "-c", "advice.detachedHead=false", "checkout", commit])

    # Apply patches
    subprocess.check_call(["git", "reset", "--hard"])
    for x in pathlib.Path(os.pardir, 'patches').glob('*.patch'):
        print("> Applying", x)
        subprocess.check_call(["git", "apply", str(x)])

    # git deps
    if 'windows' == common.system():
        env = os.environ.copy()
        env['PYTHONHTTPSVERIFY'] = '0'
        subprocess.check_call(["python", "tools/git-sync-deps"], env=env)
    else:
        subprocess.check_call(["python2", "tools/git-sync-deps"])

    return 0