| 1 | From c34349720a57997d30946286756e2ba9dbab6ace Mon Sep 17 00:00:00 2001
|
| 2 | From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <[email protected]>
|
| 3 | Date: Mon, 2 Jul 2018 11:21:19 +0200
|
| 4 | Subject: [PATCH] Renamed module and variables to get rid of async.
|
| 5 |
|
| 6 | async is a reserved word in Python 3.7.
|
| 7 | ---
|
| 8 | openscap_daemon/{async.py => async_tools.py} | 0
|
| 9 | openscap_daemon/dbus_daemon.py | 2 +-
|
| 10 | openscap_daemon/system.py | 16 ++++++++--------
|
| 11 | tests/unit/test_basic_update.py | 3 ++-
|
| 12 | 4 files changed, 11 insertions(+), 10 deletions(-)
|
| 13 | rename openscap_daemon/{async.py => async_tools.py} (100%)
|
| 14 |
|
| 15 | diff --git a/openscap_daemon/async.py b/openscap_daemon/async_tools.py
|
| 16 | similarity index 100%
|
| 17 | rename from openscap_daemon/async.py
|
| 18 | rename to openscap_daemon/async_tools.py
|
| 19 | diff --git a/openscap_daemon/dbus_daemon.py b/openscap_daemon/dbus_daemon.py
|
| 20 | index e6eadf9..cb6a8b6 100644
|
| 21 | |
| 22 | |
| 23 | @@ -81,7 +81,7 @@ def GetProfileChoicesForInput(self, input_file, tailoring_file):
|
| 24 | @dbus.service.method(dbus_interface=dbus_utils.DBUS_INTERFACE,
|
| 25 | in_signature="", out_signature="a(xsi)")
|
| 26 | def GetAsyncActionsStatus(self):
|
| 27 | - return self.system.async.get_status()
|
| 28 | + return self.system.async_manager.get_status()
|
| 29 |
|
| 30 | @dbus.service.method(dbus_interface=dbus_utils.DBUS_INTERFACE,
|
| 31 | in_signature="s", out_signature="(sssn)")
|
| 32 | diff --git a/openscap_daemon/system.py b/openscap_daemon/system.py
|
| 33 | index 2012f6e..85c2680 100644
|
| 34 | |
| 35 | |
| 36 | @@ -26,7 +26,7 @@
|
| 37 | from openscap_daemon.task import Task
|
| 38 | from openscap_daemon.config import Configuration
|
| 39 | from openscap_daemon import oscap_helpers
|
| 40 | -from openscap_daemon import async
|
| 41 | +from openscap_daemon import async_tools
|
| 42 |
|
| 43 |
|
| 44 | class ResultsNotAvailable(Exception):
|
| 45 | @@ -40,7 +40,7 @@ def __init__(self):
|
| 46 |
|
| 47 | class System(object):
|
| 48 | def __init__(self, config_file):
|
| 49 | - self.async = async.AsyncManager()
|
| 50 | + self.async_manager = async_tools.AsyncManager()
|
| 51 |
|
| 52 | logging.info("Loading configuration from '%s'.", config_file)
|
| 53 | self.config = Configuration()
|
| 54 | @@ -90,7 +90,7 @@ def get_profile_choices_for_input(self, input_file, tailoring_file):
|
| 55 | input_file, tailoring_file, None
|
| 56 | )
|
| 57 |
|
| 58 | - class AsyncEvaluateSpecAction(async.AsyncAction):
|
| 59 | + class AsyncEvaluateSpecAction(async_tools.AsyncAction):
|
| 60 | def __init__(self, system, spec):
|
| 61 | super(System.AsyncEvaluateSpecAction, self).__init__()
|
| 62 |
|
| 63 | @@ -113,7 +113,7 @@ def __str__(self):
|
| 64 | return "Evaluate Spec '%s'" % (self.spec)
|
| 65 |
|
| 66 | def evaluate_spec_async(self, spec):
|
| 67 | - return self.async.enqueue(
|
| 68 | + return self.async_manager.enqueue(
|
| 69 | System.AsyncEvaluateSpecAction(
|
| 70 | self,
|
| 71 | spec
|
| 72 | @@ -488,7 +488,7 @@ def get_closest_datetime(self, reference_datetime):
|
| 73 |
|
| 74 | return ret
|
| 75 |
|
| 76 | - class AsyncUpdateTaskAction(async.AsyncAction):
|
| 77 | + class AsyncUpdateTaskAction(async_tools.AsyncAction):
|
| 78 | def __init__(self, system, task_id, reference_datetime):
|
| 79 | super(System.AsyncUpdateTaskAction, self).__init__()
|
| 80 |
|
| 81 | @@ -536,7 +536,7 @@ def schedule_tasks(self, reference_datetime=None):
|
| 82 |
|
| 83 | if task.should_be_updated(reference_datetime):
|
| 84 | self.tasks_scheduled.add(task.id_)
|
| 85 | - self.async.enqueue(
|
| 86 | + self.async_manager.enqueue(
|
| 87 | System.AsyncUpdateTaskAction(
|
| 88 | self,
|
| 89 | task.id_,
|
| 90 | @@ -662,7 +662,7 @@ def generate_fix_for_task_result(self, task_id, result_id, fix_type):
|
| 91 | fix_type
|
| 92 | )
|
| 93 |
|
| 94 | - class AsyncEvaluateCVEScannerWorkerAction(async.AsyncAction):
|
| 95 | + class AsyncEvaluateCVEScannerWorkerAction(async_tools.AsyncAction):
|
| 96 | def __init__(self, system, worker):
|
| 97 | super(System.AsyncEvaluateCVEScannerWorkerAction, self).__init__()
|
| 98 |
|
| 99 | @@ -680,7 +680,7 @@ def __str__(self):
|
| 100 | return "Evaluate CVE Scanner Worker '%s'" % (self.worker)
|
| 101 |
|
| 102 | def evaluate_cve_scanner_worker_async(self, worker):
|
| 103 | - return self.async.enqueue(
|
| 104 | + return self.async_manager.enqueue(
|
| 105 | System.AsyncEvaluateCVEScannerWorkerAction(
|
| 106 | self,
|
| 107 | worker
|
| 108 | diff --git a/tests/unit/test_basic_update.py b/tests/unit/test_basic_update.py
|
| 109 | index 6f683e6..7f953f7 100755
|
| 110 | |
| 111 | |
| 112 | @@ -37,8 +37,9 @@ def test(self):
|
| 113 | print(self.system.tasks)
|
| 114 | self.system.schedule_tasks()
|
| 115 |
|
| 116 | - while len(self.system.async.actions) > 0:
|
| 117 | + while len(self.system.async_manager.actions) > 0:
|
| 118 | time.sleep(1)
|
| 119 |
|
| 120 | +
|
| 121 | if __name__ == "__main__":
|
| 122 | BasicUpdateTest.run()
|