Exemple #1
0
    def migrate(self):
        """Bring the db schema up to date by running any needed model
        migrations."""
        debug(self.db_conf)
        dirname = os.path.dirname(self.db_conf['open'])
        if not dirname:
            dirname = os.path.dirname(__file__)
        with cd(dirname):
            # Make sure the sqlite3 db exists before we try to migrate it
            if not os.path.exists(os.path.basename(self.db_conf['open'])):
                raise DBNotFound(
                    "DB %s doesn't exist, so we can't migrate it." %
                    self.db_conf['open'])

            # Goose apparently returns 0 even when it errors, so we
            # have to check stderr and react accordingly.
            cmd = "goose -dir db/{0} {0} {1} up".format(
                self.db_conf['driver'], os.path.basename(self.db_conf['open']))
            debug("Executing `%s`" % cmd)
            p = subprocess.Popen(cmd,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 shell=True)
            out, err = p.communicate()
            out = out.decode("utf-8")
            err = err.decode("utf-8")
            if err != '':
                sys.stderr.write("%s\n%s" % (out, err))
                raise subprocess.CalledProcessError(0, cmd, out + err)
            return out
Exemple #2
0
def fetch(project) :
    working_dir = config['projects'][project]['repo_path']
    if not os.path.exists(working_dir) :
        clone(project)
    res = 'empty'
    with path.cd( working_dir ) :
        res = process.get_output( [ "git", "fetch" ] )
    return res
Exemple #3
0
def branches(project) :
    working_dir = config['projects'][project]['repo_path']
    if not os.path.exists(working_dir) :
        clone(project)

    result = []
    with path.cd( working_dir ) :
        res = process.get_output( ["git", "branch", "-r"] )
        brs = re.findall("origin/[\w\-]+", res)
        for x in brs :
            result.append(x[7:])

    result.append('master')
    result.append('develop')

    return result
Exemple #4
0
def clone(project) :
    with path.cd( config['projects'][project]['repo_path'] ) :
        out = process.get_output([ "git", "clone", config[ 'projects' ][ project ][ 'repo' ], "." ])
        logger.write( out )