-
Notifications
You must be signed in to change notification settings - Fork 1
/
fetch_all.py
executable file
·47 lines (39 loc) · 1.22 KB
/
fetch_all.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
#!/usr/bin/env python3
import amwater
import duqlight
import colgaspa
from configparser import ConfigParser
import os
import sqlite3
import cache
import storage
config = ConfigParser()
config.read('config.ini')
download_path = config['storage']['download_path']
cache.init(download_path)
storage.init(download_path)
def print_results(results):
for result in results:
account = result['account']
usage = result['usage']
bills = result['bills']
print(f"Account {account}")
account_dbid = storage.insert_account(account)
if account_dbid is None or account_dbid == 0:
print("!!!!!!!!!!!!!!!")
break
print(f"Account DBID: {account_dbid}")
print("Usage:")
for usage in usage:
storage.insert_usage(account_dbid, usage)
print(usage)
print("Bills:")
for bill in bills:
storage.insert_bill(account_dbid, bill)
print(bill)
results = amwater.get_usage(config['amwater'], download_path)
print_results(results)
results = duqlight.get_usage(config['duqlight'], download_path)
print_results(results)
results = colgaspa.get_usage(config['colgaspa'], download_path)
print_results(results)