Skip to content

Commit

Permalink
#297 - turbo mode option to run 10X faster
Browse files Browse the repository at this point in the history
  • Loading branch information
kensoh committed Aug 27, 2021
1 parent 7ab29c1 commit 08707d1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RPA for Python :snake:

[**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)
[**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)

>_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._
Expand Down Expand Up @@ -98,9 +98,9 @@ r.telegram(1234567890, 'Sent using your own hosted endpoint', 'https://your_endp

#### GENERAL NOTES

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).
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!).

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.
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.

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).

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

>_by default Chrome runs with visible mode, to run Chrome invisibly use init(headless_mode = True)_
>_by default RPA for Python runs at normal human speed, to run 10X faster use init(turbo_mode = True)_
#### BASIC FUNCTIONS
Function|Parameters|Purpose
Expand Down
2 changes: 1 addition & 1 deletion rpa_package/rpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Apache License 2.0, Copyright 2019 Tebel.Automation Private Limited
# https://github.com/tebelorg/RPA-Python/blob/master/LICENSE.txt
__author__ = 'Ken Soh <[email protected]>'
__version__ = '1.44.1'
__version__ = '1.45.0'

# for backward compatibility, invoke tagui.py functions to use in rpa.py
from tagui import *
4 changes: 2 additions & 2 deletions rpa_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

setup(
name='rpa',
version='1.44.1',
py_modules=['rpa'], install_requires=['tagui>=1.44.1'],
version='1.45.0',
py_modules=['rpa'], install_requires=['tagui>=1.45.0'],
author='Ken Soh',
author_email='[email protected]',
license='Apache License 2.0',
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='tagui',
version='1.44.1',
version='1.45.0',
py_modules=['tagui'],
author='Ken Soh',
author_email='[email protected]',
Expand Down
19 changes: 16 additions & 3 deletions tagui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Apache License 2.0, Copyright 2019 Tebel.Automation Private Limited
# https://github.com/tebelorg/RPA-Python/blob/master/LICENSE.txt
__author__ = 'Ken Soh <[email protected]>'
__version__ = '1.44.1'
__version__ = '1.45.0'

import subprocess
import os
Expand Down Expand Up @@ -429,7 +429,7 @@ def setup():

return True

def init(visual_automation = False, chrome_browser = True, headless_mode = False):
def init(visual_automation = False, chrome_browser = True, headless_mode = False, turbo_mode = False):
"""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, _tagui_download_directory
Expand Down Expand Up @@ -507,7 +507,20 @@ def init(visual_automation = False, chrome_browser = True, headless_mode = False
browser_option = 'chrome'
if headless_mode:
browser_option = 'headless'


# special handling for turbo mode to run 10X faster
tagui_chrome_php = tagui_directory + '/' + 'src' + '/' + 'tagui_chrome.php'
tagui_header_js = tagui_directory + '/' + 'src' + '/' + 'tagui_header.js'
tagui_sikuli_py = tagui_directory + '/' + 'src' + '/' + 'tagui.sikuli/tagui.py'
if not turbo_mode:
dump(load(tagui_chrome_php).replace('$scan_period = 10000;', '$scan_period = 100000;'), tagui_chrome_php)
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)
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)
else:
dump(load(tagui_chrome_php).replace('$scan_period = 100000;', '$scan_period = 10000;'), tagui_chrome_php)
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)
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)

# entry shell command to invoke tagui process
tagui_cmd = '"' + tagui_executable + '"' + ' rpa_python ' + browser_option

Expand Down

0 comments on commit 08707d1

Please sign in to comment.