-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlitterrobot_get_activity.py
executable file
·55 lines (44 loc) · 1.39 KB
/
litterrobot_get_activity.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2022 Opensource ICT Solutions B.V.
# https://oicts.com
#
#version: 1.0.0
#date: 25-12-2022
#
import asyncio
from datetime import datetime
import json
import time
import re
import sys
from datetime import datetime
from pylitterbot import Account
# Set email and password for initial authentication.
username = sys.argv[1]
password = sys.argv[2]
# Declare search variable
date = datetime.today().strftime('%Y-%m-%d')
clean_cycle_complete = r"{}[A-Za-z0-9:.+\s]+Clean Cycle Complete".format(date)
drawer_full = r"{}[A-Za-z0-9:.+\s]+Drawer[\sA-Za-z]+Full".format(date)
async def main():
# Create an account.
account = Account()
try:
# Connect to the API and load robots.
await account.connect(username=username, password=password, load_robots=True)
# Print robots associated with account.
print("")
for robot in account.robots:
rawact = await robot.get_activity_history()
result_string = ','.join(str(v) for v in rawact)
ccc = re.findall(clean_cycle_complete,result_string)
df = re.findall(drawer_full,result_string)
# Create JSON for sending to Zabbix
print("{\"data\":[{\"CCC\":",len(ccc),",\"DF\":",len(df),"}]}")
finally:
# Disconnect from the API.
await account.disconnect()
if __name__ == "__main__":
asyncio.run(main())