Skip to content

Commit 08707d1

Browse files
committed
tebelorg#297 - turbo mode option to run 10X faster
1 parent 7ab29c1 commit 08707d1

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# RPA for Python :snake:
22

3-
[**v1.44**](https://github.com/tebelorg/RPA-Python/releases) | [**Use Cases**](#use-cases) | [**API Reference**](#api-reference) | [**About & Credits**](#about--credits) | [**PyCon Video**](https://www.youtube.com/watch?v=F2aQKWx_EAE) | [**Run on Cloud**](https://colab.research.google.com/drive/13bQO6G_hzE1teX35a3NZ4T5K-ICFFdB5?usp=sharing) | [**Telegram Chat**](https://t.me/rpa_chat)
3+
[**v1.45**](https://github.com/tebelorg/RPA-Python/releases) | [**Use Cases**](#use-cases) | [**API Reference**](#api-reference) | [**About & Credits**](#about--credits) | [**PyCon Video**](https://www.youtube.com/watch?v=F2aQKWx_EAE) | [**Run on Cloud**](https://colab.research.google.com/drive/13bQO6G_hzE1teX35a3NZ4T5K-ICFFdB5?usp=sharing) | [**Telegram Chat**](https://t.me/rpa_chat)
44

55
>_This tool was previously known as TagUI for Python. [More details](https://github.com/tebelorg/RPA-Python/issues/100) on the name change, which is backward compatible so existing scripts written with `import tagui as t` and `t.function()` will still work._
66
@@ -98,9 +98,9 @@ r.telegram(1234567890, 'Sent using your own hosted endpoint', 'https://your_endp
9898

9999
#### GENERAL NOTES
100100

101-
See [sample Python script](https://github.com/tebelorg/RPA-Python/blob/master/sample.py), the [RPA Challenge solution](https://github.com/tebelorg/RPA-Python/issues/120#issuecomment-610518196), and [RedMart groceries example](https://github.com/tebelorg/RPA-Python/issues/24). To send a Telegram app notification, [simply look up @rpapybot](https://github.com/tebelorg/RPA-Python/issues/281#issue-942803794) to allow receiving messages. To automate Chrome browser invisibly, use [headless mode](https://github.com/tebelorg/RPA-Python#core-functions). To run 20-30X faster, without normal UI interaction delays, [see this hack](https://github.com/tebelorg/RPA-Python/issues/120#issuecomment-610532082).
101+
See [sample Python script](https://github.com/tebelorg/RPA-Python/blob/master/sample.py), the [RPA Challenge solution](https://github.com/tebelorg/RPA-Python/issues/120#issuecomment-610518196), and [RedMart groceries example](https://github.com/tebelorg/RPA-Python/issues/24). To send a Telegram app notification, [simply look up @rpapybot](https://github.com/tebelorg/RPA-Python/issues/281#issue-942803794) to allow receiving messages. To automate Chrome browser invisibly, use [headless mode](https://github.com/tebelorg/RPA-Python#core-functions). To run 10X faster instead of normal human speed, use [turbo mode](https://github.com/tebelorg/RPA-Python/issues/297) (read the caveats!).
102102

103-
You can even run on your phone browser [using this Colab notebook](https://colab.research.google.com/drive/13bQO6G_hzE1teX35a3NZ4T5K-ICFFdB5?usp=sharing) (eg datascraping in headless mode). By design this package has [enterprise security](https://github.com/kelaberetiv/TagUI/blob/master/README.md#enterprise-security-by-design) and you can install, update and use it [without the internet](https://github.com/tebelorg/RPA-Python#core-functions). You can fully [control error handling](https://github.com/tebelorg/RPA-Python/issues/269) if you wish to, eg snapshot of missing element or posting to custom API endpoint.
103+
You can even run on your phone browser [using this Colab notebook](https://colab.research.google.com/drive/13bQO6G_hzE1teX35a3NZ4T5K-ICFFdB5?usp=sharing) (eg datascraping with up to 5 Colab sessions). By design this package has [enterprise security](https://github.com/kelaberetiv/TagUI/blob/master/README.md#enterprise-security-by-design) and you can install, update and use it [without the internet](https://github.com/tebelorg/RPA-Python#core-functions). You can fully [control error handling](https://github.com/tebelorg/RPA-Python/issues/269) if you wish to, eg snapshot of missing element or posting to custom API endpoint.
104104

105105
For fine-grained control on web browser file download location, use [download_location()](https://github.com/tebelorg/RPA-Python/issues/279#issuecomment-877749880). For overriding parent folder location to install and invoke TagUI ([forked version](https://github.com/tebelorg/TagUI) optimised for this package), use [tagui_location()](https://github.com/tebelorg/RPA-Python/issues/257#issuecomment-846602776).
106106

@@ -122,7 +122,7 @@ pack()||for deploying package without internet
122122
update()||for updating package without internet
123123
debug()|True or False|print & log debug info to rpa_python.log
124124

125-
>_by default Chrome runs with visible mode, to run Chrome invisibly use init(headless_mode = True)_
125+
>_by default RPA for Python runs at normal human speed, to run 10X faster use init(turbo_mode = True)_
126126
127127
#### BASIC FUNCTIONS
128128
Function|Parameters|Purpose

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.44.1'
5+
__version__ = '1.45.0'
66

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

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.44.1',
6-
py_modules=['rpa'], install_requires=['tagui>=1.44.1'],
5+
version='1.45.0',
6+
py_modules=['rpa'], install_requires=['tagui>=1.45.0'],
77
author='Ken Soh',
88
author_email='[email protected]',
99
license='Apache License 2.0',

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.44.1',
5+
version='1.45.0',
66
py_modules=['tagui'],
77
author='Ken Soh',
88
author_email='[email protected]',

tagui.py

+16-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.44.1'
5+
__version__ = '1.45.0'
66

77
import subprocess
88
import os
@@ -429,7 +429,7 @@ def setup():
429429

430430
return True
431431

432-
def init(visual_automation = False, chrome_browser = True, headless_mode = False):
432+
def init(visual_automation = False, chrome_browser = True, headless_mode = False, turbo_mode = False):
433433
"""start and connect to tagui process by checking tagui live mode readiness"""
434434

435435
global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome, _tagui_init_directory, _tagui_download_directory
@@ -507,7 +507,20 @@ def init(visual_automation = False, chrome_browser = True, headless_mode = False
507507
browser_option = 'chrome'
508508
if headless_mode:
509509
browser_option = 'headless'
510-
510+
511+
# special handling for turbo mode to run 10X faster
512+
tagui_chrome_php = tagui_directory + '/' + 'src' + '/' + 'tagui_chrome.php'
513+
tagui_header_js = tagui_directory + '/' + 'src' + '/' + 'tagui_header.js'
514+
tagui_sikuli_py = tagui_directory + '/' + 'src' + '/' + 'tagui.sikuli/tagui.py'
515+
if not turbo_mode:
516+
dump(load(tagui_chrome_php).replace('$scan_period = 10000;', '$scan_period = 100000;'), tagui_chrome_php)
517+
dump(load(tagui_header_js).replace('function sleep(ms) {ms *= 0.1; //', 'function sleep(ms) { //').replace("chrome_step('Input.insertText',{text: value});};", "for (var character = 0, length = value.length; character < length; character++) {\nchrome_step('Input.dispatchKeyEvent',{type: 'char', text: value[character]});}};"), tagui_header_js)
518+
dump(load(tagui_sikuli_py).replace('scan_period = 0.05\n\n# teleport mouse instead of moving to target\nSettings.MoveMouseDelay = 0', 'scan_period = 0.5'), tagui_sikuli_py)
519+
else:
520+
dump(load(tagui_chrome_php).replace('$scan_period = 100000;', '$scan_period = 10000;'), tagui_chrome_php)
521+
dump(load(tagui_header_js).replace('function sleep(ms) { //', 'function sleep(ms) {ms *= 0.1; //').replace("for (var character = 0, length = value.length; character < length; character++) {\nchrome_step('Input.dispatchKeyEvent',{type: 'char', text: value[character]});}};", "chrome_step('Input.insertText',{text: value});};"), tagui_header_js)
522+
dump(load(tagui_sikuli_py).replace('scan_period = 0.5', 'scan_period = 0.05\n\n# teleport mouse instead of moving to target\nSettings.MoveMouseDelay = 0'), tagui_sikuli_py)
523+
511524
# entry shell command to invoke tagui process
512525
tagui_cmd = '"' + tagui_executable + '"' + ' rpa_python ' + browser_option
513526

0 commit comments

Comments
 (0)