@@ -52,13 +52,23 @@ def __init__(self):
52
52
"generate_html" : generate_html ,
53
53
}
54
54
55
- def execute_action (self , action_list : list ) -> str :
55
+ def _execute_event (self , action : list ):
56
+ event = self .event_dict .get (action [0 ])
57
+ if len (action ) == 2 :
58
+ event (** action [1 ])
59
+ elif len (action ) == 1 :
60
+ event ()
61
+ else :
62
+ raise AutoControlActionException (cant_execute_action_error )
63
+
64
+ def execute_action (self , action_list : list ) -> dict :
56
65
"""
57
66
use to execute all action on action list(action file or program list)
58
67
:param action_list the list include action
59
68
for loop the list and execute action
60
69
"""
61
- execute_record_string = ""
70
+
71
+ execute_record_dict = dict ()
62
72
try :
63
73
if len (action_list ) > 0 or type (action_list ) is list :
64
74
pass
@@ -69,20 +79,13 @@ def execute_action(self, action_list: list) -> str:
69
79
print (repr (error ), file = sys .stderr )
70
80
for action in action_list :
71
81
try :
72
- event = self .event_dict .get (action [0 ])
73
- if len (action ) == 2 :
74
- event (** action [1 ])
75
- elif len (action ) == 1 :
76
- event ()
77
- else :
78
- raise AutoControlActionException (cant_execute_action_error )
82
+ event_response = self ._execute_event (action )
83
+ execute_record = "execute: " + str (action )
84
+ execute_record_dict .update ({execute_record : event_response })
79
85
except Exception as error :
80
86
print (repr (error ), file = sys .stderr )
81
87
record_action_to_list ("execute_action" , None , repr (error ))
82
- temp_string = "execute: " + str (action )
83
- print (temp_string )
84
- execute_record_string = "" .join ([execute_record_string , temp_string + "\n " ])
85
- return execute_record_string
88
+ return execute_record_dict
86
89
87
90
def execute_files (self , execute_files_list : list ) -> list :
88
91
"""
@@ -106,7 +109,7 @@ def add_command_to_executor(command_dict: dict):
106
109
raise AutoControlAddCommandException (add_command_exception_tag )
107
110
108
111
109
- def execute_action (action_list : list ) -> str :
112
+ def execute_action (action_list : list ) -> dict :
110
113
return executor .execute_action (action_list )
111
114
112
115
0 commit comments