-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocalconfig.py
43 lines (32 loc) · 1.29 KB
/
localconfig.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
import os
import sys
if sys.version_info[0] == 3:
import configparser
else:
import ConfigParser as configparser
""" hold local configuration """
class credentiales():
shared_path = os.getenv('SPAMSHARED')
def __init__(self):
""" get the curent user data from spamconfig file """
import os
config = configparser.ConfigParser()
username = os.getenv('USER')
path_to_config = os.path.join(self.shared_path, 'spamconfig.ini')
result = config.read(path_to_config)
if not sys.version_info[0] == 3:
config = {'DEFAULT': dict(config.items('DEFAULT')), username : dict(config.items(username))}
if result == []:
self.user = None
self.paswd = None
self.host = None
self.repository = None
self.adminname = None
self.adminpassword = None
else:
self.host = config['DEFAULT']['host']
self.repository = config['DEFAULT']['repository']
self.adminname = config['DEFAULT']['adminname']
self.adminpassword = config['DEFAULT']['adminpassword']
self.user = config[username]['username']
self.paswd = config[username]['password']