| From c34349720a57997d30946286756e2ba9dbab6ace Mon Sep 17 00:00:00 2001 |
| From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <matyc@redhat.com> |
| Date: Mon, 2 Jul 2018 11:21:19 +0200 |
| Subject: [PATCH] Renamed module and variables to get rid of async. |
| |
| async is a reserved word in Python 3.7. |
| |
| Upstream-Status: Backport |
| [https://github.com/OpenSCAP/openscap-daemon/commit/c34349720a57997d30946286756e2ba9dbab6ace] |
| |
| Signed-off-by: Yi Zhao <yi.zhao@windriver.com> |
| --- |
| openscap_daemon/{async.py => async_tools.py} | 0 |
| openscap_daemon/dbus_daemon.py | 2 +- |
| openscap_daemon/system.py | 16 ++++++++-------- |
| tests/unit/test_basic_update.py | 3 ++- |
| 4 files changed, 11 insertions(+), 10 deletions(-) |
| rename openscap_daemon/{async.py => async_tools.py} (100%) |
| |
| diff --git a/openscap_daemon/async.py b/openscap_daemon/async_tools.py |
| similarity index 100% |
| rename from openscap_daemon/async.py |
| rename to openscap_daemon/async_tools.py |
| diff --git a/openscap_daemon/dbus_daemon.py b/openscap_daemon/dbus_daemon.py |
| index e6eadf9..cb6a8b6 100644 |
| --- a/openscap_daemon/dbus_daemon.py |
| +++ b/openscap_daemon/dbus_daemon.py |
| @@ -81,7 +81,7 @@ class OpenSCAPDaemonDbus(dbus.service.Object): |
| @dbus.service.method(dbus_interface=dbus_utils.DBUS_INTERFACE, |
| in_signature="", out_signature="a(xsi)") |
| def GetAsyncActionsStatus(self): |
| - return self.system.async.get_status() |
| + return self.system.async_manager.get_status() |
| |
| @dbus.service.method(dbus_interface=dbus_utils.DBUS_INTERFACE, |
| in_signature="s", out_signature="(sssn)") |
| diff --git a/openscap_daemon/system.py b/openscap_daemon/system.py |
| index 2012f6e..85c2680 100644 |
| --- a/openscap_daemon/system.py |
| +++ b/openscap_daemon/system.py |
| @@ -26,7 +26,7 @@ import logging |
| from openscap_daemon.task import Task |
| from openscap_daemon.config import Configuration |
| from openscap_daemon import oscap_helpers |
| -from openscap_daemon import async |
| +from openscap_daemon import async_tools |
| |
| |
| class ResultsNotAvailable(Exception): |
| @@ -40,7 +40,7 @@ TASK_ACTION_PRIORITY = 10 |
| |
| class System(object): |
| def __init__(self, config_file): |
| - self.async = async.AsyncManager() |
| + self.async_manager = async_tools.AsyncManager() |
| |
| logging.info("Loading configuration from '%s'.", config_file) |
| self.config = Configuration() |
| @@ -90,7 +90,7 @@ class System(object): |
| input_file, tailoring_file, None |
| ) |
| |
| - class AsyncEvaluateSpecAction(async.AsyncAction): |
| + class AsyncEvaluateSpecAction(async_tools.AsyncAction): |
| def __init__(self, system, spec): |
| super(System.AsyncEvaluateSpecAction, self).__init__() |
| |
| @@ -113,7 +113,7 @@ class System(object): |
| return "Evaluate Spec '%s'" % (self.spec) |
| |
| def evaluate_spec_async(self, spec): |
| - return self.async.enqueue( |
| + return self.async_manager.enqueue( |
| System.AsyncEvaluateSpecAction( |
| self, |
| spec |
| @@ -488,7 +488,7 @@ class System(object): |
| |
| return ret |
| |
| - class AsyncUpdateTaskAction(async.AsyncAction): |
| + class AsyncUpdateTaskAction(async_tools.AsyncAction): |
| def __init__(self, system, task_id, reference_datetime): |
| super(System.AsyncUpdateTaskAction, self).__init__() |
| |
| @@ -536,7 +536,7 @@ class System(object): |
| |
| if task.should_be_updated(reference_datetime): |
| self.tasks_scheduled.add(task.id_) |
| - self.async.enqueue( |
| + self.async_manager.enqueue( |
| System.AsyncUpdateTaskAction( |
| self, |
| task.id_, |
| @@ -662,7 +662,7 @@ class System(object): |
| fix_type |
| ) |
| |
| - class AsyncEvaluateCVEScannerWorkerAction(async.AsyncAction): |
| + class AsyncEvaluateCVEScannerWorkerAction(async_tools.AsyncAction): |
| def __init__(self, system, worker): |
| super(System.AsyncEvaluateCVEScannerWorkerAction, self).__init__() |
| |
| @@ -680,7 +680,7 @@ class System(object): |
| return "Evaluate CVE Scanner Worker '%s'" % (self.worker) |
| |
| def evaluate_cve_scanner_worker_async(self, worker): |
| - return self.async.enqueue( |
| + return self.async_manager.enqueue( |
| System.AsyncEvaluateCVEScannerWorkerAction( |
| self, |
| worker |
| diff --git a/tests/unit/test_basic_update.py b/tests/unit/test_basic_update.py |
| index 6f683e6..7f953f7 100755 |
| --- a/tests/unit/test_basic_update.py |
| +++ b/tests/unit/test_basic_update.py |
| @@ -37,8 +37,9 @@ class BasicUpdateTest(unit_test_harness.APITest): |
| print(self.system.tasks) |
| self.system.schedule_tasks() |
| |
| - while len(self.system.async.actions) > 0: |
| + while len(self.system.async_manager.actions) > 0: |
| time.sleep(1) |
| |
| + |
| if __name__ == "__main__": |
| BasicUpdateTest.run() |
| -- |
| 2.7.4 |
| |