本文整理汇总了Python中Debug类的典型用法代码示例。如果您正苦于以下问题:Python Debug类的具体用法?Python Debug怎么用?Python Debug使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Debug类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createGraphs
def createGraphs (program, basepath):
import UDrawGraph, ICFGs, Trees, IPGs
Debug.debugMessage("Creating data structures", 1)
for cfg in program.getCFGs():
functionName = cfg.getName()
UDrawGraph.makeUdrawFile (cfg, basepath, "%s.%s" % (functionName, "cfg"))
predomTree = Trees.Dominators(cfg, cfg.getEntryID())
reverseg = cfg.getReverseCFG()
postdomTree = Trees.Dominators(reverseg, reverseg.getEntryID())
UDrawGraph.makeUdrawFile (predomTree, basepath, "%s.%s" % (functionName, "pre"))
UDrawGraph.makeUdrawFile (postdomTree, basepath, "%s.%s" % (functionName, "post"))
icfg = ICFGs.ICFG(cfg)
icfg.setEntryID()
icfg.setExitID()
icfg.addExitEntryEdge()
program.addICFG(icfg)
UDrawGraph.makeUdrawFile (icfg, basepath, "%s.%s" % (functionName, "icfg"))
lnt = Trees.LoopNests(icfg, icfg.getEntryID())
program.addLNT(lnt)
UDrawGraph.makeUdrawFile (lnt, basepath, "%s.%s" % (functionName, "lnt"))
ipg = IPGs.IPG(icfg, lnt)
program.addIPG(ipg)
icfg.addBranchDivergenceEdges(lnt)
ipg.updateWithBranchDivergentPaths()
UDrawGraph.makeUdrawFile (icfg, basepath, "%s.%s" % (functionName, "icfg"))
UDrawGraph.makeUdrawFile (ipg, basepath, "%s.%s" % (functionName, "ipg"))
示例2: splitTraces
def splitTraces (program, generatedFiles):
Debug.debugMessage("Splitting traces", 1)
allWarpTraces = {}
for outfile in generatedFiles:
traceFound = False
newKernel = False
firstTuple = None
lastTuple = None
Debug.debugMessage("Analysing file '%s'" % outfile, 1)
with open(outfile, 'r') as f:
for line in f:
if line.startswith("NEW KERNEL"):
traceFound = True
if firstTuple:
analyseHWMT(program, firstTuple, lastTuple)
firstTuple = None
continue
if traceFound:
SMAndWarp, timingTuple = getLineOfTimingTrace(line)
print
w = getWarp (allWarpTraces, SMAndWarp)
w.appendToTrace(timingTuple)
lastTuple = timingTuple
if not firstTuple:
firstTuple = timingTuple
analyseHWMT(program, firstTuple, lastTuple)
return allWarpTraces
示例3: checkCommandLineForAction
def checkCommandLineForAction ():
# Check that the user has passed the correct options
if opts.tests > 0:
cudaBinary = args[0]
if not os.path.exists(cudaBinary):
Debug.exitMessage("The argument '%s' does not exist" % cudaBinary)
elif not os.path.isfile(cudaBinary):
Debug.exitMessage("The argument '%s' is not a file" % cudaBinary)
elif not os.access(cudaBinary, os.X_OK):
Debug.exitMessage("The argument '%s' does not have execute permission" % cudaBinary)
# Get the filename of the binary without the path
basename = os.path.basename(cudaBinary)
basepath = os.path.abspath(os.path.dirname(cudaBinary))
generatedFiles = runCUDAKernel(basepath)
doAnalysis(generatedFiles, basename, basepath)
elif len(args) > 0:
for arg in args:
if not arg.endswith(gpgpuFileExt):
Debug.exitMessage("Each file must end with a '%s' suffix. You passed '%s'." % (gpgpuFileExt, arg))
basename = os.path.splitext(os.path.basename(args[0]))[0]
basepath = os.path.abspath(os.path.dirname(args[0]))
doAnalysis(args, basename, basepath)
else:
Debug.exitMessage("""There are two ways to run this script:
1) Either pass a CUDA binary as an argument and the number of times you want to run the kernel with the -T option; or
2) Pass a number of files that were generated by GPGPU-sim from a previous testing run""")
示例4: _add_new_wall_pic
def _add_new_wall_pic(self, pic=None):
"""
Adds a new wall picture to the node definition
Launches a dialog, and validates and posts the entered information
to the repository for the creation of a new wall picture for the
node that is being edited
"""
# Display the dialogue
results = pic
if results is None:
results = NodePictureDialog(self)
results = results._entries
item_id = results["name"]
item = results
# Extract the return values
try:
self.add_new(item, item_id)
except DuplicateListHeapItemException:
Debug.printi("Unable to add duplicate picture", Debug.Level.ERROR)
return
except MaxItemLimitReachedException:
Debug.printi("Maximum number of pictures for this room reached", Debug.Level.ERROR)
return
示例5: _handle_db_click
def _handle_db_click(self, event):
Debug.printe(event, Debug.Level.INFO)
item = self._listbox.get(ACTIVE)
results = WallTextureDialog(self, populator=WallTextureContainer(self._items[item]))
self._remove_texture()
self._add_new_texture(results._entries)
pass
示例6: _selection_operation
def _selection_operation(self, coords):
"""
Contextually create or edit a node
:param coords:
:return:
"""
# Determine the item ID
item = self._get_current_item(coords)
self._cache["item"] = item
true_coords = self._canvas_to_screen((self._cache["x"], self._cache["y"]))
if self._is_node(item):
Debug.printi("Node Selected : " + str(item) + " | Launching Editor", Debug.Level.INFO)
# Make request from object manager using the tag assigned
populator = self._manager.request(DataStore.DATATYPE.NODE, item)
updated_node = NodeDialog(self, true_coords[0] + 10, true_coords[1] + 10, populator=populator)
# post information to object manager, or let the dialog handle it, or whatever
self._manager.inform(DataStore.EVENT.NODE_EDIT, updated_node._entries, item)
return
if self._is_edge(item):
Debug.printi("Edge Selected : " + str(item) + " | Launching Editor", Debug.Level.INFO)
# Make a request from the object manager to populate the dialog
populator = self._manager.request(DataStore.DATATYPE.EDGE, item)
updated_edge = EdgeDialog(self, true_coords[0] + 10, true_coords[1] + 10, populator=populator)
# Make sure that information is posted to the object manager
self._manager.inform(DataStore.EVENT.EDGE_EDIT, updated_edge._entries, item)
return
if self._is_object(item):
self._edit_object(coords)
return
示例7: _delete_object
def _delete_object(self, item):
if item not in self._object_listing:
Debug.printi("Object does not exist to delete", Debug.Level.ERROR)
return
del self._object_listing[item]
self._manager.inform(DataStore.EVENT.OBJECT_DELETE, data_id=item)
self._canvas.itemconfig(item, outline="red", fill="black", activeoutline="black", activefill="red")
示例8: _end_node_drag
def _end_node_drag(self, coords):
"""
Performs actions to complete a node drag operation
Validates node location, and other associated object information and updates the cache
when a node drag is completed
:coords: The coordinates associated with this event
"""
if self._cache["item"] is None:
return
# Obtain the final points
x = coords[0]
y = coords[1]
item = self._cache["item"]
self._validate_node_position(coords)
container = self._manager.request(DataStore.DATATYPE.NODE, item)
container.x_coordinate = x
container.y_coordinate = y
self._manager.inform(DataStore.EVENT.NODE_EDIT, container.empty_container(), self._cache["item"])
Debug.printi("Node " + str(self._cache["item"]) + " has been moved", Debug.Level.INFO)
# Clean the cache
self._clear_cache(coords)
示例9: doConditionScript
def doConditionScript(self, scriptData):
Debug.debug(__name__,'==?= condition script data form : '+str(scriptData))
tag = scriptData[0]
if len(scriptData) > 1:
args = scriptData[1]
else:
args = []
##print tag,",",args
if self.hasScript(tag):
if not self.getNumScriptArgs(tag) == len(args):
for ii in range(self.getNumScriptArgs(tag)):
print ii
if ii > len(args):
args.append("")
scriptFn = self.tagMap[tag]
bool = scriptFn(self.world, *args)
# temp
#bool = False
#print '=test= scriptFn type : ', type(scriptFn)
#print '=test= scriptFn with world and args type : ', type(scriptFn(self.world, *args))
#print '=test= scriptFn return when eval used : ', eval(scriptFn(self.world, *args))
Debug.debug(__name__,'==== script '+str(tag)+' with args '+str(args)+ ' evaluated to be : '+str(bool))
return bool
## else:
## # CONSIDER: exception class
## print 'ERROR: script \'%s\' takes %d args (%d given)' %(tag, self.getNumScriptArgs(tag), len(args))
else:
print 'ERROR: script name \'%s\' not found in doConditionScript function' %(tag)
示例10: postHourlySummary
def postHourlySummary(self):
'''Posts an hourly summary to Twitter'''
# Get current system time
currentTime = datetime.now()
# create time difference to be used to work out time period
timeDiff = timedelta(hours=1)
# Get current hour
currentHour = currentTime.strftime("%H")
# If current hour does not match last post hour then it's been a new hour since last post
if(currentHour != self.LAST_HOURLY_POST):
Debug.writeOut("Hourly condtion met (" + currentHour + " != " + self.LAST_HOURLY_POST + "). Posting to Twitter")
# Create SQL to get data for tweet
sql = "SELECT COALESCE(ROUND(AVG(energy), 2), 0), " +\
"COALESCE(MAX(energy), 0), COALESCE(ROUND(AVG(temperature), 1), 0) " +\
"FROM historical_data WHERE date_time >= ADDDATE(NOW(), INTERVAL -1 HOUR)"
self.LOGGER.debug(sql)
# Get statistics from DB
stats = MySQL.executeOneUpdate(sql, None)
# Create tweet
message = (currentTime - timeDiff).strftime("%H:%M") + "-" + currentTime.strftime("%H:%M") +\
" Summary: " + str(stats[0]) + "w was used." +\
" Energy usage peaked at " + str(stats[1]) + "w" +\
". The average temperature was " + str(stats[2]) + "c."
# Check if tweet should be a Direct Message or just a tweet
if self.CONFIG.getBooleanConfig("Twitter", "directMessagePost"):
self.postDirectMessage(self.CONFIG.getBooleanConfig("Twitter", "directMessageUser"), message)
else:
# Post message to twitter
self.tweet(message)
# Set last hourly post to current hour
self.LAST_HOURLY_POST = currentHour
示例11: addSuccessor
def addSuccessor(self, id):
if not id in self.successorIDs:
self.successorIDs.append(id)
Debug.debug(__name__, "added successor (id=" + str(id) + ") to line (id=" + str(self.id) + ")")
return True
else:
return False
示例12: _load_control_file
def _load_control_file(file_path):
try:
control_file = open(file_path)
Debug.printi("Control file " + file_path + " successfully loaded", Debug.Level.INFO)
return control_file
except IOError as e:
Debug.printi(e.message, Debug.Level.FATAL)
示例13: post
def post( self, event ):
if not isinstance( event, TickEvent ):
Debug.log( "Event: " + event.name )
# Event is broadcast to all listeners
for listener in self.listeners:
listener.notify( event )
示例14: __init__
def __init__(self):
super(Sprite, self).__init__()
global sprite_count
sprite_count += 1
Debug.track("Sprite Count", sprite_count)
示例15: loadFromLog
def loadFromLog(self, logFile):
Debug.out("Loading log " + logFile)
if os.path.isfile(logFile):
statinfo = os.stat(logFile)
if not statinfo.st_size:
raise LogError("Log has zero length")
else:
raise LogError("Log doesn't exist!")
try:
f = open(logFile, 'r')
except IOError as err:
raise LogError("Parsing log failed on IOError: " + str(errstr))
t1 = time.time()
p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = self.start_element
p.EndElementHandler = self.end_element
p.CharacterDataHandler = self.char_data
p.buffer_text = True
try:
p.ParseFile(f)
Debug.out(" Loaded", self.numLoaded, "rows in", round(time.time() - t1,5), "seconds")
except IOError as err:
raise LogError("Parsing log failed on IOError: " + str(IOError))
except ExpatError as err:
raise LogError("Parsing log failed on XML ExpatError: " + str(err))
finally:
f.close()