Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
datalux
GitHub Repository: datalux/osintgram
Path: blob/master/src/config.py
271 views
1
import os
2
import configparser
3
import sys
4
5
from src import printcolors as pc
6
7
try:
8
config = configparser.ConfigParser(interpolation=None)
9
config.read("config/credentials.ini")
10
except FileNotFoundError:
11
pc.printout('Error: file "config/credentials.ini" not found!\n', pc.RED)
12
sys.exit(0)
13
except Exception as e:
14
pc.printout("Error: {}\n".format(e), pc.RED)
15
sys.exit(0)
16
17
def getUsername():
18
try:
19
20
username = config["Credentials"]["username"]
21
22
if username == '':
23
pc.printout('Error: "username" field cannot be blank in "config/credentials.ini"\n', pc.RED)
24
sys.exit(0)
25
26
return username
27
except KeyError:
28
pc.printout('Error: missing "username" field in "config/credentials.ini"\n', pc.RED)
29
sys.exit(0)
30
31
def getPassword():
32
try:
33
34
password = config["Credentials"]["password"]
35
36
if password == '':
37
pc.printout('Error: "password" field cannot be blank in "config/credentials.ini"\n', pc.RED)
38
sys.exit(0)
39
40
return password
41
except KeyError:
42
pc.printout('Error: missing "password" field in "config/credentials.ini"\n', pc.RED)
43
sys.exit(0)
44
45
46
def getHikerToken():
47
return config["Credentials"].get("hikerapi_token") or os.getenv("HIKERAPI_TOKEN")
48
49