コード例 #1
0
ファイル: cli.py プロジェクト: bmwant/podmena
def global_uninstall():
    rc = unset_git_global_hooks_path()
    if rc == 0:
        _info('Deactivated podmena globally')
    elif rc == 5:
        _warn('podmena is not installed globally!')
        sys.exit(1)
    else:
        _warn('Failed to deactivate')
        sys.exit(rc)
コード例 #2
0
ファイル: fetcher.py プロジェクト: bmwant/podmena
    def request(self, url=None):
        if url is None:
            url = self.url
        _info(f'Requesting {url}')

        req = urllib.request.Request(url)
        with contextlib.closing(urllib.request.urlopen(req)) as resp:
            if resp.status != HTTPStatus.OK:
                raise RuntimeError('Got wrong status %s' % resp.status)
            return resp.read().decode('utf-8')
コード例 #3
0
ファイル: cli.py プロジェクト: bmwant/podmena
def global_install():
    global_hooks_path = os.path.expanduser('~/.podmena/hooks')
    confirm_info = (
        'This will set one global hooks directory for all you repositories.\n'
        'This action may deactivate your previous hooks installed per '
        'repository.\nFor more info see '
        'https://git-scm.com/docs/git-config#git-config-corehooksPath\n')
    _info(confirm_info)
    if click.confirm('Do you want to continue?', abort=True):
        if not os.path.exists(global_hooks_path):
            os.makedirs(global_hooks_path)

        src_file = os.path.join(RESOURCES_DIR, HOOK_FILENAME)
        dst_file = os.path.join(global_hooks_path, HOOK_FILENAME)
        shutil.copyfile(src_file, dst_file)
        os.chmod(dst_file, 0o0775)
        db_file = os.path.join(RESOURCES_DIR, DATABASE_FILE)
        db_link = os.path.join(global_hooks_path, DATABASE_FILE)
        force_symlink(db_file, db_link)
        set_git_global_hooks_path(global_hooks_path)
        _note('Installed globally for all repos')