Skip to content

Commit 7da09d4

Browse files
committed
#279 - add download_location()
1 parent 6884738 commit 7da09d4

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

Diff for: rpa_package/rpa.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Apache License 2.0, Copyright 2019 Tebel.Automation Private Limited
33
# https://github.com/tebelorg/RPA-Python/blob/master/LICENSE.txt
44
__author__ = 'Ken Soh <[email protected]>'
5-
__version__ = '1.40.0'
5+
__version__ = '1.41.0'
66

77
# for backward compatibility, invoke tagui.py functions to use in rpa.py
88
from tagui import *

Diff for: rpa_package/setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
setup(
44
name='rpa',
5-
version='1.40.0',
6-
py_modules=['rpa'], install_requires=['tagui>=1.40.0'],
5+
version='1.41.0',
6+
py_modules=['rpa'], install_requires=['tagui>=1.41.0'],
77
author='Ken Soh',
88
author_email='[email protected]',
99
license='Apache License 2.0',

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

Diff for: tagui.py

+32-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Apache License 2.0, Copyright 2019 Tebel.Automation Private Limited
33
# https://github.com/tebelorg/RPA-Python/blob/master/LICENSE.txt
44
__author__ = 'Ken Soh <[email protected]>'
5-
__version__ = '1.40.0'
5+
__version__ = '1.41.0'
66

77
import subprocess
88
import os
@@ -37,6 +37,9 @@
3737
# to track the original directory when init() was called
3838
_tagui_init_directory = ''
3939

40+
# to track file download directory for web browser
41+
_tagui_download_directory = ''
42+
4043
# to track location of TagUI (default user home folder)
4144
if platform.system() == 'Windows':
4245
_tagui_location = os.environ['APPDATA']
@@ -429,7 +432,7 @@ def setup():
429432
def init(visual_automation = False, chrome_browser = True, headless_mode = False):
430433
"""start and connect to tagui process by checking tagui live mode readiness"""
431434

432-
global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome, _tagui_init_directory
435+
global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome, _tagui_init_directory, _tagui_download_directory
433436

434437
if _tagui_started:
435438
print('[RPA][ERROR] - use close() before using init() again')
@@ -564,7 +567,10 @@ def init(visual_automation = False, chrome_browser = True, headless_mode = False
564567
_tagui_id = _tagui_id + 1
565568

566569
# set variable to track original directory when init() was called
567-
_tagui_init_directory = os.getcwd()
570+
_tagui_init_directory = os.getcwd()
571+
572+
# set variable to track file download directory for web browser
573+
_tagui_download_directory = os.getcwd()
568574

569575
return True
570576

@@ -1670,3 +1676,26 @@ def clipboard(text_to_put = None):
16701676

16711677
else:
16721678
return True
1679+
1680+
def download_location(location = None):
1681+
global _tagui_download_directory
1682+
if not _started():
1683+
print('[RPA][ERROR] - use init() before using download_location()')
1684+
return False
1685+
1686+
if location is None:
1687+
return _tagui_download_directory
1688+
1689+
if "'" in location:
1690+
print('[RPA][ERROR] - single quote in location not supported here')
1691+
return False
1692+
1693+
if platform.system() == 'Windows':
1694+
location = location.replace('/', '\\')
1695+
1696+
if not send("chrome_step('Page.setDownloadBehavior',{behavior: 'allow', downloadPath: '" + location + "'});"):
1697+
return False
1698+
1699+
else:
1700+
_tagui_download_directory = location
1701+
return True

0 commit comments

Comments
 (0)