def quit(conf_file):
    config = SafeConfigParser()
    pwb_add_config_section(config, 'ENV')
    config.set('ENV', 'wim_path', "")
    with open(conf_file, "w+") as configfile:
        config.write(configfile, space_around_delimiters=False)
    sys.exit()
Пример #2
0
def submit(btn):
    wb_dir = os.path.abspath(os.path.join(tmp_dir, '../../'))
    pwb_add_config_section(config, 'ENV')
    config.set('ENV', 'wb_dir', wb_dir)
    config.set('ENV', 'quit', "")

    pwb_add_config_section(config, 'SYSTEM')
    sys_name = app.getEntry("sys_name")
    config.set('SYSTEM', 'sys_name', sys_name)

    pwb_add_config_section(config, 'DATABASE')
    db_name = app.getEntry("db_name")
    config.set('DATABASE', 'db_name', db_name)
    db_schema = app.getEntry("db_schema")
    config.set('DATABASE', 'db_schema', db_schema)

    dir_paths = app.getAllListItems("Directories")
    i = 1
    paths = {}
    for path in dir_paths:
        paths["dir" + str(i)] = path
        i += 1
    pwb_add_config_section(config, 'DOCUMENTS')
    for key in paths.keys():
        config.set('DOCUMENTS', key, paths[key])

    with open(conf_file, "w+") as configfile:
        config.write(configfile, space_around_delimiters=False)

    # Clear log file:
    open(tmp_dir + "/PWB.log", 'w').close()

    app.stop()
        db_args = "ok"
    elif doc_args:
        subsystem_path = str(
            unique_dir(basepath + sys_name + '/content/sub_systems/' +
                       sys_name))

    if db_args or doc_args:
        pathlib.Path(basepath + sys_name + '/administrative_metadata/').mkdir(
            parents=True, exist_ok=True)
        pathlib.Path(basepath + sys_name + '/descriptive_metadata/').mkdir(
            parents=True, exist_ok=True)
        pathlib.Path(basepath + sys_name + '/content/documentation/').mkdir(
            parents=True, exist_ok=True)
        pathlib.Path(subsystem_path + '/header/').mkdir(parents=True,
                                                        exist_ok=True)
        pathlib.Path(subsystem_path + '/content/documents/').mkdir(
            parents=True, exist_ok=True)
        pathlib.Path(subsystem_path + '/documentation/dip/').mkdir(
            parents=True, exist_ok=True)

        subsys_name = subsystem_path.split('/')[-1]
        config.set('SYSTEM', 'subsys_name', subsys_name)
    else:
        pwb_message("'Illegal or missing values in user input'", "error")
else:
    pwb_message("'Illegal or missing values in user input'", "error")

pwb_add_config_section(config, 'DATABASE')
config.set('DATABASE', 'db_args', db_args)
with open(conf_file, "w+") as configfile:
    config.write(configfile, space_around_delimiters=False)
Пример #4
0
                               'normalized_relative_path'] = norm_rel_path

            df.to_csv(header_file, index=False, sep="\t")

    # TODO: Fix at ved ny kjøring så blir en informert om "all successfully" selv om feil ved forrige? (er logget riktig i kolonne 'failed)
    if len(conversion_failed) > 0:
        print("\n")
        print("*** Files not converted (conversion failed) ***")
        print(*conversion_failed, sep="\n")
        print("\n")

    if len(conversion_not_supported) > 0:
        print("\n")
        print("*** Files not converted (conversion not supported) ***")
        print(*conversion_not_supported, sep="\n")
        print("\n")

    not_converted = len(conversion_failed) + len(conversion_not_supported)
    if not_converted > 0:
        pwb_add_config_section(config, 'ENV')
        config.set('ENV', 'wim_path', "")
        with open(conf_file, "w+") as configfile:
            config.write(configfile, space_around_delimiters=False)
        print(
            '*** Verify or fix manually any non-converted files and re-run process *** \n'
        )
    else:
        print('*** All files converted successfully. *** \n')
        # TODO: Legg inn auto sletting + renaming av mapper etter at kode for kopiering av org for visse formater på plass
        # shutil.rmtree(folder)