From 73dce68376df898d01cc8fcf843d363914a39adf Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 16 Dec 2015 19:27:29 +0000 Subject: [PATCH] Remove seemingly unused debugging.py. Add in https://github.com/galaxyproject/galaxy/commit/017a3c356b8742dd09e65f1c6ce86c0afd7de3b4. --- lib/galaxy/util/debugging.py | 68 ------------------------------------ 1 file changed, 68 deletions(-) delete mode 100644 lib/galaxy/util/debugging.py diff --git a/lib/galaxy/util/debugging.py b/lib/galaxy/util/debugging.py deleted file mode 100644 index ac804097d46..00000000000 --- a/lib/galaxy/util/debugging.py +++ /dev/null @@ -1,68 +0,0 @@ - -import inspect -import time - -import logging -log = logging.getLogger( __name__ ) - - -def stack_trace_string( max_depth=None, line_format="{index}:{file}:{function}:{line}" ): - """ - Returns a string representation of the current stack. - - :param depth: positive integer to control how many levels of the stack are - returned. max_depth=None returns the entire stack (default). - """ - stack_list = [] - for index, caller in enumerate( inspect.stack() ): - # don't include this function - if index == 0: - continue - if max_depth and index > max_depth: - break - - caller_data = { - 'index' : str( index ), - 'file' : caller[1], - 'function' : caller[3], - 'line' : caller[2] - } - stack_list.append( line_format.format( **caller_data ) ) - - return '\n'.join( stack_list ) - - -class SimpleProfiler( object ): - """ - Simple profiler that captures the duration between calls to `report` - and stores the results in a list. - """ - REPORT_FORMAT = '%20f: %s' - - def __init__( self, log=None ): - self.log = log - self.start_time = 0 - self.reports = [] - - def start( self, msg=None ): - msg = msg or 'Start' - self.start_time = time.time() - report = self.REPORT_FORMAT % ( self.start_time, msg ) - self.reports.append( report ) - if self.log: - self.log( report ) - - def report( self, msg ): - if not self.start_time: - self.start() - duration = time.time() - self.start_time - report = self.REPORT_FORMAT % ( duration, msg ) - self.reports.append( report ) - if self.log: - self.log( report ) - - def get_reports( self ): - return self.reports - - def __str__( self ): - return '\n'.join( self.reports )