本文整理匯總了Python中db.DB.loadSystemSettings方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.loadSystemSettings方法的具體用法?Python DB.loadSystemSettings怎麽用?Python DB.loadSystemSettings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類db.DB
的用法示例。
在下文中一共展示了DB.loadSystemSettings方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: isLoginRequired
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import loadSystemSettings [as 別名]
def isLoginRequired():
db = DB()
loginRequired = False
for line in db.loadSystemSettings():
if line['setting_name'] == 'username':
loginRequired = True
break
return loginRequired
示例2: setting
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import loadSystemSettings [as 別名]
def setting():
db = DB()
action = request.args.get('action')
if action == 'read':
settings = {}
# print 'READ SYSTEM CONF:'
for line in db.loadSystemSettings():
if line['setting_name'] == 'password':
continue
settings.update({ line['setting_name']: line['setting_value'] })
response = json.dumps({ 'setting': [settings] })
# print response
elif action == 'update':
if request.method == 'POST':
jsonCredentials = request.form['setting']
params = json.loads(jsonCredentials)
response = json.dumps({ 'success': 'false' })
if 'username' in params:
credentialUsername = params['username']
db.updateSystemSettings('username', credentialUsername)
response = json.dumps({ 'success': 'true' })
if 'password' in params:
credentialPassword = params['password']
db.updateSystemSettings('password', credentialPassword)
response = json.dumps({ 'success': 'true' })
if 'valve_amount' in params:
valveAmount = int(params['valve_amount'])
actualValves = db.getValveCount()
if actualValves <= valveAmount:
db.updateSystemSettings('valve_amount', valveAmount)
response = json.dumps({ 'success': 'true' })
else:
response = json.dumps({ 'success': 'false', 'message': 'There are more valves set up than you want to allow. Please remove some of them first.' })
elif action == 'destroy':
if request.method == 'POST':
jsonCredentials = request.form['setting']
params = json.loads(jsonCredentials)
# print params
#for setting in params:
for key, value in params.items():
# print 'checking: %s / %s' % (key, value)
if value == '-DELETE-':
db.deleteSystemSetting(key)
response = json.dumps({ 'success': 'true' })
return response
示例3: actionLogin
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import loadSystemSettings [as 別名]
def actionLogin():
if request.method == 'POST':
params = request.get_json();
requestUsername = params['username']
requestPassword = params['password']
systemCredentials = {}
db = DB()
for line in db.loadSystemSettings():
if line['setting_name'] == 'username':
systemCredentials['username'] = line['setting_value']
if line['setting_name'] == 'password':
systemCredentials['password'] = line['setting_value']
if len(systemCredentials) == 2 and requestUsername == systemCredentials['username'] and requestPassword == systemCredentials['password']:
print 'Login successful'
token = generateAuthToken(request, systemCredentials, 600)
response = json.dumps({ 'success': 'true', 'token': token })
else:
print 'Login failed'
response = json.dumps({ 'success': 'false', 'message': 'Invalid login.' })
return response