Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 1 | From c34349720a57997d30946286756e2ba9dbab6ace Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <matyc@redhat.com> |
| 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 | Upstream-Status: Backport |
| 9 | [https://github.com/OpenSCAP/openscap-daemon/commit/c34349720a57997d30946286756e2ba9dbab6ace] |
| 10 | |
| 11 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> |
| 12 | --- |
| 13 | openscap_daemon/{async.py => async_tools.py} | 0 |
| 14 | openscap_daemon/dbus_daemon.py | 2 +- |
| 15 | openscap_daemon/system.py | 16 ++++++++-------- |
| 16 | tests/unit/test_basic_update.py | 3 ++- |
| 17 | 4 files changed, 11 insertions(+), 10 deletions(-) |
| 18 | rename openscap_daemon/{async.py => async_tools.py} (100%) |
| 19 | |
| 20 | diff --git a/openscap_daemon/async.py b/openscap_daemon/async_tools.py |
| 21 | similarity index 100% |
| 22 | rename from openscap_daemon/async.py |
| 23 | rename to openscap_daemon/async_tools.py |
| 24 | diff --git a/openscap_daemon/dbus_daemon.py b/openscap_daemon/dbus_daemon.py |
| 25 | index e6eadf9..cb6a8b6 100644 |
| 26 | --- a/openscap_daemon/dbus_daemon.py |
| 27 | +++ b/openscap_daemon/dbus_daemon.py |
| 28 | @@ -81,7 +81,7 @@ class OpenSCAPDaemonDbus(dbus.service.Object): |
| 29 | @dbus.service.method(dbus_interface=dbus_utils.DBUS_INTERFACE, |
| 30 | in_signature="", out_signature="a(xsi)") |
| 31 | def GetAsyncActionsStatus(self): |
| 32 | - return self.system.async.get_status() |
| 33 | + return self.system.async_manager.get_status() |
| 34 | |
| 35 | @dbus.service.method(dbus_interface=dbus_utils.DBUS_INTERFACE, |
| 36 | in_signature="s", out_signature="(sssn)") |
| 37 | diff --git a/openscap_daemon/system.py b/openscap_daemon/system.py |
| 38 | index 2012f6e..85c2680 100644 |
| 39 | --- a/openscap_daemon/system.py |
| 40 | +++ b/openscap_daemon/system.py |
| 41 | @@ -26,7 +26,7 @@ import logging |
| 42 | from openscap_daemon.task import Task |
| 43 | from openscap_daemon.config import Configuration |
| 44 | from openscap_daemon import oscap_helpers |
| 45 | -from openscap_daemon import async |
| 46 | +from openscap_daemon import async_tools |
| 47 | |
| 48 | |
| 49 | class ResultsNotAvailable(Exception): |
| 50 | @@ -40,7 +40,7 @@ TASK_ACTION_PRIORITY = 10 |
| 51 | |
| 52 | class System(object): |
| 53 | def __init__(self, config_file): |
| 54 | - self.async = async.AsyncManager() |
| 55 | + self.async_manager = async_tools.AsyncManager() |
| 56 | |
| 57 | logging.info("Loading configuration from '%s'.", config_file) |
| 58 | self.config = Configuration() |
| 59 | @@ -90,7 +90,7 @@ class System(object): |
| 60 | input_file, tailoring_file, None |
| 61 | ) |
| 62 | |
| 63 | - class AsyncEvaluateSpecAction(async.AsyncAction): |
| 64 | + class AsyncEvaluateSpecAction(async_tools.AsyncAction): |
| 65 | def __init__(self, system, spec): |
| 66 | super(System.AsyncEvaluateSpecAction, self).__init__() |
| 67 | |
| 68 | @@ -113,7 +113,7 @@ class System(object): |
| 69 | return "Evaluate Spec '%s'" % (self.spec) |
| 70 | |
| 71 | def evaluate_spec_async(self, spec): |
| 72 | - return self.async.enqueue( |
| 73 | + return self.async_manager.enqueue( |
| 74 | System.AsyncEvaluateSpecAction( |
| 75 | self, |
| 76 | spec |
| 77 | @@ -488,7 +488,7 @@ class System(object): |
| 78 | |
| 79 | return ret |
| 80 | |
| 81 | - class AsyncUpdateTaskAction(async.AsyncAction): |
| 82 | + class AsyncUpdateTaskAction(async_tools.AsyncAction): |
| 83 | def __init__(self, system, task_id, reference_datetime): |
| 84 | super(System.AsyncUpdateTaskAction, self).__init__() |
| 85 | |
| 86 | @@ -536,7 +536,7 @@ class System(object): |
| 87 | |
| 88 | if task.should_be_updated(reference_datetime): |
| 89 | self.tasks_scheduled.add(task.id_) |
| 90 | - self.async.enqueue( |
| 91 | + self.async_manager.enqueue( |
| 92 | System.AsyncUpdateTaskAction( |
| 93 | self, |
| 94 | task.id_, |
| 95 | @@ -662,7 +662,7 @@ class System(object): |
| 96 | fix_type |
| 97 | ) |
| 98 | |
| 99 | - class AsyncEvaluateCVEScannerWorkerAction(async.AsyncAction): |
| 100 | + class AsyncEvaluateCVEScannerWorkerAction(async_tools.AsyncAction): |
| 101 | def __init__(self, system, worker): |
| 102 | super(System.AsyncEvaluateCVEScannerWorkerAction, self).__init__() |
| 103 | |
| 104 | @@ -680,7 +680,7 @@ class System(object): |
| 105 | return "Evaluate CVE Scanner Worker '%s'" % (self.worker) |
| 106 | |
| 107 | def evaluate_cve_scanner_worker_async(self, worker): |
| 108 | - return self.async.enqueue( |
| 109 | + return self.async_manager.enqueue( |
| 110 | System.AsyncEvaluateCVEScannerWorkerAction( |
| 111 | self, |
| 112 | worker |
| 113 | diff --git a/tests/unit/test_basic_update.py b/tests/unit/test_basic_update.py |
| 114 | index 6f683e6..7f953f7 100755 |
| 115 | --- a/tests/unit/test_basic_update.py |
| 116 | +++ b/tests/unit/test_basic_update.py |
| 117 | @@ -37,8 +37,9 @@ class BasicUpdateTest(unit_test_harness.APITest): |
| 118 | print(self.system.tasks) |
| 119 | self.system.schedule_tasks() |
| 120 | |
| 121 | - while len(self.system.async.actions) > 0: |
| 122 | + while len(self.system.async_manager.actions) > 0: |
| 123 | time.sleep(1) |
| 124 | |
| 125 | + |
| 126 | if __name__ == "__main__": |
| 127 | BasicUpdateTest.run() |
| 128 | -- |
| 129 | 2.7.4 |
| 130 | |