1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
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.
---
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 @@ def GetProfileChoicesForInput(self, input_file, tailoring_file):
@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 @@
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 @@ def __init__(self):
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 @@ def get_profile_choices_for_input(self, input_file, tailoring_file):
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 @@ def __str__(self):
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 @@ def get_closest_datetime(self, reference_datetime):
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 @@ def schedule_tasks(self, reference_datetime=None):
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 @@ def generate_fix_for_task_result(self, task_id, result_id, fix_type):
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 @@ def __str__(self):
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 @@ def test(self):
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()
|