aboutsummaryrefslogtreecommitdiffstats
path: root/lib/orm/management/commands/lsupdates.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/orm/management/commands/lsupdates.py')
-rw-r--r--lib/orm/management/commands/lsupdates.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/orm/management/commands/lsupdates.py b/lib/orm/management/commands/lsupdates.py
index ca67713a..1805142f 100644
--- a/lib/orm/management/commands/lsupdates.py
+++ b/lib/orm/management/commands/lsupdates.py
@@ -5,7 +5,7 @@
# Security Response Tool Implementation
#
# Copyright (C) 2013-2015 Intel Corp.
-# Copyright (C) 2017-2018 Wind River Systems
+# Copyright (C) 2017-2021 Wind River Systems
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -103,7 +103,7 @@ class Command(BaseCommand):
(what,
pec))
sys.stdout.flush()
- if int(pec) is 100:
+ if int(pec) == 100:
sys.stdout.write("\n")
sys.stdout.flush()
@@ -322,6 +322,16 @@ class Command(BaseCommand):
logger.info("***LS UPDATES***")
+ # Disable the background updates until these are all processed
+ SrtSetting.set_setting('SRT_DISABLE_UPDATES','yes')
+
+ # First process the pre-init data sources in strict pk order to insure dependencies
+ data_sources=DataSource.objects.filter(update_frequency=DataSource.PREINIT).order_by('key')
+ for source in data_sources:
+ if source.init:
+ print("Fetching pre-init datasource '%s:%s'" % (source.source,source.description))
+ self.execute_script(source.init)
+
# Process the data sources in strict pk order to insure dependencies
data_sources=DataSource.objects.all().order_by('key')
for source in data_sources:
@@ -333,6 +343,10 @@ class Command(BaseCommand):
# No Init action?
print("Skipping datasource %s (no init action)" % (source.description))
continue
+ elif 'DISABLE ' in source.attributes:
+ # Data source disabled
+ print("Disabled datasource %s (%s)" % (source.description,source.attributes))
+ continue
else:
logger.info("Fetching datasource %s:%s" % (source.source,source.description))
print("Fetching datasource '%s:%s'" % (source.source,source.description))
@@ -395,10 +409,12 @@ class Command(BaseCommand):
logger.error("Unknown data source type for (%s,%s,%s) " % (source.data,source.source,source.name))
_log("Unknown data source type for %s,%s,%s) " % (source.data,source.source,source.name))
+ # Re-able the background updates until these are all processed
+ SrtSetting.set_setting('SRT_DISABLE_UPDATES','no')
+
os.system('setterm -cursor on')
def handle(self, *args, **options):
-
# testing shortcuts
if 'yes' == SrtSetting.objects.get(name='SRTDBG_MINIMAL_DB').value:
print("TEST: MINIMAL DATABASE LOADING")
@@ -407,5 +423,4 @@ class Command(BaseCommand):
Command.status_sustaining_limit = 10
Command.debug_defect_limit = 10
Command.cpe_limit = 10
-
self.update()