Em Quarta-feira 11 Fevereiro 2009, às 05:02:16, Wes James escreveu: > Massimo, > > I just downloaded trunk and tried starting as normal and get: > > WARNING:root:unable to import dbhash > default applications appear to be installed already > web2py Enterprise Web Framework > Created by Massimo Di Pierro, Copyright 2007-2009 > Version 1.56.2 (2009-02-10 23:57:30) > Database drivers available: SQLite3, Postgre > please visit: > http://127.0.0.1:6667 > use "kill -SIGTERM 711" to shutdown the web2py server > Traceback (most recent call last): > File "./web2py.py", line 14, in <module> > start() > File "/opt/1web2py/gluon/widget.py", line 825, in start > path=options.folder) > File "/opt/1web2py/gluon/main.py", line 508, in __init__ > log_filename, profiler_filename, web2py_path=path), > File "/opt/1web2py/gluon/main.py", line 425, in appfactory > if os.path.exists(profilerfilename): > File > "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pos >ixpath.py", line 171, in exists > st = os.stat(path) > TypeError: coercing to Unicode: need string or buffer, NoneType found > > but if i start with the command below it works fine.
Hi Wes, Try with the attached patch. PS: Massimo, im sending to you too, so if that is alright we can put it in trunk. > -wj > > On Tue, Feb 10, 2009 at 11:01 PM, mdipierro <mdipie...@cs.depaul.edu> wrote: > > New in trunk (highly experimental) > > > > web2py.py -F profiler.log > > > > will log all requests with profile details in profiler.log. This makes > > thing slower. > > I am not sure this is the proper way of doing it. Any feed back will > > be appreciated. > > > > It should be trivial to build an app (or an admin page) to browse and > > search the profiler.log file if it exists. > > > > Massimo > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---
=== modified file 'gluon/main.py' --- gluon/main.py 2009-02-11 05:56:18 +0000 +++ gluon/main.py 2009-02-11 09:53:25 +0000 @@ -422,26 +422,38 @@ logfilename='httpsever.log', profilerfilename='profiler.log', web2py_path=web2py_path): - if os.path.exists(profilerfilename): - os.unlink(profilerfilename) - locker=thread.allocate_lock() + def app_with_logging(environ, responder): + """ """ + environ['web2py_path'] = web2py_path status_headers = [] - + def responder2(s, h): + """ """ + status_headers.append(s) status_headers.append(h) + return responder(s, h) time_in = time.time() ret=[0] + if not profilerfilename: ret[0] = wsgiapp(environ, responder2) else: + if os.path.exists(profilerfilename): + os.unlink(profilerfilename) + + locker=thread.allocate_lock() locker.acquire() + cProfile.runctx('ret[0] = wsgiapp(environ, responder2)', - globals(), locals(), profilerfilename+'.tmp') + globals(), + locals(), + profilerfilename+'.tmp') + stat = pstats.Stats(profilerfilename+'.tmp') stat.stream = cStringIO.StringIO() stat.strip_dirs().sort_stats(-1).print_stats() @@ -451,23 +463,25 @@ ('='*60, environ['PATH_INFO'], '='*60, profile_out)) profile_file.close() locker.release() + try: - line = '%s, %s, %s, %s, %s, %s, %f\n' % ( - environ['REMOTE_ADDR'], - datetime.datetime.today().strftime('%Y-%m-%d %H:%M:%S' - ), - environ['REQUEST_METHOD'], - environ['PATH_INFO'].replace(',', '%2C'), - environ['SERVER_PROTOCOL'], - (status_headers[0])[:3], - time.time() - time_in, - ) + text = '%s, %s, %s, %s, %s, %s, %f\n' + today = datetime.datetime.today() + line = msg % (environ['REMOTE_ADDR'], + today.strftime('%Y-%m-%d %H:%M:%S'), + environ['REQUEST_METHOD'], + environ['PATH_INFO'].replace(',', '%2C'), + environ['SERVER_PROTOCOL'], + (status_headers[0])[:3], + time.time() - time_in) + if logfilename: open(logfilename, 'a').write(line) else: sys.stdout.write(line) except: pass + return ret[0] return app_with_logging @@ -475,23 +489,18 @@ class HttpServer(object): - def __init__( - self, - ip='127.0.0.1', - port=8000, - password='', - pid_filename='httpserver.pid', - log_filename='httpserver.log', - profiler_filename=None, - ssl_certificate=None, - ssl_private_key=None, - numthreads=10, - server_name=None, - request_queue_size=5, - timeout=10, - shutdown_timeout=5, - path=web2py_path, - ): + def __init__(self, ip='127.0.0.1', port=8000, password='', + pid_filename='httpserver.pid', + log_filename='httpserver.log', + profiler_filename='profiler.log', + ssl_certificate=None, + ssl_private_key=None, + numthreads=10, + server_name=None, + request_queue_size=5, + timeout=10, + shutdown_timeout=5, + path=web2py_path): """ starts the web server. """ @@ -502,6 +511,7 @@ server_name = socket.gethostname() logging.info('starting web server...') from contrib.wsgihooks import ExecuteOnCompletion2, callback + self.server = wsgiserver.CherryPyWSGIServer( (ip, port), appfactory(ExecuteOnCompletion2(wsgibase, callback),