forked from fullstack-sake/legym_fk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
57 lines (42 loc) · 1.32 KB
/
main.py
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
import sys
import legym
def automation_for_debug():
if len(sys.argv) != 2:
raise Exception("arguments not provided")
username, password, distance, activity = sys.argv[1].split("#")
user = legym.login(username, password)
print(f"{user=}")
running_result = user.running(float(distance))
print(f"{running_result=}")
register_result = user.register(name=activity)
print(f"{register_result=}")
sign_result = user.sign()
print(f"{sign_result=}")
def automation_for_workflow():
if len(sys.argv) != 2:
raise Exception("arguments not provided")
username, password, distance, activity = sys.argv[1].split("#")
print("Login...", end="")
user = legym.login(username, password)
print("success")
print("Running...", end="")
actual_distance, success = user.running(float(distance))
if success:
print(f"{actual_distance} km")
else:
print("failed")
print("Registering...", end="")
_, success, _ = user.register(name=activity)
if success:
print("success")
else:
print("failed")
print("Signing...", end="")
results = user.sign()
for result in results:
if result[1]:
print("success")
else:
print("failed")
if __name__ == "__main__":
automation_for_workflow()