Пример #1
0
                    choices=('notset', 'debug', 'info', 'warning', 'error',
                             'critical'))
args = parser.parse_args()

handlers = []
handlers.append(log.StreamHandler())
if args.log is not None:
    handlers.append(log.FileHandler(args.log, 'w'))
log.basicConfig(
    format='%(asctime)s %(levelname)s %(filename)s:%(lineno)s %(message)s',
    level=getattr(log, args.level.upper()),
    handlers=handlers)

path = lambda x: os.path.abspath(os.path.join(args.folder, x))
home = path('')
config = ConfigUtil.load_config(path('config.json'))

log.info('Running network generation tool.')
log.info(f'Loading run data from {home}.')

population = Network()

if not population.ready(config['network']):
    log.error(
        'Dependent data not parsed or generated; see warnings for details.')
    exit(1)
elif population.complete(home):
    log.warning(
        'Network already generated. Would you like to replace it? [Y/n]')
    if input().lower() not in ('y', 'yes', 'yeet'):
        log.info(
Пример #2
0
def main():
    parser = ArgumentParser('daymet air temperature parser')

    parser.add_argument('--dir',
                        type=str,
                        dest='dir',
                        default='.',
                        help='path to directory containing Icarus run data')
    parser.add_argument(
        '--log',
        type=str,
        dest='log',
        default=None,
        help='path to file to save the process log; not saved by default')
    parser.add_argument('--level',
                        type=str,
                        dest='level',
                        default='info',
                        choices=('notset', 'debug', 'info', 'warning', 'error',
                                 'critical'),
                        help='verbosity of the process log')

    args = parser.parse_args()

    handlers = []
    handlers.append(log.StreamHandler())
    if args.log is not None:
        handlers.append(log.FileHandler(args.log, 'w'))
    log.basicConfig(
        format='%(asctime)s %(levelname)s %(filename)s:%(lineno)s %(message)s',
        level=getattr(log, args.level.upper()),
        handlers=handlers)

    path = lambda x: os.path.abspath(os.path.join(args.dir, x))
    home = path('')

    config = ConfigUtil.load_config(path('config.json'))
    database = SqliteUtil(path('database.db'))

    tmin_files = config['network']['exposure']['tmin_files']
    tmax_files = config['network']['exposure']['tmax_files']
    day = config['network']['exposure']['day']
    steps = config['network']['exposure']['steps']

    log.info('Running roads parsing tool.')
    log.info(f'Loading run data from {home}.')

    if not ready(database, tmin_files, tmax_files):
        log.error('Process dependencies not met; see warnings and '
                  'docuemntation for more details.')
        exit(1)
    if complete(database):
        log.info('All or some of this process is already complete. '
                 ' Would you like to proceed? [Y/n]')
        valid = ('y', 'n', 'yes', 'no', 'yee', 'naw')
        response = input().lower()
        while response not in valid:
            print('Try again; would you like to proceed? [Y/n]')
            response = input().lower()
        if response in ('n', 'no', 'naw'):
            log.info('User chose to terminate process.')
            exit()

    try:
        log.info('Starting road parsing.')
        parse_temperatures(database, tmin_files, tmax_files, steps, day, 4326,
                           2223)
    except:
        log.exception('Critical error while parsing roads; '
                      'terminating process and exiting.')
        exit(1)
Пример #3
0
    def validate_config(self, configpath, specspath):
        config = ConfigUtil.load_config(configpath)
        # specs = ConfigUtil.load_specs(specspath)
        # config = ConfigUtil.verify_config(specs, config)

        return config
Пример #4
0
def main():
    parser = ArgumentParser()
    main = parser.add_argument_group('main')
    main.add_argument('file',
                      type=str,
                      help='file path to save the exported routes to')
    main.add_argument(
        '--modes',
        type=str,
        nargs='+',
        dest='modes',
        help='list of modes to export routes for; defualt is all modes',
        default=('walk', 'pt', 'car', 'bike'),
        choices=('walk', 'pt', 'car', 'bike'))
    main.add_argument('--skip-empty',
                      dest='skip',
                      action='store_true',
                      default=False,
                      help='skip all legs that do not have routes')
    main.add_argument('--epsg',
                      dest='epsg',
                      type=int,
                      default=2223,
                      help='epsg system to convert routes to; default is 2223')

    common = parser.add_argument_group('common')
    common.add_argument(
        '--folder',
        type=str,
        dest='folder',
        default='.',
        help='file path to the directory containing Icarus run data'
        '; default is the working directory')
    common.add_argument(
        '--log',
        type=str,
        dest='log',
        default=None,
        help=
        'file path to save the process log; by default the log is not saved')
    common.add_argument(
        '--level',
        type=str,
        dest='level',
        default='info',
        help='verbosity level of the process log; default is "info"',
        choices=('notset', 'debug', 'info', 'warning', 'error', 'critical'))
    common.add_argument(
        '--replace',
        dest='replace',
        action='store_true',
        default=False,
        help='automatically replace existing data; do not prompt the user')
    args = parser.parse_args()

    handlers = []
    handlers.append(log.StreamHandler())
    if args.log is not None:
        handlers.append(log.FileHandler(args.log, 'w'))
    log.basicConfig(
        format='%(asctime)s %(levelname)s %(filename)s:%(lineno)s %(message)s',
        level=getattr(log, args.level.upper()),
        handlers=handlers)

    path = lambda x: os.path.abspath(os.path.join(args.folder, x))
    home = path('')

    log.info('Running route export tool.')
    log.info(f'Loading run data from {home}.')

    database = SqliteUtil(path('database.db'), readonly=True)
    config = ConfigUtil.load_config(path('config.json'))

    try:
        export_routes(database, args.modes, args.file, args.skip, args.epsg)
    except:
        log.exception('Critical error while exporting routes:')
        exit(1)

    database.close()