Esempio n. 1
0
def end_log(cl_args_list=sys.argv,
            log='sconstruct.log',
            excluded_dirs=[],
            release_dir='./release/'):
    '''Complete the log of a build process.'''
    if misc.is_scons_dry_run(cl_args_list=cl_args_list):
        return None

    end_message = "*** Build completed: {%s} ***\n \n \n" % misc.current_time()
    with open(log, "a") as f:
        f.write(end_message)

    # scan sconstruct.log for start time
    with open(log, "rU") as f:
        s = f.readline()
        s = s[s.find('{') + 1:s.find('}')]
        start_time = datetime.strptime(s, "%Y-%m-%d %H:%M:%S")

    # gather all sconscript logs
    parent_dir = os.getcwd()
    builder_logs = collect_builder_logs(parent_dir,
                                        excluded_dirs=excluded_dirs)

    # keep only builder logs from this run OR is broken (value == beginning_of_time)
    beginning_of_time = datetime.min  # to catch broken logs (see collect_builder_logs)
    this_run_dict = {
        key: value
        for key, value in builder_logs.items()
        if (value > start_time) or value == beginning_of_time
    }
    this_run_list = sorted(this_run_dict, key=this_run_dict.get, reverse=True)

    with open(log, "a") as sconstruct:
        for f in this_run_list:
            with open(f, 'rU') as sconscript:
                if this_run_dict[f] == beginning_of_time:
                    warning_string = "*** Warning!!! The log below does not have timestamps," + \
                                     " the Sconscript may not have finished.\n"
                    sconstruct.write(warning_string)
                sconstruct.write(f + '\n')
                sconstruct.write(sconscript.read())

    # move top level logs to /release/ directory.
    if not os.path.exists(release_dir):
        os.makedirs(release_dir)
    for file in glob.glob("*.log"):
        shutil.move('./' + file, release_dir + file)
    return None
Esempio n. 2
0
def start_log(mode, cl_args_list=sys.argv, log='sconstruct.log'):
    '''Begins logging a build process'''

    if not (mode in ['develop', 'cache']):
        raise Exception("Error: %s is not a defined mode" % mode)
    elif misc.is_scons_dry_run(cl_args_list=cl_args_list):
        return None

    start_message = "*** New build: {%s} ***\n" % misc.current_time()
    with open(log, "w") as f:
        f.write(start_message)

    if misc.is_unix():
        sys.stdout = os.popen('tee -a %s' % log, 'w')
    elif sys.platform == 'win32':
        sys.stdout = open(log, 'a')

    sys.stderr = sys.stdout

    return None
Esempio n. 3
0
def scons_debrief(args, cl_args_list=sys.argv):
    '''
    Execute functions after SCons has built all targets.
    Current list of functions: 
        1. print state_of_repo
        2. issue size_warnings
    '''
    # Don't run on SCons dry run
    if misc.is_scons_dry_run(cl_args_list=cl_args_list):
        return None
    # Log the state of the repo
    state_of_repo(args['MAXIT'], args['log'])

    # Issue size warnings
    issue_size_warnings(args['look_in'].split(";"),
                        float(args['file_MB_limit_lfs']),
                        float(args['total_MB_limit_lfs']),
                        float(args['file_MB_limit']),
                        float(args['total_MB_limit']), args['lfs_required'],
                        args['git_attrib_path'])

    return None