本文整理汇总了Python中debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: timer_callback
def timer_callback( self ):
debug('timer_callback timeout_id: '+str(self.timeout_id))
self.remove_timeout()
self.update_profile()
self.mainloop()
#commented by merlin 1991 advice self.mainloop()
debug('end of timer_callback')
示例2: load
def load( manipulator, filename ):
try:
dom = minidom.parse( filename )
except IOError:
print "Error. Can't read", filename
return False
manipulator.items = []
for item in dom.getElementsByTagName('item'):
i = None
if item.hasAttribute('figure'):
i = Figure( item.getAttribute('figure').encode() )
elif item.hasAttribute('text'):
i = TextItem( item.getAttribute('text').encode() )
pos = item.getAttribute('pos').encode().split(',')
pos = map( float, pos )
i.position.setTranspose( pos[0],pos[1], 1 )
i.refreshTransform()
manipulator.items.append( i )
dom.unlink()
refnames.reset()
debug('save', 'loaded from', filename )
return True
示例3: paint
def paint( self ):
"Draws and flips bg and rings"
surface = self.getSurface()
# Erase
self.erase()
# Draw Field Items
self.drawItems()
# Export Frame as bitmap
if Enduring.exportMode:
filename = 'frame_%s_%05d.bmp' % ( strDate(), Enduring.exportModeFrame )
Enduring.exportModeFrame += 1
pygame.image.save( surface, filename )
debug(1, 'Frame saved:', filename )
# Draw Toolbars
for t in self.toolbars:
t.draw( surface, self.size )
# Flip screen
self.flip()
示例4: def2c
def def2c(self, ssad, prio = 19, implicit_global=False):
if ssad.type == 's' and ssad.parent_def != None:
debug(CODE, 6, 'found',ssad,'to be member of', ssad.parent_def)
s = self.expr2c(ssad.parent_def, deref_auto = False) + '.' + 'mem_' + zhex(ssad.addr - ssad.parent_def.ops[0])
self.add_struct_member(ssad, ssad.parent_def.ops[0], ssad.parent_def.ops[1])
elif isinstance(ssad.addr, int):
if ssad.dessa_name == None:
raise InternalError('no dessa_name in ' + str(ssad) + '(' + repr(ssad) + '), defined in ' + str(ssad.define_statement))
s = Symbol(ssad.addr, ssad.dessa_name).name
else:
assert(ssad.addr == None)
assert(ssad.dessa_name != None)
s = ssad.dessa_name
if not implicit_global and ssad.type[0] == 'M' and not ssad.is_dessa_tmp and s not in self.declare_globals:
self.declare_globals[s] = ssatype2c(ssad.data_type)
elif (ssad.type[0] != 'M' or ssad.is_dessa_tmp) and s not in self.declare_locals and ssad.parent_def == None:
ctype = ssatype2c(ssad.data_type)
if ssad.type == 's':
self.declare_locals[s] = (ctype, '__sp[' + str(ssad.addr) + ']')
else:
self.declare_locals[s] = (ctype, None)
if ssad.type == 's' and ssad.addr in [1,2] and arch.stacked_return_address:
current_statement.add_comment('XXX: stacked return address accessed')
if ssad.data_type.type == SSAType.COMPOUND:
s = '&' + s
return s
示例5: parse
def parse(self, start, comefrom = None, blockified = None):
self.start_st = start
basic_blocks[start] = self
if comefrom != None:
self.comefrom += [comefrom]
curst = start
debug(BLOCK, 3, 'startblockat', curst)
while len(curst.next) == 1 and len(list(curst.next)[0].comefrom) == 1 and curst.op != ssa.ENDLESS_LOOP and not curst.next[0] in basic_blocks:
curst = list(curst.next)[0]
debug(BLOCK, 3, 'endblockat', curst)
self.end_st = curst
if curst.op != ssa.ENDLESS_LOOP:
for i in curst.next:
if i in basic_blocks:
basic_blocks[i].comefrom += [self]
self.next += [basic_blocks[i]]
else:
nb = BasicBlock()
nb.parse(i, self, blockified)
basic_blocks[i] = nb
self.next += [nb]
# Workaround for "Bxx 0": A basic block should not have the same
# successor multiple times.
final_next = []
for i in self.next:
if i not in final_next:
final_next += [i]
self.next = final_next
示例6: get_group_from_xy
def get_group_from_xy(self, x, y):
debug('TaskBar._get_group_from_xy: x={0} y={1}'.format(x, y))
for g in self.groups.values():
debug3('g: {}'.format(g))
if x >= g['x'] and x <= g['right'] and y >= g['y'] and y <= g['bottom']:
debug3('get_group_from_xy: {}'.format(g))
return g
示例7: _draw_taskbar
def _draw_taskbar(self):
debug('TaskBar._draw_taskbar')
if not self.x:
self.x=self.canvas.winfo_x()
if not self.y:
self.y=self.canvas.winfo_y()
if not self.width:
self.width=self.canvas.winfo_reqwidth()
if not self.height:
self.height=self.canvas.winfo_reqheight()
if not self.bordersize:
self.bordersize=1
group_count=len(self.groups)
if self.width/group_count < 200:
self.group_width=200
else:
self.group_width=int(self.width/group_count)
self.group_width=200
self.canvas.delete("taskbar")
object_id=self.canvas.create_rectangle(self.x, self.y, self.x+self.width, self.y+self.height, fill='white', outline='black', tags="taskbar")
self.canvas.tag_lower(object_id)
self._draw_groups()
self._update_bottom()
示例8: _string
def _string(self, func, size=0):
'''Used to pretty print the stack. func should be a function that
will format a number. If size is nonzero, only display that many
items. Note: we make a copy of the stack so we can't possibly
mess it up.
'''
s = self.stack[:]
if not size or size > len(s): size = max(1, len(s))
s.reverse()
s = s[:size]
s.reverse()
if debug():
fmt = "%%(vtype)s | %%(index) %dd: %%(value)s" % (2+int(log10(max(len(s),1))))
else:
fmt = "%%(index) %dd: %%(value)s" % (2+int(log10(max(len(s),1))))
m = []
lens = len(s)
for i in xrange(lens):
if debug():
vtype = repr(s[i])[:16]
vtype += ' '*(16-len(vtype))
m.append(fmt % { 'vtype': vtype, 'index': size - i, 'value': func(s[i], i==(lens-1))})
else:
m.append(fmt % {'index': size - i, 'value': func(s[i], i==(lens-1))})
s = '\n'.join(m)
# Special treatment for the first four registers: name them x, y,
# z, t (as is done for HP calculators).
if 0:
s = s.replace(" 0: ", " x: ")
s = s.replace(" 1: ", " y: ")
s = s.replace(" 2: ", " z: ")
s = s.replace(" 3: ", " t: ")
return s
示例9: _getAttrs
def _getAttrs(self, soup):
try:
soup.find('span', 'label-heading').extract()
except:
debug('Unable to remove .label-heading')
values = soup.renderContents() \
.replace('<span class="label-heading">Some things about me:</span>', '') \
.strip().split('<br />')
attrs = {
'category': '',
'style': '',
'type': '',
'country': '',
'brewer': '',
'alcohol content (abv)': ''
}
for pair in values:
if pair == '':
continue
try:
key, value = pair.replace('<span class="label">', '').split('</span>')
key = key.replace(':', '').strip().lower()
value = value.strip().title()
attrs[key] = value
except:
debug('Problem extracting key from: %s in %s' % (pair, values))
return attrs
示例10: __init__
def __init__(self, id, context_type = 'playlist', auto_fetch = True):
self.id = id
super(Cache_track, self).__init__(qobuz.path.cache,
'track',
self.id, True)
self.set_cache_refresh(qobuz.addon.getSetting('cache_duration_track'))
debug(self, "Cache duration: " + str(self.cache_refresh))
示例11: setSpeakLanguage
def setSpeakLanguage( nNumLang = getDefaultSpeakLanguage(), proxyTts = False ):
"change the tts speak language"
print( "SetSpeakLanguage to: %d" % nNumLang );
if( not proxyTts ):
proxyTts = naoqitools.myGetProxy( "ALTextToSpeech" );
if( not proxyTts ):
debug( "ERR: setSpeakLanguage: can't connect to tts" );
return;
try:
if( nNumLang == constants.LANG_FR ):
proxyTts.loadVoicePreference( "NaoOfficialVoiceFrench" );
elif ( nNumLang == constants.LANG_EN ):
proxyTts.loadVoicePreference( "NaoOfficialVoiceEnglish" );
elif ( nNumLang == constants.LANG_SP ):
proxyTts.loadVoicePreference( "NaoOfficialVoiceSpanish" );
elif ( nNumLang == constants.LANG_IT ):
proxyTts.loadVoicePreference( "NaoOfficialVoiceItalian" );
elif ( nNumLang == constants.LANG_GE ):
proxyTts.loadVoicePreference( "NaoOfficialVoiceGerman" );
elif ( nNumLang == constants.LANG_CH ):
proxyTts.loadVoicePreference( "NaoOfficialVoiceChinese" );
elif ( nNumLang == constants.LANG_PO ):
proxyTts.loadVoicePreference( "NaoOfficialVoicePolish" );
elif ( nNumLang == constants.LANG_KO ):
proxyTts.loadVoicePreference( "NaoOfficialVoiceKorean" );
else:
proxyTts.loadVoicePreference( "NaoOfficialVoiceEnglish" );
except:
print( "ERR: setSpeakLanguage: loadVoicePreference error" );
示例12: runMachine
def runMachine(name):
global debugging
print("Starting machine: " + str(name) + "...")
run = ["docker", "run", "-d"]
# get the machine info
this_machine = mach.all_machines[name]
# append port info
for port in this_machine["ports"]:
nex = str(nextPort(port))
run.append("-p=" + nex + ":" + str(portNum(port)))
debug("next port for " + port + " is: " + nex, FINEST)
# append environment info
for env in this_machine["env"]:
run.append("-e=" + env[0] + ":" + env[-1])
# append volume info
for vol in this_machine["vol"]:
run.append("-v=" + vol[0] + ":" + vol[-1])
# append name
run.append('--name="' + name + "-" + nextRunNumber(name) + '"')
run.append("build/" + name)
if not debugging:
child = subprocess.Popen(run, stdout=subprocess.PIPE)
print("Machine " + str(name) + " started")
else:
debug_msg = "\tdocker run"
for item in run[2:]:
debug_msg += "\n\t\t" + item
debug(debug_msg)
示例13: definePort
def definePort(name, base):
if str(base) not in port_infinities:
port_infinities[str(base)] = infiniteNumbers(10000 + base, 100)
new_port = {"inf": port_infinities[str(base)], "basePort": base}
all_ports[name] = new_port
debug('Created port "' + name + '" with base "' + str(base) + "'", FINE)
return new_port
示例14: guess_entry_points
def guess_entry_points(text, org, manual_entries):
# find all "MOV R12, SP" and "PUSH {..., lr}"
mov_r12_sp = []
push_lr = []
for i in range(0, len(text) >> 2):
insn = struct.unpack('<I', text[i:i+4])[0]
if insn == 0xe1a0c00d:
mov_r12_sp += [i]
elif insn & 0xffffc000 == 0xe92d4000:
push_lr += [i]
debug(TRACE, 3, 'found', len(mov_r12_sp), 'times MOV R12, SP;', len(push_lr), 'times PUSH {...lr}')
# if there are a lot of "MOV R12, SP"'s, we assume the code has been
# compiled with frame pointer and functions start at the MOV; otherwise,
# functions start at the PUSH
if len(mov_r12_sp) > len(push_lr) / 2:
entry_points = mov_r12_sp
else:
entry_points = push_lr
new_entry_points = []
for i in entry_points:
i += org
if not i in manual_entries:
new_entry_points.append(i)
return new_entry_points
示例15: _edit_select_all
def _edit_select_all(action, window):
debug(DEBUG_COMMANDS)
active_view = window.get_active_view()
if warn_if_equal(active_view, None):
return
active_view.select_all()
active_view.grab_focus()