本文整理汇总了Python中web.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: db_body
def db_body(db):
srow = DatabaseSessionStateProvider.set_msg_context(self, manager, context, sessionids, db)
if srow:
# set oauth-related extensions on context
context.session.token_type = srow.token_type
context.session.secret = srow.secret
context.session.client_secret = srow.client_secret
if srow.aux_json != None:
aux = jsonReader(srow.aux_json)
else:
aux = None
context.session.aux = aux
data_store = Oauth1aDataStore(context.session)
oauth_server = oauth.oauth.OAuthServer(data_store)
oauth_server.add_signature_method(oauth.oauth.OAuthSignatureMethod_HMAC_SHA1())
try:
oauth_server.verify_request(context.oauth_request)
except oauth.oauth.OAuthError, te:
if hasattr(te, 'message'):
web.debug(te.message)
# clear session-related state on invalid signature
context.oauth_request = None
context.client = None
context.attributes = set()
context.session = None
示例2: process
def process(self):
userSession = web.ctx.env.get('HTTP_X_CURRENT_PERSONID')
params = web.data()
jsons = simplejson.loads(params if params else '{}')
web.debug('Notify userSession: %s, %r' % (userSession, jsons))
if not userSession:
web.ctx.status = '406 Not login'
return 'not userID'
remove = True
startPage = 0
pageSize = 30
if 'keep' in jsons:
remove = jsons['keep']
if 'startPage' in jsons:
startPage = jsons['startPage']
if 'pageSize' in jsons:
pageSize = jsons['pageSize']
query = {'personID':userSession,}
if remove:
query = {'personID':userSession, 'remove':{'$ne':'1'}}
notes = MongoUtil.fetchPage('notes',query,startPage,pageSize,[('createdTime', -1)])
#web.debug('notes count:%i' % len(notes))
res = []
for note in notes:
if maturedNote(note):
if remove:
note['remove'] = '1'
MongoUtil.update('notes', note)
res.append(cleanNote(note))
web.debug('Total friend:'+ str(len(res)))
return simplejson.dumps(res)
示例3: handle_user
def handle_user(user_email, password, function_type):
try:
check_username = globs.db.query("SELECT * FROM users WHERE email=$id", vars={'id':user_email})
print "CHECK USERNAME!!!!!!!!!!!!"
print check_username
if (function_type == "register"):
if not list(check_username):
pass_hashobj = globs.PasswordHash(password)
email_hashobj = globs.PasswordHash(user_email)
user_ident = globs.db.query ("SELECT MAX(user_id) as highestId from users")[0]
if (user_ident.highestId == None):
userID = 0
else:
userID = user_ident.highestId + 1
sequence_id = globs.db.insert('users', user_id = userID, email = user_email, active = 0, password_hash = pass_hashobj.hashedpw, password_salt = pass_hashobj.salt, create_date = web.SQLLiteral("NOW()"), email_hash = email_hashobj.hashedpw, email_salt = email_hashobj.salt)
else:
print "I occur when the login username is already taken"
return False
elif (function_type == "login"):
results = check_username[0]
verified = globs.verify_user_hash(password, results)
return verified
else:
print "I shouldn't occur"
return False
except IndexError:
web.debug("AN SQL EXCEPTION HAS OCCURED")
return False
示例4: POST
def POST(self):
raw_data = web.data()
conn, cursor = oraconn()
web.header("Content-Type", "application/json")
try:
data = json.loads(raw_data)
except:
return '{"success": false, "message": "Failed to decode json string"}'
try:
data["ma"]["datum"] = datetime.datetime.strptime(data["ma"]["datum"], "%d.%m.%Y")
except:
return "Failed to parse input date"
# web.debug(data["ma"])
# update metadata
sql = "SELECT DATUM FROM DATO_HOLDINGAREA_STAFF WHERE DATUM = TO_DATE('%s', 'YYYYMMDD')" % data["ma"][
"datum"
].strftime("%Y%m%d")
web.debug(sql)
try:
cursor.execute(sql)
except Exception, e:
# web.debug(e)
return '{"success": false, "message": "Failed to query metadata in database"}'
示例5: POST
def POST(self):
data = web.data()
(_, tmp_key) = data.split('=')
web.debug(tmp_key)
key = ""
for s in tmp_key:
if s.isdigit() or s.isalpha():
key += s
if len(key) == 0:
render = web.template.render(tmpt_path, base='layout')
return render.view_video("")
else:
res = gen_formats(key)
if len(res) == 0:
ret = '<h2>Warning</h2>' + '<pre><code>'
ret += "No available video" + '<br>'
ret += '</code></pre>'
render = web.template.render(tmpt_path, base='layout')
return render.view_video(ret)
else:
ret = '<h2>Enjoy it!</h2> <br><br>'
for r in res:
tmp = r.split('_')
tmp = tmp[len(tmp)-1].replace('.mp4', '')
w, h = tmp.split('x')
ret += "<video width=\"" + w + "\" height=\"" + h + "\" controls>"
ret += "<source src=\"" + r + "\" type=\"video/mp4\">"
ret += "</video>"
ret += "<br><br><br>"
render = web.template.render(tmpt_path, base='layout')
return render.view_video(ret)
示例6: getNextCommand
def getNextCommand(self):
web.debug("current floor %d" % self._currentFloor)
web.debug("stops up:" + " - ".join(str(s) for s in self._stopsUp))
web.debug("stops down:" + " - ".join(str(s) for s in self._stopsDown))
web.debug("stops:" + " - ".join(str(s) for s in self._stopsDown))
#if the current floor is in the stops no matter the firection
if self._currentFloor in self._stops:
self._openDoors()
#checking the stops when going up
elif self._currentDirection == ElevatorEngine.DIRECTION_UP and self._currentFloor in self._stopsUp:
self._openDoors()
#checking the stops when going down
elif self._currentDirection == ElevatorEngine.DIRECTION_DOWN and self._currentFloor in self._stopsDown:
self._openDoors()
#checking in the current direction (to avoid going up/down everytime)
elif self._numberOfStopsInDirection(self._currentDirection) != 0:
self._goToCurrentDirection()
#checking the other direction
elif self._numberOfStopsInDirection(self._reverseCurrentDirection()) != 0:
self._goToCurrentReverseDirection()
##Doing the action
if self._actions.empty():
action = ElevatorEngine.ACTION_NOTHING
else:
action = self._actions.get()
web.debug("action: %s" % (action))
return action
示例7: POST
def POST(self):
x = web.input(myfile={})
web.debug(x['myfile'].filename)
#web.debug(x['myfile'].value)
web.debug(x['myfile'].file.read())
raise web.seeother('/upload')
示例8: doGet
def doGet(pathInfo, opts):
"""Does HTTP GET"""
web.debug("doGet")
# Quick /entity/search for property:value
# Looks up entity and returns
if pathInfo == "/get":
httpConfig = httpconfig.HttpConfig(web.ctx.env["DOCUMENT_ROOT"])
host = httpConfig.config["serverhost"]
port = httpConfig.config["serverport"]
prop = "urn:lri:property_type:id"
val = opts["id"]
url = 'http://%s:%s/entity/search?q={"%s":"%s"}&opts={}' % (host, port, prop, val)
web.debug("doGet: url = " + url)
r = requests.get(url)
text = None
try:
text = r.content
except AttributeError, e:
print ("doGet: No content")
try:
text = r.text
except AttributeError, e:
print ("doGet: No text")
示例9: filterPruned
def filterPruned(self, properties, key):
"""Returns data w/all keys removed but id and given properties
Works on filtered results
"""
# Get all properties
props = []
for item in self.get("response"):
for i in item[key]:
for prop in i["props"].keys():
if prop not in props:
props.append(prop)
# Keep props we want to keep
# Start with props that are never removed
# Add props passed in
keeps = self.getDefaultFilterProps()
for prop in properties:
if prop not in keeps:
keeps.append(prop)
# Remove props we want to keep from list
for keep in keeps:
try:
props.remove(keep)
except ValueError, e:
web.debug("QueryResult.filterPruned: %s: %r" % (keep, e))
示例10: GET
def GET(self):
q = web.input()
t = template.env.get_template('search.html')
f = search_form()
try:
if q.query:
results = []
user_list = []
query = q.query.split(' ')
for i in User.all():
x = util.strip_private_data(i)
if x is not None:
user_list.append(x)
for p in user_list:
for i in query:
if i in dict(p).values():
results.append(p)
return t.render(util.data(
title='Find who you\'re looking for!',
form=f,
results=results if results else None,
))
else:
web.debug('q.query doesn\'t exist and it didn\'t thow an exception!')
raise Warning('Odd, huh?')
except:
return t.render(util.data(
title='Find who you\'re looking for!',
form=f,
))
示例11: POST
def POST(self):
registroForm = FormularioRegistro()
if not registroForm.validates():
return makos.mako_template(varDep = "",titulo = self.paginaActual, formRegistro = registroForm )
else:
datos = web.input()
conn = MongoClient('mongodb://localhost:27017')
db = conn.app.usuarios
aux = web.input()
db_usuarios = {
"nombre": aux.Nombre,
"apellidos": aux.Apellidos,
"email": aux.Email,
"visa": aux.Visa,
"dia": aux.Dia,
"mes": aux.Mes,
"ano": aux.Ano,
"direccion": aux.Direccion,
"contrasena": aux.Contrasena,
"contrasena2": aux.Contrasena2,
"pago": aux.Pago,
}
db.insert(db_usuarios)
#Cerramos la conexión
conn.close()
datos = leerDatosBD()
registroForm = insertarDatosForm(datos)
web.debug(datos)
contenido = imprimirDatosBD()
return makos.mako_template(varDep = "", titulo = self.paginaActual, formRegistro = registroForm ,mensaje = "Registro exitoso", content = contenido)
示例12: parse_action_impl
def parse_action_impl(self, action, table, db):
if action == 'set_user':
username = self.qs_dict.get('username')
if not username:
set_status_code(web, 400)
return result_template('''Illegal parameters: no "username"''')
username = ''.join(username)
data = web.data()
# TODO
if debug:
web.debug('DB action=set_user, username=%s' % username)
username = db.set_user(username, {'data': data})
return username
if action == 'get_user':
username = self.qs_dict.get('username')
if not username:
set_status_code(web, 400)
return result_template('''Illegal parameters: no "username"''')
username = ''.join(username)
if debug:
web.debug('DB action=get_user, username=%s' % username)
data = db.load_user(username)
return username_data_template(username, data['data'], data['_id'])
示例13: parse_action
def parse_action(self, web, db):
web.header('Content-Type', 'text/json')
cookie = web.cookies()
login, user, token = check_login(cookie)
if not login:
set_status_code(web, 401)
return not_login_template()
qs = web.ctx.env.get('QUERY_STRING')
if not qs:
set_status_code(web, 400)
return result_template('''No parameters''')
self.qs_dict = urlparse.parse_qs(qs)
action = self.qs_dict.get('action')
table = self.qs_dict.get('table')
if not action or not table:
set_status_code(web, 400)
return result_template('''Illegal parameters: no "action" nor "table"''')
action = ''.join(action)
table = ''.join(table)
if action in self.actions:
try:
return self.parse_action_impl(action, table, db)
except Exception, e:
web.debug(str(e))
set_status_code(web, 500)
return exception_template(e)
示例14: POST
def POST(self):
x = web.input(myfile={})
name = web.debug(x['myfile'].filename) # This is the filename
web.debug(x['myfile'].value) # This is the file contents
web.debug(x['myfile'].file.read()) # Or use a filline object
form = web.input(contents=None)
return render.uploaded(name = str(name), contents = form.contents)
示例15: POST
def POST(self, cmd):
if cmd == 'total':
pts = MongoUtil.fetchPage('columbia',{}, 0, 1)
return pts.count()
if cmd == 'upload':
params = web.data();
#passTime = params.passTime
#ua = params.ua
jsonData = simplejson.loads(params)
web.debug("passTime:%r", jsonData)
ctime = jsonData.get('time')
MongoUtil.save('columbia', jsonData)
if ctime:
histGram = MongoUtil.fetch('histgram', {})
if not histGram:
histGram = {}
val = histGram.get(ctime)
if val:
++val
histGram[ctime] = val
else:
histGram[ctime] = 1
MongoUtil.update('histgram', histGram)
total = 1
beating = 1
for tm in histGram:
if tm > ctime:
total += histGram.get(tm)
beating += histGram.get(tm)
else:
total += histGram.get(tm)
return 100 * beating/total