|
@@ -85,31 +85,23 @@ def fetchDataADEI():
|
|
|
curtime = int(time.time())
|
|
|
time_range = str((curtime-3600)) + "-" + str(curtime)
|
|
|
for param in varname:
|
|
|
- #print param
|
|
|
dest = config['server'] + config['script']
|
|
|
url = dest + "?" + varname[param] + "&window=" + time_range
|
|
|
- #print url
|
|
|
data = requests.get(url,
|
|
|
auth=(config['username'],
|
|
|
config['password'])).content
|
|
|
- #tmp_data = data.content
|
|
|
- #print "CHECK THIS"
|
|
|
- #print data
|
|
|
-
|
|
|
last_value = data.split(",")[-1].strip()
|
|
|
- try:
|
|
|
+ try:
|
|
|
#print last_value
|
|
|
test_x = float(last_value)
|
|
|
except ValueError:
|
|
|
last_value = ""
|
|
|
- #print last_value
|
|
|
cache_data[param] = last_value
|
|
|
#current_timestamp = strftime("%Y-%m-%d %H:%M:%S", gmtime())
|
|
|
current_timestamp = strftime("%Y-%m-%d %H:%M:%S")
|
|
|
cache_data['time'] = current_timestamp
|
|
|
time_pattern = "%Y-%m-%d %H:%M:%S"
|
|
|
epoch_cur = int(time.mktime(time.strptime(current_timestamp, time_pattern)))
|
|
|
- #print("current: ", epoch_cur)
|
|
|
|
|
|
|
|
|
with open("cache.yaml",'r') as stream_cache:
|
|
@@ -119,8 +111,10 @@ def fetchDataADEI():
|
|
|
time_prev = cache_content.get('time')
|
|
|
#time_pattern = "%Y-%m-%d %H:%M:%S"
|
|
|
epoch_prev = int(time.mktime(time.strptime(time_prev, time_pattern)))
|
|
|
+ print("current:", epoch_cur)
|
|
|
print("previous:", epoch_prev)
|
|
|
|
|
|
+ """
|
|
|
if epoch_cur == epoch_prev:
|
|
|
server = smtplib.SMTP('smtp.gmail.com', 587)
|
|
|
server.starttls()
|
|
@@ -128,7 +122,7 @@ def fetchDataADEI():
|
|
|
msg = "Katrin is running!"
|
|
|
server.sendmail("server.bora@gmail.com", "chanhoonseng3101@gmail.com", msg)
|
|
|
server.quit()
|
|
|
-
|
|
|
+ """
|
|
|
|
|
|
with open(".tmp.yaml", 'w') as stream_tmp:
|
|
|
stream_tmp.write(yaml.dump(cache_data, default_flow_style=False))
|