Exemplo n.º 1
0
def check_space_available(path):
    Utility.create_folder(path)
    free, used, total = Utility.get_disk_usage(path)
    ConsolePrint.info("free:%s" % free)
    ConsolePrint.info("used:%s" % used)
    ConsolePrint.info("total:%s" % total)
    if free < 200:
        JobFunc.RaiseException(MemoryError, "Insufficient disk space.")
Exemplo n.º 2
0
def remove_oldest_version():
    while True:
        free, used, total = Utility.get_disk_usage(SOURCE_CODE_PATH)
        print "free:%s" % free
        print "used:%s" % used
        print "total:%s" % total
        if free < 300:
            f_list = os.listdir(SOURCE_CODE_PATH)
            f_list.sort()
            oldest_folder = f_list[0]
            oldest_folder_path = os.path.join(SOURCE_CODE_PATH, oldest_folder)
            print 'I find %s is the oldest.' % oldest_folder
            print f_list
            print 'I will remove \"%s\"' % oldest_folder_path
            shutil.rmtree(oldest_folder_path)

        else:
            print 'Space is enough.'
            break
Exemplo n.º 3
0
def run(*args, **kwargs):
    JobFunc.SendJobStartMail()
    Utility.print_info(__file__, args, kwargs)
    workspace_path = Utility.get_compiler_path()
    Utility.create_folder(workspace_path)
    free, used, total = Utility.get_disk_usage(workspace_path)
    print "free:%s" % free
    print "used:%s" % used
    print "total:%s" % total
    if free < 200:
        JobFunc.RaiseException(MemoryError, "Insufficient disk space.")

    os.chdir(workspace_path)
    repo_init_command = Utility.Repo.init(
        url='ssh://[email protected]:29418/manifest',
        branch='C2_8.1_master')
    repo_init_exit_code = Utility.execute_command(repo_init_command)
    if repo_init_exit_code != 0:
        JobFunc.RaiseException(IOError, "Repo init error")

    repo_sync_command = Utility.Repo.sync()
    repo_sync_exit_code = Utility.execute_command(repo_sync_command)
    if repo_sync_exit_code != 0:
        JobFunc.RaiseException(IOError, "Repo sync error")