Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
opts, args = getopt.getopt(argv[1:], "h", ['help'])
except getopt.error, msg:
print >>sys.stderr, 'Error: %s\n' % msg
print >>sys.stderr, __usage__.strip()
return 1
# process options
for o, a in opts:
if o in ('-h', '--help'):
print __usage__.strip()
return 0
# check arguments
if len(args) != 1:
print >>sys.stderr, "Error: 1 argument required"
print >>sys.stderr, __usage__.strip()
return 2
return TwitterAuth(DataStore.params(args[0]))
# convert status from bit pattern to single int
s = ''
for b in reversed(line[-1]):
s += b
line[-1] = int(s, 2)
# save result
writer.writerow(line)
reader.close()
writer.close()
# preserve file date (doesn't seem to work on Asus router)
shutil.copystat(file1, file2)
os.unlink(file1)
os.rmdir(root)
# create data summaries
print 'Generating hourly and daily summaries'
params = DataStore.params(data_dir)
raw_data = DataStore.data_store(data_dir)
calib_data = DataStore.calib_store(data_dir)
hourly_data = DataStore.hourly_store(data_dir)
daily_data = DataStore.daily_store(data_dir)
monthly_data = DataStore.monthly_store(data_dir)
Process.Process(
params, raw_data, calib_data, hourly_data, daily_data, monthly_data)
return 0
def usage():
except getopt.error, msg:
print >>sys.stderr, 'Error: %s\n' % msg
print >>sys.stderr, __usage__.strip()
return 1
# process options
for o, a in opts:
if o in ('-h', '--help'):
print __usage__.strip()
return 0
# check arguments
if len(args) != 1:
print >>sys.stderr, "Error: 1 argument required"
print >>sys.stderr, __usage__.strip()
return 2
data_dir = args[0]
params = DataStore.params(data_dir)
Localisation.SetApplicationLanguage(params)
hourly_data = DataStore.hourly_store(data_dir)
idx = hourly_data.before(datetime.max)
print 'Zambretti (current):', Zambretti(params, hourly_data[idx])
idx = utc.localize(idx).astimezone(Local)
if idx.hour < 8 or (idx.hour == 8 and idx.minute < 30):
idx -= timedelta(hours=24)
idx = idx.replace(hour=9, minute=0, second=0)
idx = hourly_data.nearest(idx.astimezone(utc).replace(tzinfo=None))
lcl = utc.localize(idx).astimezone(Local)
print 'Zambretti (at %s):' % lcl.strftime('%H:%M %Z'), Zambretti(
params, hourly_data[idx])
return 0