@@ -77,20 +77,35 @@ def _sdq(input_text = ''):
7777# change identifier single quote ' to double quote "
7878 return input_text .replace ("'" ,'"' )
7979
80+ def _started ():
81+ global _tagui_started ; return _tagui_started
82+
8083def coord (x_coordinate = None , y_coordinate = None ):
8184# function to form a coordinate string from x and y integers
8285 return '(' + str (x_coordinate ) + ',' + str (y_coordinate ) + ')'
8386
84- def _started ():
85- global _tagui_started ; return _tagui_started
86-
8787def debug (on_off = None ):
8888# function to set debug mode, eg print debug info
8989 global _tagui_debug
9090 if on_off is not None : _tagui_debug = on_off
9191 return _tagui_debug
9292
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 ):
94109# connect to tagui process by checking tagui live mode readiness
95110
96111 global _process , _tagui_started , _tagui_id
@@ -99,17 +114,14 @@ def init(debug_mode = False, visual_automation = False):
99114 print ('[TAGUI][ERROR] - use close() before using init() again' )
100115 return False
101116
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
106118 if visual_automation :
107- tagui_flow = 'tagui_visual'
119+ _visual_flow ()
108120 else :
109- tagui_flow = 'tagui_python'
121+ _python_flow ()
110122
111123 # entry command to invoke tagui process
112- tagui_cmd = 'tagui ' + tagui_flow + ' chrome'
124+ tagui_cmd = 'tagui tagui_python chrome'
113125
114126 try :
115127 # launch tagui using subprocess
@@ -236,6 +248,13 @@ def close():
236248 # loop until tagui process has closed before returning control
237249 while _process .poll () is None : pass
238250
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+
239258 _tagui_started = False
240259 return True
241260
0 commit comments