-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to define custom TagUI installation folder #207
Changes from 6 commits
b89eb99
3e86e45
d766300
13f8ef2
97fcd06
ab7c6df
23db347
5b45532
77ae10e
2b71c4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,7 +247,7 @@ def unzip(file_to_unzip = None, unzip_location = None): | |
zip_file.close() | ||
return True | ||
|
||
def setup(): | ||
def setup(installation_dir = None): | ||
"""function to setup TagUI to user home folder on Linux / macOS / Windows""" | ||
|
||
# get user home folder location to setup tagui | ||
|
@@ -256,6 +256,10 @@ def setup(): | |
else: | ||
home_directory = os.path.expanduser('~') | ||
|
||
# override home folder when manual path is set | ||
if installation_dir: | ||
home_directory = installation_dir | ||
|
||
print('[RPA][INFO] - setting up TagUI for use in your Python environment') | ||
|
||
# special check for macOS - download() will fail due to no SSL certs for Python 3 | ||
|
@@ -308,6 +312,10 @@ def setup(): | |
else: | ||
tagui_directory = home_directory + '/' + '.tagui' | ||
|
||
# override with custom dir | ||
if installation_dir: | ||
tagui_directory = installation_dir + '/' + '.tagui' | ||
|
||
# overwrite tagui to .tagui folder for Linux / macOS | ||
|
||
# first rename existing .tagui folder to .tagui_previous | ||
|
@@ -437,7 +445,7 @@ def setup(): | |
|
||
return True | ||
|
||
def init(visual_automation = False, chrome_browser = True): | ||
def init(visual_automation = False, chrome_browser = True, installation_dir = None): | ||
"""start and connect to tagui process by checking tagui live mode readiness""" | ||
|
||
global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome, _tagui_init_directory | ||
|
@@ -458,12 +466,21 @@ def init(visual_automation = False, chrome_browser = True): | |
else: | ||
tagui_directory = os.path.expanduser('~') + '/' + '.tagui' | ||
|
||
# check if custom installation path is set | ||
if installation_dir: | ||
if "tagui" in installation_dir: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it is expected that |
||
print('[RPA][INFO] - It was detected to use a custom directory.') | ||
tagui_directory = installation_dir | ||
else: | ||
print('[RPA][ERROR] - Please use path with target directory name tagui.') | ||
sys.exit(1) | ||
|
||
tagui_executable = tagui_directory + '/' + 'src' + '/' + 'tagui' | ||
end_processes_executable = tagui_directory + '/' + 'src' + '/' + 'end_processes' | ||
|
||
# if tagui executable is not found, initiate setup() to install tagui | ||
if not os.path.isfile(tagui_executable): | ||
if not setup(): | ||
if not setup(installation_dir): | ||
# error message is shown by setup(), no need for message here | ||
return False | ||
|
||
|
@@ -586,19 +603,26 @@ def init(visual_automation = False, chrome_browser = True): | |
_tagui_started = False | ||
return False | ||
|
||
def pack(): | ||
def pack(installation_dir = None): | ||
"""function to pack TagUI files for installation on an air-gapped computer without internet""" | ||
|
||
print('[RPA][INFO] - pack() is to deploy RPA for Python to a computer without internet') | ||
print('[RPA][INFO] - update() is to update an existing installation deployed from pack()') | ||
print('[RPA][INFO] - detecting and zipping your TagUI installation to rpa_python.zip ...') | ||
|
||
# check custom installation path | ||
if installation_dir: | ||
print('[RPA][INFO] - It was detected to use a custom directory as source for packing.') | ||
if not os.path.isdir(installation_dir + "/src"): | ||
print('[RPA][ERROR] - Your target destination is not a valid path.') | ||
sys.exit(1) | ||
|
||
# first make sure TagUI files have been downloaded and synced to latest stable delta files | ||
global _tagui_started | ||
if _tagui_started: | ||
if not close(): | ||
return False | ||
if not init(False, False): | ||
if not init(False, False, installation_dir): | ||
return False | ||
if not close(): | ||
return False | ||
|
@@ -677,11 +701,24 @@ def update(): | |
update_zip_file.write(base64.b64decode(rpa_update_zip)) | ||
update_zip_file.close() | ||
|
||
# unzip update.zip to tagui folder in user home directory | ||
# check tagui path | ||
if platform.system() == 'Windows': | ||
base_directory = os.environ['APPDATA'] + '/tagui' | ||
else: | ||
base_directory = os.path.expanduser('~') + '/.tagui' | ||
|
||
if len(sys.argv) == 2: | ||
print('[RPA][INFO] - It was detected to use a custom directory for updating.') | ||
if os.path.isdir(sys.argv[1]): | ||
if "tagui" in sys.argv[1]: | ||
base_directory = sys.argv[1] | ||
else: | ||
print('[RPA][ERROR] - Please use path with target directory name tagui.') | ||
sys.exit(1) | ||
else: | ||
print('[RPA][ERROR] - Your target destination is not a valid path.') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we not exit in this case? |
||
|
||
# unzip update.zip to tagui folder in target directory | ||
r.unzip('update.zip', base_directory + '/src') | ||
if os.path.isfile('update.zip'): os.remove('update.zip') | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
home_directory = installation_dir
is set above, thisif
block is not needed. Theif else
right above will take care of adding the appropriate name based on OS. Do note my comment below, it seems that the expectation ofinstallation_dir
is different insetup
andinit
.