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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from datetime import datetime
import configparser
import os
import platform
cp = configparser.ConfigParser()
try:
cp.readfp(open('settings.ini', "r+"))
except Exception as err:
print("Error reading settings.ini:" + str(err))
log("LOG PARSE ERROR", str(err))
exit()
try:
MANDRILL_PRODUCTION = cp.get('CONFIG', 'MANDRILL_PRODUCTION')
SIGN_ENABLE = cp.get('CONFIG', 'SIGN_ENABLE')
JSIGNPDF_PATH = cp.get('CONFIG', 'JSIGNPDF_PATH')
BCC = cp.get('CONFIG', 'BCC')
REPLY_TO = cp.get('CONFIG', 'REPLY_TO')
FROM_EMAIL = cp.get('CONFIG', 'FROM_EMAIL')
FROM_NAME = cp.get('CONFIG', 'FROM_NAME')
SIGNING_DOMAIN = cp.get('CONFIG', 'SIGNING_DOMAIN')
DEV_LOGS_EMAIL = cp.get('CONFIG', 'DEV_LOGS_EMAIL')
CRYPTOKEY_PASSWORD = cp.get('CONFIG', 'CRYPTOKEY_PASSWORD')
PAGE_SIZE = cp.get('CONFIG', 'PAGE_SIZE')
AUTHTOKEN = cp.get('ZOHO', 'AUTHTOKEN')
ORGANIZATION_ID = cp.get('ZOHO', 'ORGANIZATION_ID')
MANDRILL_TEST_KEY = cp.get('MANDRILL', 'MANDRILL_TEST_KEY')
MANDRILL_PRODUCTION_KEY = cp.get('MANDRILL', 'MANDRILL_PRODUCTION_KEY')
MANDRILL_TEMPLATE_NAME = cp.get('MANDRILL', 'MANDRILL_TEMPLATE_NAME')
except:
print("Settings file seems to have been corrupted. Contact Support")
exit()
querystring = {"authtoken": AUTHTOKEN,
"organization_id": ORGANIZATION_ID, 'status': 'draft'}
OUTPUT_FILE = os.path.join("data", "output.csv")
headers = {
'cache-control': "no-cache",
'Accepts': 'application/json'
}
INVOICES_API = "https://books.zoho.com/api/v3/invoices".strip()
CONTACTS_API = "https://books.zoho.com/api/v3/contacts/".strip()
MARK_AS_SENT = "https://books.zoho.com/api/v3/invoices/%s/status/sent"
date_mode = None
start_date = None
end_date = None
# setup log file, download directory and decide start and end dates for
# script run
SCRIPT_START_TIME = datetime.now()
year = str(SCRIPT_START_TIME.year)
month = str(SCRIPT_START_TIME.month).zfill(2)
day = str(SCRIPT_START_TIME.day).zfill(2)
hour = str(SCRIPT_START_TIME.hour).zfill(2)
minute = str(SCRIPT_START_TIME.minute).zfill(2)
second = str(SCRIPT_START_TIME.second).zfill(2)
# open log file
NOW_DATE_TIME = '-'.join((year, month, day)) + "_" + \
'-'.join((hour, minute, second))
TODAY_DATE = '-'.join((year, month, day))
BEG_MONTH_DATE = '-'.join((year, month, "01"))
if(MANDRILL_PRODUCTION.lower() == "false"):
MANDRILL_CONFIG = False
elif(MANDRILL_PRODUCTION.lower() == "true"):
MANDRILL_CONFIG = True
else:
print("Invalid state of mandrill in settings.ini")
exit()
if(SIGN_ENABLE.lower() == "false"):
SIGN_ENABLE = False
elif(SIGN_ENABLE.lower() == "true"):
SIGN_ENABLE = True
else:
print("Invalid state of SIGN_ENABLEing in settings.ini")
exit()
def check_platform():
PLATFORM = platform.system().lower().strip()
if PLATFORM != "linux" and PLATFORM != "windows":
return None
else:
return PLATFORM