Skip to content

Commit 7c29b6b

Browse files
committed
tebelorg#35 tebelorg#34 - cleaner execution and error handling
tebelorg#35 - Cleaner usage and execution without TagUI intermediary files During usage, the following temporary files will be generated in order to use TagUI - tagui_python - simple flow to initiate TagUI live mode tagui_python.raw - raw file for TagUI module expansion tagui_python.js - generated JavaScript code for TagUI tagui_local.js - TagUI for Python custom functions file tagui_python.log - log file for automation execution tagui_python.txt - to retrieve data output from TagUI When debug mode is on using debug(True), only tagui_python.log and tagui_python.txt will be retained while the rest are deleted. That essentially means that the first 4 files above do not really add value to the typical TagUI for Python user. Having them in the script folder during execution may add clutter, clunkiness and confusion. Furthermore, TagUI for Python has been downloaded over 5000 times since initial release, without users reporting issue that requires above 4 temporary files for debugging and troubleshooting. Raising issue to update code to immediately delete the first 4 files upon connecting to TagUI to remove clutter. For the last 2 files, they will be retained until close() is used, where they will be deleted if debug(False) (default). tebelorg#34 - graceful error handling on Windows folder path with space On Windows, if script is used in folder path name with space, error message can appear without any meaningful information. Some components of upstream project TagUI cannot work with spaces in the path and folder name containing the TagUI automation script. Solution is store the script in a folder path without space, or run it from a folder path without space in it.
1 parent 573eb2e commit 7c29b6b

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# TagUI for Python
44

5-
[**Use Cases**](#use-cases) | [**API Reference**](#api-reference) | [**About & Credits**](#about--credits) | [**v1.8**](https://github.com/tebelorg/TagUI-Python/releases)
5+
[**Use Cases**](#use-cases) | [**API Reference**](#api-reference) | [**About & Credits**](#about--credits) | [**v1.9**](https://github.com/tebelorg/TagUI-Python/releases)
66

77
![TagUI for Python demo in Jupyter notebook](https://raw.githubusercontent.com/tebelorg/Tump/master/tagui_python.gif)
88

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='tagui',
5-
version='1.8.0',
5+
version='1.9.0',
66
py_modules=['tagui'],
77
author='Ken Soh',
88
author_email='[email protected]',

tagui.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""INTEGRATION ENGINE FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG"""
22
__author__ = 'Ken Soh <[email protected]>'
3-
__version__ = '1.8.0'
3+
__version__ = '1.9.0'
44

55
import subprocess
66
import os
@@ -413,6 +413,11 @@ def init(visual_automation = False, chrome_browser = True):
413413
# sync tagui delta files for current release if needed
414414
if not _tagui_delta(tagui_directory): return False
415415

416+
# on Windows, check if there is space in folder path name
417+
if platform.system() == 'Windows' and ' ' in os.getcwd():
418+
print('[TAGUI][INFO] - to use TagUI for Python on Windows, avoid space in folder path name')
419+
return False
420+
416421
# create entry flow to launch SikuliX accordingly
417422
if visual_automation:
418423
# check for working java jdk for visual automation mode
@@ -492,6 +497,12 @@ def init(visual_automation = False, chrome_browser = True):
492497
print('[TAGUI][ERROR] - TagUI process ended unexpectedly')
493498
return False
494499

500+
# remove generated tagui flow, js code and custom functions files
501+
if os.path.isfile('tagui_python'): os.remove('tagui_python')
502+
if os.path.isfile('tagui_python.js'): os.remove('tagui_python.js')
503+
if os.path.isfile('tagui_python.raw'): os.remove('tagui_python.raw')
504+
if os.path.isfile('tagui_local.js'): os.remove('tagui_local.js')
505+
495506
# increment id and prepare for next instruction
496507
_tagui_id = _tagui_id + 1
497508

@@ -627,12 +638,6 @@ def close():
627638
# loop until tagui process has closed before returning control
628639
while _process.poll() is None: pass
629640

630-
# remove generated tagui flow, js code and custom functions files
631-
if os.path.isfile('tagui_python'): os.remove('tagui_python')
632-
if os.path.isfile('tagui_python.js'): os.remove('tagui_python.js')
633-
if os.path.isfile('tagui_python.raw'): os.remove('tagui_python.raw')
634-
if os.path.isfile('tagui_local.js'): os.remove('tagui_local.js')
635-
636641
# remove generated tagui log and data files if not in debug mode
637642
if not debug():
638643
if os.path.isfile('tagui_python.log'): os.remove('tagui_python.log')

0 commit comments

Comments
 (0)