コード例 #1
0
def __status_snapshot(git_wrkspc,
                      release_name,
                      master_hash=None,
                      suffix="snap",
                      debug=False,
                      verbose=False):
    filename = "/tmp/%s.%s" % (release_name, suffix)

    num = 1
    while os.path.exists(filename):
        filename = "/tmp/%s+%s.%s" % (release_name, num, suffix)
        num += 1

    with open(filename, "w") as out:
        if master_hash is not None:
            print("Master hash: %s" % (master_hash, ), file=out)

        print(file=out)
        for line in git_status(sandbox_dir=git_wrkspc,
                               debug=debug,
                               verbose=verbose):
            print(line, file=out)

        print(file=out)
        for name, status, sha1, branch in \
          git_submodule_status(sandbox_dir=git_wrkspc, debug=debug,
                               verbose=verbose):
            print("%s%s %s (%s)" % (status, sha1, name, branch), file=out)
コード例 #2
0
def main(config_file):
    config = config_from_file(config_file)
    for section, settings in config.items():
        # create directory for backup
        if 'backup_dir' in settings and \
           not os.path.exists(settings['backup_dir']):
            os.makedirs(settings['backup_dir'])

        # create empty git repo
        if not os.path.exists(os.path.join(settings['backup_dir'], '.git')):
            git_init(settings['backup_dir'])

        if settings['type'] in ['mysql', 'pgsql']:
            # backup database
            print run_command(construct_dump_command(settings,
                                                     settings['type']))
        else:
            # backup files
            files_dir = os.path.join(settings['files_dir'], '.')
            backup_dir = settings['backup_dir']
            print run_command('cp -a {0} {1}'.format(files_dir, backup_dir))

        # add changes in repo
        git_add_all(settings['backup_dir'])

        # get status message for commit
        status_message = git_status(settings['backup_dir'])
        print status_message

        # commit changes
        git_commit(settings['backup_dir'], status_message)

        # add remote for pushing
        git_remote_add(settings['backup_dir'], settings['git_remote'])

        # push changes
        git_push(settings['backup_dir'])

        # done
        print 'Done! {0} backuped!'.format(section)
コード例 #3
0
def __delete_untracked(git_sandbox, debug=False, verbose=False):
    untracked = False
    for line in git_status(sandbox_dir=git_sandbox,
                           debug=debug,
                           verbose=verbose):
        if line.startswith("#"):
            if len(line) <= 1 or not line[1].isspace():
                line = line[1:]
            else:
                line = line[2:]

        if not untracked:
            if line.startswith("Untracked files:"):
                untracked = True
            continue

        filename = line.strip()
        if filename == "" or filename.find("use \"git add") >= 0:
            continue

        if filename.endswith("/"):
            shutil.rmtree(os.path.join(git_sandbox, filename[:-1]))
        else:
            os.remove(os.path.join(git_sandbox, filename))
コード例 #4
0
ファイル: screwdriver.py プロジェクト: substance/screwdriver
 def status(self, args=None):
   config = self.get_project_config()
   for m in config["modules"]:
     git_status(self.root_dir, m)
コード例 #5
0
ファイル: substance.py プロジェクト: Web5design/substance
 def status(root, config, args=None):
   for m in config["modules"]:
     git_status(root_dir, m)
コード例 #6
0
ファイル: screwdriver.py プロジェクト: substance/screwdriver
 def status(self, args=None):
     config = self.get_project_config()
     for m in config["modules"]:
         git_status(self.root_dir, m)
コード例 #7
0
ファイル: substance.py プロジェクト: andreypopp/substance
 def status(root, config, args=None):
     for m in config["modules"]:
         git_status(root_dir, m)