conversion to tagui python object · chenpython/RPA-Python@f2e39fc · GitHub
Skip to content

Commit f2e39fc

Browse files
committed
conversion to tagui python object
1 parent 813ce25 commit f2e39fc

5 files changed

Lines changed: 53 additions & 46 deletions

File tree

.gitignore

Lines changed: 8 additions & 2 deletions

sample.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import tagui as t
2+
3+
tagui_flow = [
4+
'https://ca.yahoo.com',
5+
'type search-box as github',
6+
'show search-box',
7+
'click search-button',
8+
'snap page',
9+
'snap logo',
10+
'https://duckduckgo.com',
11+
'type search_form_input_homepage as The search engine that doesnt track you.',
12+
]
13+
14+
t.init()
15+
16+
t.send(tagui_flow[0])
17+
t.send(tagui_flow[1])
18+
t.send(tagui_flow[2])
19+
t.click("search-button")
20+
21+
t.wait(5)
22+
23+
t.send(tagui_flow[4])
24+
t.send(tagui_flow[5])
25+
t.send(tagui_flow[6])
26+
t.send(tagui_flow[7])
27+
28+
t.close()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
name='tagui',
55
version='0.0.2',
66
author='Tebel.Automation',
7-
author_email='support@tebel.org',
7+
author_email='ken@tebel.org',
88
url='https://github.com/tebelorg/TagUI-Python',
99
license='LICENSE.txt',
1010
description='Placeholder for TagUI Python package',

tagui.py

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def py23_encode(input_variable):
3939
elif python2_env(): return input_variable
4040
else: return input_variable.encode('utf-8')
4141

42-
def tagui_open():
42+
def init():
4343
# connect to tagui process by checking tagui live mode readiness
4444

4545
global process, tagui_id
@@ -69,7 +69,7 @@ def tagui_open():
6969
print('[ERROR] - ' + str(e))
7070
return False
7171

72-
def tagui_ready():
72+
def ready():
7373
# check whether tagui is ready to receive instructions
7474

7575
global process, tagui_id
@@ -96,7 +96,7 @@ def tagui_ready():
9696
print('[ERROR] - ' + str(e))
9797
return False
9898

99-
def tagui_send(tagui_instruction):
99+
def send(tagui_instruction):
100100
# send next live mode instruction to tagui for processing if tagui is ready
101101

102102
global process, tagui_id
@@ -108,7 +108,7 @@ def tagui_send(tagui_instruction):
108108
if process.poll() is not None: return False
109109

110110
# loop until tagui live mode is ready and listening for inputs
111-
while not tagui_ready(): pass
111+
while not ready(): pass
112112

113113
# echo live mode instruction, first remove quotes to be echo-safe
114114
safe_tagui_instruction = tagui_instruction.replace("'", "").replace('"','')
@@ -130,7 +130,7 @@ def tagui_send(tagui_instruction):
130130
print('[ERROR] - ' + str(e))
131131
return False
132132

133-
def tagui_close():
133+
def close():
134134
# disconnect from tagui process by sending done instruction
135135

136136
global process, tagui_id
@@ -140,7 +140,7 @@ def tagui_close():
140140
if process.poll() is not None: return False
141141

142142
# loop until tagui live mode is ready and listening for inputs
143-
while not tagui_ready(): pass
143+
while not ready(): pass
144144

145145
# send done instruction to terminate live mode and exit tagui
146146
process.stdin.write(py23_encode('echo "[tagui][finished listening]"\n'))
@@ -157,15 +157,15 @@ def tagui_close():
157157
print('[ERROR] - ' + str(e))
158158
return False
159159

160-
def tagui_present(element_identifier):
160+
def present(element_identifier):
161161
if element_identifier is None or element_identifier == '':
162162
return False
163163

164164
tagui_timeout = time.time() + 10
165165
while time.time() < tagui_timeout:
166-
tagui_send('present_result = present(\'' + element_identifier + '\')')
167-
tagui_send('dump present_result.toString() to /tmp/tagui_python.txt')
168-
tagui_send('load /tmp/tagui_python.txt to present_result')
166+
send('present_result = present(\'' + element_identifier + '\')')
167+
send('dump present_result.toString() to /tmp/tagui_python.txt')
168+
send('load /tmp/tagui_python.txt to present_result')
169169

170170
tagui_text = open('/tmp/tagui_python.txt', mode='r')
171171
element_present = tagui_text.read(); tagui_text.close()
@@ -174,51 +174,22 @@ def tagui_present(element_identifier):
174174

175175
return False
176176

177-
def tagui_click(element_identifier):
177+
def click(element_identifier):
178178
if element_identifier is None or element_identifier == '':
179179
print('[ERROR] - target missing for click()')
180180
return False
181181

182-
elif tagui_present(element_identifier) == False:
182+
elif present(element_identifier) == False:
183183
print('[ERROR] - cannot find ' + element_identifier)
184184
return False
185185

186-
elif tagui_send('click ' + element_identifier) == False:
186+
elif send('click ' + element_identifier) == False:
187187
return False
188188

189189
else:
190190
return True
191191

192-
def tagui_wait(delay_in_seconds):
192+
def wait(delay_in_seconds):
193193
if delay_in_seconds is None: delay_in_seconds = 5.0
194194
time.sleep(float(delay_in_seconds))
195195
return True
196-
197-
# testing code for development
198-
199-
tagui_flow = [
200-
'https://ca.yahoo.com',
201-
'type search-box as github',
202-
'show search-box',
203-
'click search-button',
204-
'snap page',
205-
'snap logo',
206-
'https://duckduckgo.com',
207-
'type search_form_input_homepage as The search engine that doesnt track you.',
208-
]
209-
210-
tagui_open()
211-
212-
tagui_send(tagui_flow[0])
213-
tagui_send(tagui_flow[1])
214-
tagui_send(tagui_flow[2])
215-
tagui_click("search-button")
216-
217-
tagui_wait(5)
218-
219-
tagui_send(tagui_flow[4])
220-
tagui_send(tagui_flow[5])
221-
tagui_send(tagui_flow[6])
222-
tagui_send(tagui_flow[7])
223-
224-
tagui_close()

tagui_python

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)