aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2019-01-31 10:06:41 -0800
committerDavid Reyna <David.Reyna@windriver.com>2019-01-31 10:06:41 -0800
commit8fbfbc37c5f7867dc420d6f4965c9294ec5390cd (patch)
treeea62c637c18b351a12ba63ce6b11a3e0c48697de
parentb54122107f9fd5b8f9b790d1ed1507071fe83ccf (diff)
downloadsrtool-8fbfbc37c5f7867dc420d6f4965c9294ec5390cd.tar.gz
srtool-8fbfbc37c5f7867dc420d6f4965c9294ec5390cd.tar.bz2
srtool-8fbfbc37c5f7867dc420d6f4965c9294ec5390cd.zip
srtool-updates: improve update reporting
Add time till next update in update verbose output. Indicate in table display when a datasource has an update policy but no update script. Signed-off-by: David Reyna <David.Reyna@windriver.com>
-rwxr-xr-xbin/common/srtool_update.py28
-rw-r--r--lib/srtgui/tables.py11
2 files changed, 26 insertions, 13 deletions
diff --git a/bin/common/srtool_update.py b/bin/common/srtool_update.py
index 131918ca..ec8554ea 100755
--- a/bin/common/srtool_update.py
+++ b/bin/common/srtool_update.py
@@ -91,8 +91,9 @@ def run_updates(force_all,name_filter,is_trial):
cur_write = conn.cursor()
time_now = datetime.now() #datetime.now(pytz.utc)
- print("SRTool Update: time_now = %s" % time_now.strftime(ORM.DATASOURCE_DATETIME_FORMAT))
- status_str = "====================\n"
+ 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)
#get sources that have update command
@@ -172,16 +173,24 @@ def run_updates(force_all,name_filter,is_trial):
# Not yet?
if testdate > time_now:
- status_str += " Skip '%s': update time not reached (%s)\n" % (source[ORM.DATASOURCE_DESCRIPTION],testdate.strftime(ORM.DATASOURCE_DATETIME_FORMAT))
+ time_to_go = testdate - time_now
+ frequency_str = ORM.get_orm_string(source[ORM.DATASOURCE_UPDATE_FREQUENCY],ORM.DATASOURCE_FREQUENCY_STR)
+ status_str += " Skip (next=%s in days=%2s minutes=%4s,%7s):%s\n" % (testdate.strftime(ORM.DATASOURCE_DATETIME_FORMAT),time_to_go.days,time_to_go.seconds//60,frequency_str,source[ORM.DATASOURCE_DESCRIPTION])
continue
else:
- status_str += " UPDATE '%s': update time reached (%s)\n" % (source[ORM.DATASOURCE_DESCRIPTION],testdate.strftime(ORM.DATASOURCE_DATETIME_FORMAT))
+ status_str += " UPDATE '%s': Time reached (%s)\n" % (source[ORM.DATASOURCE_DESCRIPTION],testdate.strftime(ORM.DATASOURCE_DATETIME_FORMAT))
# Execute the update
if is_trial:
print("TRIAL: Update required\t...\texecuting '%s'" % (source[ORM.DATASOURCE_UPDATE]))
status_str += " > TRIAL: execute '%s'\n" % (source[ORM.DATASOURCE_UPDATE])
else:
+ # First update the datasource's last_updated_date so avoid dual triggers
+ # (e.g. a manual test run on top of an automatic run)
+ sql = "UPDATE orm_datasource SET lastUpdatedDate=? WHERE id=?"
+ cur_write.execute(sql, (time_now.strftime(ORM.DATASOURCE_DATETIME_FORMAT),source[ORM.DATASOURCE_ID],) )
+ conn.commit()
+
print("Update required\t...\texecuting '%s'" % (source[ORM.DATASOURCE_UPDATE]))
status_str += " > EXECUTE: execute '%s'\n" % (source[ORM.DATASOURCE_UPDATE])
master_write("SRTOOL_UPDATE:%s:%s:%s\n" %(time_now.strftime(ORM.DATASOURCE_DATETIME_FORMAT),source[ORM.DATASOURCE_DESCRIPTION],source[ORM.DATASOURCE_UPDATE]))
@@ -190,10 +199,6 @@ def run_updates(force_all,name_filter,is_trial):
update_command += " --force"
os.system(os.path.join(script_pathname, update_command))
- # Reset datasource's last_updated_date
- sql = "UPDATE orm_datasource SET lastUpdatedDate=? WHERE id=?"
- cur_write.execute(sql, (time_now.strftime(ORM.DATASOURCE_DATETIME_FORMAT),source[ORM.DATASOURCE_ID],) )
- conn.commit()
conn.close()
# Status summary
@@ -213,7 +218,6 @@ def configure_ds_update(datasource_description, frequency, time):
conn.commit()
conn.close()
-
#################################
# List update data sources
#
@@ -236,8 +240,10 @@ def list():
continue
frequency_str = ORM.get_orm_string(source[ORM.DATASOURCE_UPDATE_FREQUENCY],ORM.DATASOURCE_FREQUENCY_STR)
print(format_str % (source[ORM.DATASOURCE_DATA],source[ORM.DATASOURCE_SOURCE],source[ORM.DATASOURCE_NAME],frequency_str,source[ORM.DATASOURCE_UPDATE_TIME],source[ORM.DATASOURCE_DESCRIPTION]))
- if verbose:
- print(format_str % ('',source[ORM.DATASOURCE_LASTMODIFIEDDATE],source[ORM.DATASOURCE_LASTUPDATEDDATE],'','',''))
+
+ if verbose:
+ print('')
+ run_updates(False,'all',True)
#################################
# Start 'cron' job for updates
diff --git a/lib/srtgui/tables.py b/lib/srtgui/tables.py
index 7cbce339..3268e68f 100644
--- a/lib/srtgui/tables.py
+++ b/lib/srtgui/tables.py
@@ -1673,20 +1673,27 @@ class SourcesTable(ToasterTable):
field_name="lastModifiedDate",
)
+ updated_template = '''
+ {% if data.update %}{{data.lastUpdatedDate}}{% else %}---{% endif %}
+ '''
self.add_column(title="Updated",
help_text="Last update date",
hideable=True,
hidden=True,
#orderable=True,
- field_name="lastUpdatedDate",
+ static_data_name="updated",
+ static_data_template=updated_template,
)
+ frequency_template = '''
+ {% if data.update %}{{data.get_frequency_text}}{% else %}({{data.get_frequency_text}}){% endif %}
+ '''
self.add_column(title="Update Freq.",
hideable=False,
orderable=True,
field_name="update_frequency",
static_data_name="update_frequency",
- static_data_template="{{data.get_frequency_text}}",
+ static_data_template=frequency_template,
)
self.add_column(title="Update Detail",