count = 1 while True: if not os.path.isfile( "{base}/data/old_namelists/namelist_bu_{count}.py".format( base=sys.argv[1], count=count)): log.info("Backing up old namelist to {base}/data/old_namelists/namelist_bu" \ "_{count}.py".format(base = sys.argv[1], count = count), keep_log) shutil.copyfile( "{base}/namelist.py".format(base=sys.argv[1]), "{base}/data/old_namelists/namelist_bu_{count}.py".format( base=sys.argv[1], count=count)) break count += 1 else: log.initialise(keep_log) directory_folders = list_folders(sys.argv[1]) model_directories = [] for model_directory in directory_folders: if os.path.isfile("{base}/{fn}/{fn}.qgs".format(base=sys.argv[1], fn=model_directory)): model_directories.append(model_directory) if len(model_directories) == 0: print("\t! there is no model found in this directory.") log.error("no Model was found in the directory working directory", keep_log) sys.exit(1) elif len(model_directories) == 1:
list_files, copy_file, copytree, file_name, python_variable, get_extents) from projection_lookup import epsg_lookup_dictionary from qgs_project_template import template from sqlite_tools import sqlite_connection from logger import log log = log("{base}/swatplus_aw_log.txt".format(base=sys.argv[1])) keep_log = True # check if there is need to prepare project if os.path.isfile("{base}/config.py".format(base=sys.argv[1])): import config if config.Keep_Log == True: keep_log = True log.initialise() else: keep_log = False if config.Model_2_config == True: log.info( "config creation is required; 'Model_2_config' is set to 'True'", keep_log) sys.exit(0) else: log.initialise() log.info("config was not found in the current directory", keep_log) print("\t! config.py not found in current directory") sys.exit(0)