Пример #1
0
def mysql_fullbackup(host,user,password,user_os,password_os,mysql_path,bakdir):
    # 上传脚本
    # 删除旧的备份脚本
    date = datetime.datetime.now().strftime('%Y%m%d%H')
    bak_file = bakdir + '/dbfullbak_%s.sql.gz' %date
    mysqldump = '%s/bin/mysqldump -u%s -p%s -S %s/run/mysql.sock -A -R -x --default-character-set=utf8' %(mysql_path,user,password,mysql_path)

    cmd = mysqldump + ' |gzip > ' + bak_file

    tools.exec_command(host,user_os,password_os,cmd)
Пример #2
0
def get_stats(**kwargs):
    try:
        oldest_commit       = exec_command("git log --pretty=oneline --reverse --format='%ct' | head -1")
        days_project        = int(time.time()-float(oldest_commit.pop(0)))/60/60/24;
        stats               = exec_command("git shortlog -s -n --all")
        result              = []
        for x in stats:
            x = x.lstrip().split("\t")
            x.append("{0:.2f}".format(float(x[0])/days_project))
            result.append(x)

        return json.dumps(result)
    except Exception as e:
        print(e)
        return [""]
Пример #3
0
def main():
    # Init folder for issue
    if not os.path.exists(settings.issue_folder):
        os.makedirs(settings.issue_folder)

    # Get user configuration for issue creation
    try:
        settings.author_name = exec_command("git config user.name").pop()
    except:
        print ("Username unavailable. You are now : {0}".format(settings.author_name))

    try:
        settings.author_email = exec_command("git config user.email").pop()
    except:
        print ("Email unavailable. You are now : {0}".format(settings.author_email))

    print ("Git-Tracker is now listening on http://localhost:5000/ ")
    serve(ip="localhost", port=5000)
Пример #4
0
def main():
    # Get user configuration for issue creation
    try:
        settings.author_name = exec_command("git config user.name").pop()
    except:
        print ("Username unavailable. You are now : {0}".format(settings.author_name))

    try:
        settings.author_email = exec_command("git config user.email").pop()
    except:
        print ("Email unavailable. You are now : {0}".format(settings.author_email))

    count_issue = 0
    for f in sorted_ls("{0}/i*".format(settings.issue_folder)):
        try:
            issue = load_issue(settings.issue_folder,  os.path.basename(f))
            if issue["author"] == "{0} <{1}>".format(settings.author_name, settings.author_email):
                count_issue = count_issue+1
        except:
            pass

    print ("You have\033[1m {0} issue(s)\033[0m assigned to you.".format(count_issue))
Пример #5
0
def oracle_fullbackup(host, user, password, bakdir, sid, backup_retain_day,
                      arch_keep_days):
    # 上传脚本
    # 删除旧的备份脚本
    cmd = 'rm -f %s/oracle_backup_*.sh' % bakdir
    tools.exec_command(host, user, password, cmd)
    # 上传备份脚本
    local_file = os.getcwd() + '/frame/oracle_tools/oracle_backup_db.sh'
    remote_path = '%s/oracle_backup_db.sh' % bakdir
    tools.sftp_upload_file(host, user, password, remote_path, local_file)

    local_file = os.getcwd() + '/frame/oracle_tools/oracle_backup_arch.sh'
    remote_path = '%s/oracle_backup_arch.sh' % bakdir
    tools.sftp_upload_file(host, user, password, remote_path, local_file)
    # 数据库全备
    cmd = "sh %s/oracle_backup_db.sh -i %s -d %s -r %s" % (bakdir, sid, bakdir,
                                                           backup_retain_day)
    tools.exec_command(host, user, password, cmd)
    # 归档日志清理
    cmd = "sh %s/oracle_backup_arch.sh -i %s -d %s -r %s" % (
        bakdir, sid, bakdir, arch_keep_days)
    tools.exec_command(host, user, password, cmd)
Пример #6
0
def get_number_of_commits(**kwargs):
    try:
        return json.dumps(exec_command("git rev-list HEAD --count"))
    except Exception as e:
        return [""]
Пример #7
0
def get_log(**kwargs):
    return json.dumps(exec_command("git log --pretty=format:'%h;%an;%ae;%ar;%s' -50"))
Пример #8
0
def get_branch(**kwargs):
    return json.dumps(exec_command("git branch -a"))
Пример #9
0
def get_author(**kwargs):
    return json.dumps(exec_command("git log --all --format='%aN <%cE>' | sort -u"))