-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.py
More file actions
65 lines (41 loc) · 1.22 KB
/
run.py
File metadata and controls
65 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
import sys
from workflow import Workflow3
from workflow.background import is_running, run_in_background
import os
def string_from_count(c):
"""Returns a fancy string to show in the workflow from the count item"""
blue = "\\U0001F535\\U0000FE0F"
white = "\\U000026AA\\U0000FE0F"
black = "\\U000026AB\\U0000FE0F"
ret = black + black + black + black + black + white + black + black + black + black + black
mod = 2 * (5 - (c % 5))
return ret.decode('unicode_escape')[mod:][0:10]
def main(wf):
#Check if first time
try:
count = int(os.environ['count'])
first_time = False
except:
count = 0
first_time = True
if first_time:
wf.rerun = 0.5
wf.add_item('Starting background process')
run_in_background('bg', ['/usr/bin/python', wf.workflowfile('bg.py')])
else:
if is_running('bg'):
"""Update status"""
wf.rerun = 0.5
wf.add_item("Background process is running",string_from_count(count))
count += 1
else:
"""Last case"""
data = wf.stored_data('bg_result')
wf.add_item("Process Finished","Result: " + data, icon="Checkmark.png")
wf.setvar('count',count)
wf.send_feedback()
if __name__ == '__main__':
wf = Workflow3()
log = wf.logger
sys.exit(wf.run(main))