@@ -77,20 +77,35 @@ def _sdq(input_text = ''):
77
77
# change identifier single quote ' to double quote "
78
78
return input_text .replace ("'" ,'"' )
79
79
80
+ def _started ():
81
+ global _tagui_started ; return _tagui_started
82
+
80
83
def coord (x_coordinate = None , y_coordinate = None ):
81
84
# function to form a coordinate string from x and y integers
82
85
return '(' + str (x_coordinate ) + ',' + str (y_coordinate ) + ')'
83
86
84
- def _started ():
85
- global _tagui_started ; return _tagui_started
86
-
87
87
def debug (on_off = None ):
88
88
# function to set debug mode, eg print debug info
89
89
global _tagui_debug
90
90
if on_off is not None : _tagui_debug = on_off
91
91
return _tagui_debug
92
92
93
- def init (debug_mode = False , visual_automation = False ):
93
+ def _python_flow ():
94
+ # function to create entry tagui flow without visual automation
95
+ flow_text = '// NORMAL ENTRY FLOW FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG\r \n \r \n live'
96
+ flow_file = open ('tagui_python' , 'w' )
97
+ flow_file .write (flow_text )
98
+ flow_file .close ()
99
+
100
+ def _visual_flow ():
101
+ # function to create entry tagui flow with visual automation
102
+ flow_text = '// VISUAL ENTRY FLOW FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG\r \n ' + \
103
+ '// mouse_xy() - dummy trigger for SikuliX integration\r \n \r \n live'
104
+ flow_file = open ('tagui_python' , 'w' )
105
+ flow_file .write (flow_text )
106
+ flow_file .close ()
107
+
108
+ def init (visual_automation = False ):
94
109
# connect to tagui process by checking tagui live mode readiness
95
110
96
111
global _process , _tagui_started , _tagui_id
@@ -99,17 +114,14 @@ def init(debug_mode = False, visual_automation = False):
99
114
print ('[TAGUI][ERROR] - use close() before using init() again' )
100
115
return False
101
116
102
- # set debug mode, eg print debug info to output
103
- debug (debug_mode )
104
-
105
- # set entry flow to launch SikuliX accordingly
117
+ # create entry flow to launch SikuliX accordingly
106
118
if visual_automation :
107
- tagui_flow = 'tagui_visual'
119
+ _visual_flow ()
108
120
else :
109
- tagui_flow = 'tagui_python'
121
+ _python_flow ()
110
122
111
123
# entry command to invoke tagui process
112
- tagui_cmd = 'tagui ' + tagui_flow + ' chrome'
124
+ tagui_cmd = 'tagui tagui_python chrome'
113
125
114
126
try :
115
127
# launch tagui using subprocess
@@ -236,6 +248,13 @@ def close():
236
248
# loop until tagui process has closed before returning control
237
249
while _process .poll () is None : pass
238
250
251
+ # remove generated tagui flow and log files if not in debug mode
252
+ if not debug ():
253
+ if os .path .isfile ('tagui_python' ): os .remove ('tagui_python' )
254
+ if os .path .isfile ('tagui_python.js' ): os .remove ('tagui_python.js' )
255
+ if os .path .isfile ('tagui_python.raw' ): os .remove ('tagui_python.raw' )
256
+ if os .path .isfile ('tagui_python.log' ): os .remove ('tagui_python.log' )
257
+
239
258
_tagui_started = False
240
259
return True
241
260
0 commit comments