fixed issue 728, bug in languages, thanks pgergo

This commit is contained in:
Massimo Di Pierro
2012-03-26 11:17:20 -05:00
parent bc4def632c
commit ba93692ed4
84 changed files with 222 additions and 137 deletions
+1
View File
@@ -261,3 +261,4 @@ if __name__=='__main__':
+1
View File
@@ -241,3 +241,4 @@ if __name__=='__main__':
+1
View File
@@ -3,3 +3,4 @@
+1
View File
@@ -192,3 +192,4 @@ if __name__ == "__main__":
+1
View File
@@ -3908,3 +3908,4 @@ def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, refer
+1
View File
@@ -53,3 +53,4 @@ class MemcacheClient(Client):
+1
View File
@@ -88,3 +88,4 @@ def autoretry_datastore_timeouts(attempts=5.0, interval=0.1, exponent=2.0):
+1
View File
@@ -65,3 +65,4 @@ def pdf_from_html(html):
+1
View File
@@ -17,3 +17,4 @@ def button(merchant_id="123456789012345",
+1
View File
@@ -7,3 +7,4 @@ from gluon.dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, driv
+1
View File
@@ -909,3 +909,4 @@ if __name__ == '__main__':
+1
View File
@@ -125,3 +125,4 @@ if __name__ == "__main__":
+1
View File
@@ -178,3 +178,4 @@ if __name__ == '__main__':
+48 -47
View File
@@ -60,13 +60,13 @@ class Qdb(bdb.Bdb):
request = self.pipe.recv()
if request.get("method") == 'run':
return None
response = {'version': '1.1', 'id': request.get('id'),
'result': None,
response = {'version': '1.1', 'id': request.get('id'),
'result': None,
'error': None}
try:
# dispatch message (JSON RPC like)
method = getattr(self, request['method'])
response['result'] = method.__call__(*request['args'],
response['result'] = method.__call__(*request['args'],
**request.get('kwargs', {}))
except Exception, e:
response['error'] = {'code': 0, 'message': str(e)}
@@ -101,7 +101,7 @@ class Qdb(bdb.Bdb):
return
if self.stop_here(frame):
self.interaction(frame, None)
def user_line(self, frame):
"""This function is called when we stop or break at this line."""
if self._wait_for_mainpyfile:
@@ -126,8 +126,8 @@ class Qdb(bdb.Bdb):
trace = traceback.extract_tb(trace)
title = traceback.format_exception_only(extype, exvalue)[0]
# send an Exception notification
msg = {'method': 'exception',
'args': (title, extype.__name__, exvalue, trace, msg),
msg = {'method': 'exception',
'args': (title, extype.__name__, exvalue, trace, msg),
'id': None}
self.pipe.send(msg)
self.interaction(frame, info)
@@ -156,7 +156,7 @@ class Qdb(bdb.Bdb):
"imp" : imp, # need for run
})
# avoid stopping before we reach the main script
# avoid stopping before we reach the main script
self._wait_for_mainpyfile = 1
self.mainpyfile = self.canonic(filename)
self._user_requested_quit = 0
@@ -180,8 +180,8 @@ class Qdb(bdb.Bdb):
if code.co_name != "?":
message = "%s: %s()" % (message, code.co_name)
# wait user events
self.waiting = True
# wait user events
self.waiting = True
self.frame = frame
try:
while self.waiting:
@@ -270,7 +270,7 @@ class Qdb(bdb.Bdb):
else:
first = arg
elif not self._lineno:
first = max(1, self.frame.f_lineno - 5)
first = max(1, self.frame.f_lineno - 5)
else:
first = self._lineno + 1
if last is None:
@@ -302,7 +302,7 @@ class Qdb(bdb.Bdb):
if self.breaks: # There's at least one
for bp in bdb.Breakpoint.bpbynumber:
if bp:
breaks.append((bp.number, bp.file, bp.line,
breaks.append((bp.number, bp.file, bp.line,
bp.temporary, bp.enabled, bp.hits, bp.cond, ))
return breaks
@@ -367,13 +367,13 @@ class Qdb(bdb.Bdb):
return []
else:
return dir(obj)
def get_call_tip(self, expression):
"Return list of auto-completion options for expression"
try:
obj = self.do_eval(expression)
except Exception, e:
return ('', '', str(e))
return ('', '', str(e))
else:
name = ''
try:
@@ -479,7 +479,7 @@ class Qdb(bdb.Bdb):
"Replacement for stdout.write()"
msg = {'method': 'write', 'args': (text, ), 'id': None}
self.pipe.send(msg)
def writelines(self, l):
map(self.write, l)
@@ -492,7 +492,7 @@ class Qdb(bdb.Bdb):
class QueuePipe(object):
"Simulated pipe for threads (using two queues)"
def __init__(self, name, in_queue, out_queue):
self.__name = name
self.in_queue = in_queue
@@ -516,10 +516,10 @@ class RPCError(RuntimeError):
"Remote Error (not user exception)"
pass
class Frontend(object):
"Qdb generic Frontend interface"
def __init__(self, pipe):
self.i = 1
self.pipe = pipe
@@ -546,7 +546,7 @@ class Frontend(object):
def interaction(self, filename, lineno, line, *kwargs):
raise NotImplementedError
def exception(self, title, extype, exvalue, trace, request):
"Show a user_exception"
raise NotImplementedError
@@ -554,7 +554,7 @@ class Frontend(object):
def write(self, text):
"Console output (print)"
raise NotImplementedError
def readline(self, text):
"Console input/rawinput"
raise NotImplementedError
@@ -566,10 +566,10 @@ class Frontend(object):
# wait for a message...
request = self.recv()
else:
# process an asyncronus notification received earlier
# process an asyncronus notification received earlier
request = self.notifies.pop(0)
return self.process_message(request)
def process_message(self, request):
if request:
result = None
@@ -588,8 +588,8 @@ class Frontend(object):
elif request.get('method') == 'readline':
result = self.readline()
if result:
response = {'version': '1.1', 'id': request.get('id'),
'result': result,
response = {'version': '1.1', 'id': request.get('id'),
'result': result,
'error': None}
self.send(response)
return True
@@ -619,20 +619,20 @@ class Frontend(object):
def do_step(self, arg=None):
"Execute the current line, stop at the first possible occasion"
self.call('do_step')
def do_next(self, arg=None):
"Execute the current line, do not stop at function calls"
self.call('do_next')
def do_continue(self, arg=None):
def do_continue(self, arg=None):
"Continue execution, only stop when a breakpoint is encountered."
self.call('do_continue')
def do_return(self, arg=None):
def do_return(self, arg=None):
"Continue execution until the current function returns"
self.call('do_return')
def do_jump(self, arg):
def do_jump(self, arg):
"Set the next line that will be executed."
res = self.call('do_jump', arg)
print res
@@ -644,7 +644,7 @@ class Frontend(object):
def do_quit(self, arg=None):
"Quit from the debugger. The program being executed is aborted."
self.call('do_quit')
def do_eval(self, expr):
"Inspect the value of the expression"
return self.call('do_eval', expr)
@@ -672,11 +672,11 @@ class Frontend(object):
def do_clear_file_breakpoints(self, filename):
"Remove all breakpoints at filename"
self.call('do_clear_breakpoints', filename, lineno)
def do_list_breakpoint(self):
"List all breakpoints"
return self.call('do_list_breakpoint')
def do_exec(self, statement):
return self.call('do_exec', statement)
@@ -685,7 +685,7 @@ class Frontend(object):
def get_call_tip(self, expression):
return self.call('get_call_tip', expression)
def interrupt(self):
"Immediately stop at the first possible occasion (outside interaction)"
# this is a notification!, do not expect a response
@@ -695,7 +695,7 @@ class Frontend(object):
def set_burst(self, value):
req = {'method': 'set_burst', 'args': (value, )}
self.send(req)
def set_params(self, params):
req = {'method': 'set_params', 'args': (params, )}
self.send(req)
@@ -703,13 +703,13 @@ class Frontend(object):
class Cli(Frontend, cmd.Cmd):
"Qdb Front-end command line interface"
def __init__(self, pipe, completekey='tab', stdin=None, stdout=None, skip=None):
cmd.Cmd.__init__(self, completekey, stdin, stdout)
Frontend.__init__(self, pipe)
# redefine Frontend methods:
def run(self):
while 1:
try:
@@ -731,18 +731,18 @@ class Cli(Frontend, cmd.Cmd):
def write(self, text):
print text,
def readline(self):
return raw_input()
def postcmd(self, stop, line):
return not line.startswith("h") # stop
do_h = cmd.Cmd.do_help
do_s = Frontend.do_step
do_n = Frontend.do_next
do_c = Frontend.do_continue
do_c = Frontend.do_continue
do_r = Frontend.do_return
do_j = Frontend.do_jump
do_q = Frontend.do_quit
@@ -750,12 +750,12 @@ class Cli(Frontend, cmd.Cmd):
def do_eval(self, args):
"Inspect the value of the expression"
print Frontend.do_eval(self, args)
def do_list(self, args):
"List source code for the current file"
lines = Frontend.do_list(self, eval(args, {}, {}) if args else None)
self.print_lines(lines)
def do_where(self, args):
"Print a stack trace, with the most recent frame at the bottom."
lines = Frontend.do_where(self)
@@ -831,7 +831,7 @@ def test():
front_conn = QueuePipe("parent", parent_queue, child_queue)
child_conn = QueuePipe("child", child_queue, parent_queue)
p = Thread(target=f, args=(child_conn,))
p.start()
import time
@@ -844,7 +844,7 @@ def test():
qdb = Test(front_conn)
time.sleep(5)
while 1:
print "running..."
Frontend.run(qdb)
@@ -856,7 +856,7 @@ def test():
def connect(host="localhost", port=6000, authkey='secret password'):
"Connect to a running debugger backend"
address = (host, port)
from multiprocessing.connection import Client
@@ -872,7 +872,7 @@ def connect(host="localhost", port=6000, authkey='secret password'):
def main(host='localhost', port=6000, authkey='secret password'):
"Debug a script and accept a remote frontend"
if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
print "usage: pdb.py scriptfile [arg] ..."
sys.exit(2)
@@ -916,7 +916,7 @@ qdb = None
def set_trace(host='localhost', port=6000, authkey='secret password'):
"Simplified interface to debug running programs"
global qdb, listener, conn
from multiprocessing.connection import Listener
# only create it if not currently instantiated
if not qdb:
@@ -940,7 +940,7 @@ def quit():
conn.close()
conn = None
if listener:
listener.close()
listener.close()
listener = None
if __name__ == '__main__':
@@ -962,3 +962,4 @@ if __name__ == '__main__':
import qdb
qdb.main(**kwargs)
+7 -6
View File
@@ -67,7 +67,7 @@ class RedisClient(object):
}}
else:
self.storage = self.meta_storage[app]
self.r_server = redis.Redis(host=host, port=port, db=self.db)
def __call__(self, key, f, time_expire=300):
@@ -96,7 +96,7 @@ class RedisClient(object):
return value
except ConnectionError:
return self.retry_call(key, f, time_expire)
def retry_call(self, key, f, time_expire):
self.RETRIES += 1
if self.RETRIES <= self.MAX_RETRIES:
@@ -107,19 +107,19 @@ class RedisClient(object):
else:
self.RETRIES = 0
raise ConnectionError , 'Redis instance is unavailable at %s' % (self.server)
def increment(self, key, value=1, time_expire=300):
try:
newKey = self.__keyFormat__(key)
obj = self.r_server.get(newKey)
obj = self.r_server.get(newKey)
if obj:
return self.r_server.incr(newKey, value)
return self.r_server.incr(newKey, value)
else:
self.r_server.setex(newKey, value, time_expire)
return value
except ConnectionError:
return self.retry_increment(key, value, time_expire)
def retry_increment(self, key, value, time_expire):
self.RETRIES += 1
if self.RETRIES <= self.MAX_RETRIES:
@@ -165,3 +165,4 @@ class RedisClient(object):
key.replace(' ', '_'))
+1
View File
@@ -590,3 +590,4 @@ if __name__ == '__main__':
+1
View File
@@ -268,3 +268,4 @@ if __name__=='__main__':
+1
View File
@@ -149,3 +149,4 @@ if __name__ == "__main__":
client = ServerProxy(location, verbose='--verbose' in sys.argv,)
print client.add(1, 2)
+1
View File
@@ -114,3 +114,4 @@ def sms_email(number,provider):
+1
View File
@@ -264,3 +264,4 @@ if __name__ == '__main__':
+1
View File
@@ -64,3 +64,4 @@ if __name__=='__main__':
print 'refunded',s['refunded']
+1
View File
@@ -245,3 +245,4 @@ class TaskBarIcon:
+12 -11
View File
@@ -14,10 +14,10 @@ class TimeCollector(object):
'''Private utility function to clean up this common calculation.'''
return self.scores[index1].stamp - self.scores[index2].stamp
def getReportItems(self, orderByCost=True):
'''Returns a list of dicts. Each dict has
start (ms),
end (ms),
delta (ms),
'''Returns a list of dicts. Each dict has
start (ms),
end (ms),
delta (ms),
perc (%),
tag (str)
'''
@@ -37,9 +37,9 @@ class TimeCollector(object):
delta = delta * 1000,
perc = perc,
tag = self.scores[i].tag
)
)
)
if orderByCost:
if orderByCost:
data.sort(key=lambda x: x['perc'], reverse=True)
return data
def getReportLines(self, orderByCost=True):
@@ -49,20 +49,20 @@ class TimeCollector(object):
data = self.getReportItems(orderByCost)
headerTemplate = '%10s | %10s | %10s | %11s | %-30s'
headerData = ('Start(ms)', 'End(ms)', 'Delta(ms)', 'Time Cost',
'Description')
'Description')
bodyTemplate = '%(start)10.0f | %(end)10.0f | %(delta)10.0f |' \
+ ' %(perc)10.0f%% | %(tag)-30s'
+ ' %(perc)10.0f%% | %(tag)-30s'
return [headerTemplate % headerData] + [bodyTemplate % d for d in data]
def getReportText(self, **kwargs):
return '\n'.join(self.getReportLines(**kwargs))
def restart(self):
self.scores = [Score(tag='start',stamp=time.clock())]
if __name__=='__main__':
print('')
print('Testing:')
print('')
# First create the collector
t = TimeCollector()
x = [i for i in range(1000)]
@@ -85,7 +85,7 @@ if __name__=='__main__':
# And once again report results
print('')
print(t.getReportText())
t.restart()
t.restart()
for y in range(1, 200, 20):
x = [i for i in range(10000)*y]
t.addStamp('Iteration when y = ' + str(y))
@@ -93,3 +93,4 @@ if __name__=='__main__':
print('')
# You can turn off ordering of results
print(t.getReportText(orderByCost=False))
+1
View File
@@ -518,3 +518,4 @@ class mobilize(object):
return self.func()