aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2019-01-14 20:37:36 -0800
committerDavid Reyna <David.Reyna@windriver.com>2019-01-14 20:37:36 -0800
commit454d96154afef5aae809fbd24c0b70ec7f6371a9 (patch)
treeb695aedfdf16bba806e2d0871601aaef9364f397
parent95401a2a57f12ee3f463df230e0b89e3e3c85a8e (diff)
downloadsrtool-454d96154afef5aae809fbd24c0b70ec7f6371a9.tar.gz
srtool-454d96154afef5aae809fbd24c0b70ec7f6371a9.tar.bz2
srtool-454d96154afef5aae809fbd24c0b70ec7f6371a9.zip
srtool: auto-update support cleanup
Add backgroup data source updates cleanup * Add robust method for scanning ORM string lists * Fix DATASOURCE_FREQUENCY_STR ORM string list * Adjust '--list' columns [YOCTO #13131] Signed-off-by: David Reyna <David.Reyna@windriver.com>
-rwxr-xr-xbin/common/srtool_common.py15
-rwxr-xr-xbin/common/srtool_update.py4
-rwxr-xr-xlib/srtmain/management/commands/update.py3
3 files changed, 17 insertions, 5 deletions
diff --git a/bin/common/srtool_common.py b/bin/common/srtool_common.py
index f7e09764..46996aec 100755
--- a/bin/common/srtool_common.py
+++ b/bin/common/srtool_common.py
@@ -497,9 +497,21 @@ def gen_schema_header():
fd.write(" %s_%s = %d\n" % ('DATASOURCE','ONDEMAND' ,5))
fd.write(" %s_%s = %d\n" % ('DATASOURCE','ONSTARTUP' ,6))
fd.write(" %s_%s = '%s'\n" % ('DATASOURCE','FREQUENCY_STR', \
- 'Minute,Hourly,Daily,Weekly,Monthly,OnDemand.OnStartup' \
+ 'Minute,Hourly,Daily,Weekly,Monthly,OnDemand,OnStartup' \
))
+ fd.write("\n\n")
+ fd.write(" # General routine to return string name of a constant (e.g. 'DATASOURCE_FREQUENCY_STR')\n")
+ fd.write(" def get_orm_string(value,string_set):\n")
+ fd.write(" string_list = string_set.split(',')\n")
+ fd.write(" string_count = len(string_list)\n")
+ fd.write(" value = int(value)\n")
+ fd.write(" if (value < 0) or (value >= string_count):\n")
+ fd.write(" print(\"ERROR: value '%d' out of range of '%s'\" % (value,string_set))\n")
+ fd.write(" return '<error>'\n")
+ fd.write(" return string_list[value]\n")
+ fd.write("")
+
fd.write("\n")
#################################
@@ -538,7 +550,6 @@ def fix_cve_recommend():
i = 0
for cve in cur:
i += 1
- name_sort = get_name_sort(cve[ORM.CVE_NAME])
# Progress indicator support
if 0 == i % 10:
diff --git a/bin/common/srtool_update.py b/bin/common/srtool_update.py
index a093a7b6..ebd19aef 100755
--- a/bin/common/srtool_update.py
+++ b/bin/common/srtool_update.py
@@ -225,7 +225,7 @@ def list():
cur = conn.cursor()
cur_write = conn.cursor()
- format_str = "%14s %7s %14s %10s %28s %s"
+ format_str = "%16s %7s %14s %10s %28s %s"
print("SRTool Update List:")
status_str = "====================\n"
@@ -236,7 +236,7 @@ def list():
# Only process datasoures with update command
if not source[ORM.DATASOURCE_UPDATE]:
continue
- frequency_str = ORM.DATASOURCE_FREQUENCY_STR.split(',')[source[ORM.DATASOURCE_UPDATE_FREQUENCY]]
+ 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]))
#################################
diff --git a/lib/srtmain/management/commands/update.py b/lib/srtmain/management/commands/update.py
index 8f746aea..8304e199 100755
--- a/lib/srtmain/management/commands/update.py
+++ b/lib/srtmain/management/commands/update.py
@@ -36,6 +36,7 @@ class Command(BaseCommand):
context = '> /dev/null 2>&1 &' if 'cron_start' == options['command'] else ''
update_command = "./bin/common/srtool_update.py %s %s %s %s %s %s" % (command,name_filter,force,is_trial,verbose,context)
- print("RUN: %s" % (update_command))
+ if verbose:
+ print("RUN UPDATE SCRIPT: %s" % (update_command))
os.chdir(os.environ['SRT_BASE_DIR'])
os.system("%s" % (update_command))