Example #1
0
def main(iargs=None):
    """ email mintpy or insarmaps results """

    inps = putils.cmd_line_parse(iargs, script='email_results')

    email_address = os.getenv('NOTIFICATIONEMAIL')

    if not iargs is None:
        message_rsmas.log(
            inps.work_dir,
            os.path.basename(__file__) + ' ' + ' '.join(iargs[:]))
    else:
        message_rsmas.log(
            inps.work_dir,
            os.path.basename(__file__) + ' ' + ' '.join(sys.argv[1::]))

    if inps.email_insarmaps_flag:
        email_insarmaps_results(email_address)

        if int(inps.template['cleanopt']) == 4:
            cleanlist = pathObj.isce_clean_list
            putils.remove_directories(cleanlist[4])

        return

    if inps.email_mintpy_flag:
        email_mintpy_results(email_address)
        return

    return None
Example #2
0
def check_directories_and_inputs(inputs):

    inps = inputs

    # invalid input of custom template
    if inps.custom_template_file:
        if not os.path.isfile(inps.custom_template_file):
            raise FileNotFoundError(inps.custom_template_file)

    if inps.remove_project_dir:
        putils.remove_directories(directories_to_delete=[inps.work_dir])

    if not os.path.isdir(inps.work_dir):
        os.makedirs(inps.work_dir)

    os.chdir(inps.work_dir)

    inps.slc_dir = os.path.join(inps.work_dir, 'SLC')
    if not os.path.isdir(inps.slc_dir):
        os.makedirs(inps.slc_dir)

    # check input --start/end/step
    for key in ['start_step', 'end_step', 'step']:
        value = vars(inps)[key]
        if value and value not in step_list:
            msg = 'Input step not found: {}'.format(value)
            msg += '\nAvailable steps: {}'.format(step_list)
            raise ValueError(msg)

    # ignore --start/end input if --step is specified
    if inps.step:
        inps.start_step = inps.step
        inps.end_step = inps.step

    # get list of steps to run
    idx0 = step_list.index(inps.start_step)
    idx1 = step_list.index(inps.end_step)

    if idx0 > idx1:
        msg = 'input start step "{}" is AFTER input end step "{}"'.format(
            inps.start_step, inps.end_step)
        raise ValueError(msg)
    inps.runSteps = step_list[idx0:idx1 + 1]

    print('Run routine processing with {} on steps: {}'.format(
        os.path.basename(__file__), inps.runSteps))
    if len(inps.runSteps) == 1:
        print('Remaining steps: {}'.format(step_list[idx0 + 1:]))

    print('-' * 50)

    return inps