Skip to content
Snippets Groups Projects
Commit fa61f607 authored by Edileuton Henrique de Oliveira's avatar Edileuton Henrique de Oliveira
Browse files

Add elapsedtime function that verifies if have passed 24 hours since the last sucessful execution

parent a1eda6e8
No related branches found
No related tags found
1 merge request!4Elapsed Time
...@@ -25,7 +25,7 @@ import _winreg ...@@ -25,7 +25,7 @@ import _winreg
import shutil import shutil
import subprocess import subprocess
import urllib import urllib
from time import localtime, strftime from time import localtime, strftime, time
from xml.etree.ElementTree import tostring from xml.etree.ElementTree import tostring
import collect import collect
import glob import glob
...@@ -37,6 +37,7 @@ import glob ...@@ -37,6 +37,7 @@ import glob
PROINFODATAPATH = os.environ["ProgramFiles"] + "\\ProInfoData" PROINFODATAPATH = os.environ["ProgramFiles"] + "\\ProInfoData"
PREVIOUSPATH = PROINFODATAPATH + "\\data\\previous" PREVIOUSPATH = PROINFODATAPATH + "\\data\\previous"
URL = "http://200.17.202.187/tomcat/axis/Seed2.jws" URL = "http://200.17.202.187/tomcat/axis/Seed2.jws"
LASTEXEC = PROINFODATAPATH + "\\data\\lastexec.txt"
# Log lifetime in days # Log lifetime in days
LOGLIFETIME = 30 LOGLIFETIME = 30
...@@ -189,6 +190,19 @@ def callUpdater(): ...@@ -189,6 +190,19 @@ def callUpdater():
# Wait to be killed # Wait to be killed
out = proc.communicate() out = proc.communicate()
# Check if have passed 24 hours since the last sucessful execution
def elapsedTime():
if not os.path.exists(LASTEXEC):
return True
lastexec = file(LASTEXEC , "r").read()
# 86400 seconds = 24 hours
if time() - float(lastexec) > 86400:
return True
else:
return False
# ========================================== # ==========================================
# Main program # Main program
# ========================================== # ==========================================
...@@ -271,6 +285,13 @@ if(updatelink): ...@@ -271,6 +285,13 @@ if(updatelink):
else: else:
log.write("UPDATE: No updates are available.") log.write("UPDATE: No updates are available.")
# Check if have passed 24 hours since the last sucessful execution
if not elapsedTime():
# If everything ran ok, exit with success status
log.write("EXIT(0): Success, not elapsed time.")
log.close()
sys.exit(0)
# Collect data # Collect data
try: try:
collectData = collect.collect() collectData = collect.collect()
...@@ -329,6 +350,11 @@ if os.path.isdir(PREVIOUSPATH): ...@@ -329,6 +350,11 @@ if os.path.isdir(PREVIOUSPATH):
log.close() log.close()
sys.exit(14) sys.exit(14)
# Record the last sucess execution
lastExecFile = file(LASTEXEC , "w")
lastExecFile.write(str(time()))
lastExecFile.close()
# If everything ran ok, exit with success status # If everything ran ok, exit with success status
log.write("EXIT(0): Success.") log.write("EXIT(0): Success.")
log.close() log.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment