コード例 #1
0
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

debug = options.debug
dev_mode = options.dev_mode
grib_source = options.grib_source
is_utc_time = options.is_utc_time
region_key = options.region
source_key = options.source
verbose = options.verbose or debug

grib_var_name = args[0].upper()

num_args = len(args)
if len(args) == 1:
    local_hour = tzutils.asLocalHour(datetime.datetime.now(), 'US/Eastern')
    utc_hour = tzutils.asUtcHour(target_hour)
elif num_args > 1:
    if num_args >= 5:
        time_tuple = tuple([int(t) for t in args[1:5]])
        utc_hour = tzutils.asHourInTimezone(time_tuple, 'UTC')
        local_hour = tzutils.asLocalHour(utc_hour, 'US/Eastern')
    else:
        errmsg = 'At least 5 arguments are required when requesting a '
        errmsg += 'specific time. (variable year month day hour)'
        raise RuntimeError, errmsg
else:
    errmsg = 'No arguments passed to script. You must at least specify'
    raise RuntimeError, '%s the grib variable name.' % errmsg

if debug:
    print 'requesting ...'
コード例 #2
0
                  default='US/Eastern')

options, args = parser.parse_args()


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

debug = options.debug
dev_mode = options.dev_mode
local_timezone = options.local_timezone
periods = ('daily','average')
region_key = options.grid_region
source_key = options.grid_source
verbose = options.verbose or debug

now = tzutils.asUtcHour(datetime.datetime.now(), local_timezone)

weather_key = 'temps'

# default to current year & month 
year = now.year
month = current_month = now.month
last_day = datetime.date(year, month, lastDayOfMonth(year, month))
last_day_end = tzutils.asUtcTime(datetime.datetime.combine(last_day, datetime.time(hour=23)))

num_time_args = len(args)
if num_time_args == 0 :
    # no time args, discover them from times in the files
    start_time = None
    end_time = None
コード例 #3
0
 def asUtcHour(self, datetime_hour, local_timezone=None):
     return tzutils.asUtcHour(datetime_hour, local_timezone)