Exemple #1
0
                  default=False)
parser.add_option('-n',
                  action='store_true',
                  dest='use_ndfd_cache',
                  default=False)
parser.add_option('-v', action='store_true', dest='verbose', default=False)
parser.add_option('-z', action='store_true', dest='debug', default=False)

options, args = parser.parse_args()

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

debug = options.debug
use_dev_paths = options.use_dev_paths
use_ndfd_cache = options.use_ndfd_cache
verbose = options.verbose or debug

factory = NDFDProjectFactory()
if use_dev_paths: factory.config.dirpaths.update(factory.config.dev_dirpaths)
if use_ndfd_cache: factory.setServerUrl(factory.ndfd_config.cache_server)

target_date, filepaths = factory.downloadLatestForecast(True)
if verbose:
    print 'NDFD grib files downloaded for %s :', str(target_date)
    for filepath in filepaths:
        print '    ', filepath

elapsed_time = elapsedTime(DOWNLOAD_START_TIME, True)
fmt = 'completed download for %s in %s'
print fmt % (target_date.isoformat(), elapsed_time)
    ]

if ',' in options.periods:
    periods = options.periods.split(',')
else:
    periods = [
        options.periods,
    ]

verbose = options.verbose or debug

latest_time = datetime.datetime.utcnow()
target_year = latest_time.year

factory = NDFDProjectFactory()
target_date, filepaths = \
    factory.downloadLatestForecast(filetypes=filetypes, periods=periods,
                                   region=options.region, verbose=verbose)

elapsed_time = elapsedTime(UPDATE_START_TIME, True)
fmt = 'completed download for %s in %s'
print fmt % (target_date.isoformat(), elapsed_time)

transport_dirpath = '/Volumes/Transport/data/app_data'
if os.path.exists(transport_dirpath):
    ndfd_dirpath = os.path.split(filepaths[0])[0]
    dest_dirpath = os.path.join(transport_dirpath, 'shared/forecast/ndfd')
    command = '/usr/bin/rsync -cgloprtuD %s %s' % (ndfd_dirpath, dest_dirpath)
    print command
    os.system(command)
if ',' in options.periods:
    periods = options.periods.split(',')
else:
    periods = [
        options.periods,
    ]

latest_time = datetime.datetime.utcnow()
target_year = latest_time.year

factory = NDFDProjectFactory()
factory.setDownloadAttempts(attempts)
factory.setDownloadWaitTime(wait_time)

target_date, filepaths, failed = \
    factory.downloadLatestForecast(filetypes=filetypes, periods=periods,
                                   debug=debug)

elapsed_time = elapsedTime(UPDATE_START_TIME, True)
fmt = '\ncompleted download for %s in %s'
print fmt % (target_date.isoformat(), elapsed_time)
if len(filepaths) > 0:
    print 'successfully downloaded :'
    for path in filepaths:
        print '    ', path
if len(failed) > 0:
    print '\ndownload failed after %d attempts for :' % factory.wait_attempts
    for info in failed:
        print '    %s (%s) @ %s' % info

transport_dirpath = '/Volumes/Transport/data/app_data'
if os.path.exists(transport_dirpath):