本文整理汇总了Python中common.database.Database.write_users方法的典型用法代码示例。如果您正苦于以下问题:Python Database.write_users方法的具体用法?Python Database.write_users怎么用?Python Database.write_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.database.Database
的用法示例。
在下文中一共展示了Database.write_users方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from common.database import Database [as 别名]
# 或者: from common.database.Database import write_users [as 别名]
def run(self):
# load the configuration
# Create default root user
db = Database()
abspath = path.abspath(path.join(path.dirname(__file__), path.pardir))
configfile = abspath + '/conf/smsgw.conf'
cfg = SmsConfig(configfile)
wisglobals.wisid = cfg.getvalue('wisid', 'nowisid', 'wis')
wisglobals.wisipaddress = cfg.getvalue('ipaddress', '127.0.0.1', 'wis')
wisglobals.wisport = cfg.getvalue('port', '7777', 'wis')
wisglobals.cleanupseconds = cfg.getvalue('cleanupseconds', '86400', 'wis')
wisglobals.ldapserver = cfg.getvalue('ldapserver', None, 'wis')
wisglobals.ldapbasedn = cfg.getvalue('ldapbasedn', None, 'wis')
wisglobals.ldapenabled = cfg.getvalue('ldapenabled', None, 'wis')
ldapusers = cfg.getvalue('ldapusers', '[]', 'wis')
wisglobals.ldapusers = json.loads(ldapusers)
wisglobals.ldapusers = [item.lower() for item in wisglobals.ldapusers]
smsgwglobals.wislogger.debug("WIS:" + str(wisglobals.ldapusers))
password = cfg.getvalue('password', '20778ba41791cdc8ac54b4f1dab8cf7602a81f256cbeb9e782263e8bb00e01794d47651351e5873f9ac82868ede75aa6719160e624f02bba4df1f94324025058', 'wis')
salt = cfg.getvalue('salt', 'changeme', 'wis')
# write the default user on startup
db.write_users('root', password, salt)
# check if ssl is enabled
wisglobals.sslenabled = cfg.getvalue('sslenabled', None, 'wis')
wisglobals.sslcertificate = cfg.getvalue('sslcertificate', None, 'wis')
wisglobals.sslprivatekey = cfg.getvalue('sslprivatekey', None, 'wis')
wisglobals.sslcertificatechain = cfg.getvalue('sslcertificatechain', None, 'wis')
smsgwglobals.wislogger.debug("WIS: SSL " + str(wisglobals.sslenabled))
if wisglobals.sslenabled is not None and 'true' in wisglobals.sslenabled.lower():
smsgwglobals.wislogger.debug("WIS: STARTING SSL")
cherrypy.config.update({'server.ssl_module':
'builtin'})
cherrypy.config.update({'server.ssl_certificate':
wisglobals.sslcertificate})
cherrypy.config.update({'server.ssl_private_key':
wisglobals.sslprivatekey})
if wisglobals.sslcertificatechain is not None:
cherrypy.config.update({'server.ssl_certificate_chain':
wisglobals.sslcertificatechain})
cherrypy.config.update({'server.socket_host':
wisglobals.wisipaddress})
cherrypy.config.update({'server.socket_port':
int(wisglobals.wisport)})
cherrypy.quickstart(Root(), '/smsgateway',
'wis-web.conf')
示例2: run
# 需要导入模块: from common.database import Database [as 别名]
# 或者: from common.database.Database import write_users [as 别名]
def run(self):
# load the configuration
# Create default root user
db = Database()
abspath = path.abspath(path.join(path.dirname(__file__), path.pardir))
# store the abspath in globals for easier handling
wisglobals.smsgatewayabspath = abspath
configfile = abspath + '/conf/smsgw.conf'
cfg = SmsConfig(configfile)
readme = open(abspath + '/README.md', 'r')
readmecontent = readme.read()
version = re.compile(r"(?<=## Version)(.*v.\..*)", re.S).findall(readmecontent)
if version:
wisglobals.version = version[0].strip('\n')
smsgwglobals.wislogger.debug("WIS: Version: " + str(wisglobals.version))
wisglobals.wisid = cfg.getvalue('wisid', 'nowisid', 'wis')
wisglobals.wisipaddress = cfg.getvalue('ipaddress', '127.0.0.1', 'wis')
wisglobals.wisport = cfg.getvalue('port', '7777', 'wis')
wisglobals.cleanupseconds = cfg.getvalue('cleanupseconds', '86400', 'wis')
wisglobals.validusernameregex = cfg.getvalue('validusernameregex', '([^a-zA-Z0-9])', 'wis')
wisglobals.validusernamelength = cfg.getvalue('validusernamelength', 30, 'wis')
wisglobals.ldapserver = cfg.getvalue('ldapserver', None, 'wis')
wisglobals.ldapbasedn = cfg.getvalue('ldapbasedn', None, 'wis')
wisglobals.ldapenabled = cfg.getvalue('ldapenabled', None, 'wis')
ldapusers = cfg.getvalue('ldapusers', '[]', 'wis')
wisglobals.ldapusers = json.loads(ldapusers)
wisglobals.ldapusers = [item.lower() for item in wisglobals.ldapusers]
smsgwglobals.wislogger.debug("WIS:" + str(wisglobals.ldapusers))
password = cfg.getvalue('password', '20778ba41791cdc8ac54b4f1dab8cf7602a81f256cbeb9e782263e8bb00e01794d47651351e5873f9ac82868ede75aa6719160e624f02bba4df1f94324025058', 'wis')
salt = cfg.getvalue('salt', 'changeme', 'wis')
# write the default user on startup
db.write_users('root', password, salt)
# read pissendtimeout
wisglobals.pissendtimeout = int(cfg.getvalue('pissendtimeout', '20', 'wis'))
# check if ssl is enabled
wisglobals.sslenabled = cfg.getvalue('sslenabled', None, 'wis')
wisglobals.sslcertificate = cfg.getvalue('sslcertificate', None, 'wis')
wisglobals.sslprivatekey = cfg.getvalue('sslprivatekey', None, 'wis')
wisglobals.sslcertificatechain = cfg.getvalue('sslcertificatechain', None, 'wis')
smsgwglobals.wislogger.debug("WIS: SSL " + str(wisglobals.sslenabled))
if wisglobals.sslenabled is not None and 'true' in wisglobals.sslenabled.lower():
smsgwglobals.wislogger.debug("WIS: STARTING SSL")
cherrypy.config.update({'server.ssl_module':
'builtin'})
cherrypy.config.update({'server.ssl_certificate':
wisglobals.sslcertificate})
cherrypy.config.update({'server.ssl_private_key':
wisglobals.sslprivatekey})
if wisglobals.sslcertificatechain is not None:
cherrypy.config.update({'server.ssl_certificate_chain':
wisglobals.sslcertificatechain})
cherrypy.config.update({'server.socket_host':
wisglobals.wisipaddress})
cherrypy.config.update({'server.socket_port':
int(wisglobals.wisport)})
cherrypy.tree.mount(StatsLogstash(), '/smsgateway/api/stats/logstash', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}})
cherrypy.quickstart(Root(), '/smsgateway',
'wis-web.conf')