-
Notifications
You must be signed in to change notification settings - Fork 1
/
configfile.py
60 lines (42 loc) · 1.34 KB
/
configfile.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
56
57
58
#!/usr/bin/python
#databasetype = 'sqlite:///'
'postgresql://name:pass@ip/dbname'
from os.path import expanduser, exists, dirname
from os import makedirs
from PyQt4.QtGui import QMessageBox
def popErrorMessage(text):
msgBox = QMessageBox();
msgBox.setText(text);
msgBox.exec();
#'postgres:salakala://localhost:5433/vetapp'
_databasename = 'vetapp'
_username = 'vetapp_user'
_pass = 'salakala' #change this to unique + TODO: crypt password
_ip = '192.168.1.68'
_port = '5432'
_bill_directory = '~/bill/'
_debug_val = True
def getVersion():
return 0.1200
def logDEBUG(_from, _msg):
if _debug_val :
print("DEBUG: from: " + str(_from) + ': msg:' + str(_msg))
def logERROR(_from, _msg):
print("ERROR: from: " + str(_from) + ': msd:' + str(_msg))
def isDBDebugOn():
return False
def getDBName():
return _databasename;
def getBillPath():
path = expanduser(_bill_directory)
if not exists(dirname(path)):
makedirs(dirname(path))
return path
def genDBString(db_type = 'sqlite'):
if db_type is 'sqlite':
return 'sqlite:///' + _databasename
elif db_type is 'postgresql':
return 'postgresql://' + _username + ':' + _pass + '@' + _ip +':' + _port + '/' + _databasename
else:
print("ERROR: database type is incorrect use sqlite or postgresql")
return None