forked from mgckind/desaccess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount.py
39 lines (35 loc) · 1.18 KB
/
count.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
import tornado.auth
import tornado.escape
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import Settings
import cx_Oracle
import os
import yaml
from version import __version__
dbConfig0 = Settings.dbConfig()
app_log = Settings.app_log
class BaseHandler(tornado.web.RequestHandler):
def get_current_user(self):
return self.get_secure_cookie("usera")
class CountHandler(BaseHandler):
def get(self):
kwargs = {'host': dbConfig0.host, 'port': dbConfig0.port, 'service_name': 'desdr'}
dsn = cx_Oracle.makedsn(**kwargs)
with open('config/user_manager.yaml', 'r') as cfile:
conf = yaml.load(cfile)['oracle']
user_manager = conf['user']
pass_manager = conf['passwd']
del conf
dbh = cx_Oracle.connect(user_manager, pass_manager, dsn=dsn)
cursor = dbh.cursor()
try:
cc = cursor.execute('select count(*) from des_admin.des_users').fetchone()
except:
cc = ('')
cursor.close()
dbh.close()
self.render('stats.html', version=__version__, count=cc[0]-49)
#self.write('<br><br><h1>Count = {}</h1>'.format(cc[0]-49))