mailcnf_tools.py
2.37 KB
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
from mysql.connector import MySQLConnection, Error
from read_dbconfig import read_db_config
import sqlite3
#import hashlib
#import tornado.ioloop
#import tornado.web
##import tornado.escape
#import tornado
import os.path
class mailcnf_tools:
def getDomainNamebyGuid(self,guid):
if guid == 0:
query = " SELECT name FROM `virtual_domains` WHERE deleted='0' "
else:
query = " SELECT name FROM `virtual_domains` WHERE group_id in ( "+guid+" ) AND deleted='0' "
try:
db_config = read_db_config()
conn = MySQLConnection(**db_config)
cursor = conn.cursor()
cursor.execute(query)
fields=cursor.fetchall()
combolist=[]
for field in fields:
combolist.append(str(field[0]))
combolist.sort()
return combolist
except Error as error:
print(error)
finally:
cursor.close()
conn.close()
def get_domain_id_by_name(self,name):
id=0
query = " SELECT id FROM `virtual_domains` WHERE `name`='"+name+"' "
try:
db_config = read_db_config()
conn = MySQLConnection(**db_config)
cursor = conn.cursor()
cursor.execute(query)
fields=cursor.fetchall()
for field in fields:
id=field[0]
except Error as error:
print(error)
finally:
cursor.close()
conn.close()
return id
def get_user_groups_srvcnf(self):
dbpath =os.path.dirname(__file__)+ "/srvcnf.sqlite3"
self.write(dbpath)
# password=self.get_argument("password")
self.write(" - ")
self.db=sqlite3.connect(dbpath)
self.dbcursor=self.db.cursor()
#sql = ' SELECT _id,groupname FROM `srvgrps` ORDER BY `_id` ASC '
sql = ' SELECT _id FROM `srvgrps` ORDER BY `_id` ASC '
# password=''
combolist=[]
for field in self.dbcursor.execute(sql):
combolist.append(str(field[0]))
combolist.sort()
return combolist
# password= row[0] #String.valueOf(c.getInt(c.getColumnIndex("password")));
#return password