aboutsummaryrefslogtreecommitdiffstats
path: root/bin/common/srtool_update.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/common/srtool_update.py')
-rwxr-xr-xbin/common/srtool_update.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/bin/common/srtool_update.py b/bin/common/srtool_update.py
index 1ec6c0a3..92f4479d 100755
--- a/bin/common/srtool_update.py
+++ b/bin/common/srtool_update.py
@@ -27,6 +27,7 @@ import sqlite3
import json
import time
from datetime import datetime, timedelta
+import traceback
# load the srt.sqlite schema indexes
dir_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
@@ -85,7 +86,7 @@ def get_tag_key(tag,key,default=''):
# ONDEMAND = 5 "{}" # only on demand
# ONSTARTUP = 6 "{}" # on every SRTool start up
-def run_updates(force_all,name_filter,is_trial):
+def run_updates(force_all,name_filter,update_skip_history,is_trial):
conn = sqlite3.connect(srtDbName)
cur = conn.cursor()
@@ -95,7 +96,7 @@ def run_updates(force_all,name_filter,is_trial):
if verbose:
print("SRTool Update: time_now = %s" % time_now.strftime(ORM.DATASOURCE_DATETIME_FORMAT))
status_str = "============================================================\n"
- status_str += "Update: Date=%s,Filter='%s',Force=%s\n" % (time_now.strftime(ORM.DATASOURCE_DATETIME_FORMAT),name_filter,force_all)
+ status_str += "Update: Date=%s,Filter='%s',Force=%s,Skip_History=%s\n" % (time_now.strftime(ORM.DATASOURCE_DATETIME_FORMAT),name_filter,force_all,update_skip_history)
#get sources that have update command
sources = cur.execute("SELECT * FROM orm_datasource").fetchall()
@@ -198,6 +199,8 @@ def run_updates(force_all,name_filter,is_trial):
update_command = source[ORM.DATASOURCE_UPDATE]
if force_all:
update_command += " --force"
+ if update_skip_history:
+ update_command += " --update-skip-history"
if update_command.startswith('./'):
update_command = os.path.join(script_pathname, update_command)
os.system("echo 'Update:%s,%s' > %s" % (datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT),update_command,os.path.join(script_pathname,SRT_UPDATE_TASK_FILE)))
@@ -235,7 +238,7 @@ def list():
cur = conn.cursor()
cur_write = conn.cursor()
- format_str = "%16s %7s %14s %10s %28s %s"
+ format_str = "%16s %7s %14s %10s %28s '%s'"
print("SRTool Update List:")
print(format_str % ('Data','Source','Name','Frequency','Offset','Description'))
@@ -251,7 +254,7 @@ def list():
if verbose:
print('')
- run_updates(False,'all',True)
+ run_updates(False,'all',True,True)
#################################
# Start 'cron' job for updates
@@ -274,7 +277,7 @@ def cron_start():
extra_line = False
while True:
# Run the updates
- run_updates(False,'all',False)
+ run_updates(False,'all',False,False)
# Toggle an extra line in the log to make updates obvious
if extra_line:
extra_line = False
@@ -318,6 +321,7 @@ def main(argv):
parser.add_argument('--name-filter', '-n', dest='name_filter', help='Filter for datasource name')
parser.add_argument('--force', '-f', action='store_true', dest='force', help='Force the update')
+ parser.add_argument('--update-skip-history', '-H', action='store_true', dest='update_skip_history', help='Skip history updates')
parser.add_argument('--verbose', '-v', action='store_true', dest='verbose', help='Debugging: verbose output')
parser.add_argument('--trial', '-t', action='store_true', dest='is_trial', help='Debugging: trial run')
@@ -337,12 +341,13 @@ def main(argv):
elif 'run-updates' == args.command:
try:
print("BEGINNING UPDATING DATASOURCES... this MAY take a long time")
- run_updates(args.force,name_filter,args.is_trial)
+ run_updates(args.force,name_filter,args.update_skip_history,args.is_trial)
master_log.write("SRTOOL:%s:UPDATING DATASOURCES:\t\t\t...\t\t\tSUCCESS\n" %(datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT)))
print("FINISHED UPDATING ALL DATASOURCES\n")
except Exception as e:
print("FAILED UPDATING ALL DATASOURCES (%s)" % e)
master_log.write("SRTOOL:%s:UPDATING DATASOURCES\t\t\t...\t\t\tFAILED ... %s\n" % (datetime.now().strftime(ORM.DATASOURCE_DATETIME_FORMAT), e))
+ traceback.print_exc(file=sys.stdout)
elif args.configure_ds_update:
try:
print("CHANGING UPDATE CONFIGURATION FOR %s" % args.configure_ds_update[0])