コード例 #1
0
ファイル: core.py プロジェクト: harixxy/nodebox-opengl
def log(logfile="", mode="w", top=10):
    """Enable logging to the given file.

If the file name is unspecified, a default name is built by appending
a 'log-psyco' extension to the main script name.

Mode is 'a' to append to a possibly existing file or 'w' to overwrite
an existing file. Note that the log file may grow quickly in 'a' mode."""
    import profiler, logger

    if not logfile:
        import os

        logfile, dummy = os.path.splitext(sys.argv[0])
        if os.path.basename(logfile):
            logfile += "."
        logfile += "log-psyco"
    if hasattr(_psyco, "VERBOSE_LEVEL"):
        print >>sys.stderr, "psyco: logging to", logfile
    # logger.current should be a real file object; subtle problems
    # will show up if its write() and flush() methods are written
    # in Python, as Psyco will invoke them while compiling.
    logger.current = open(logfile, mode)
    logger.print_charges = top
    profiler.logger = logger
    logger.writedate("Logging started")
    cannotcompile(logger.psycowrite)
    _psyco.statwrite(logger=logger.psycowrite)
コード例 #2
0
def log(logfile='', mode='w', top=10):
    """Enable logging to the given file.

If the file name is unspecified, a default name is built by appending
a 'log-psyco' extension to the main script name.

Mode is 'a' to append to a possibly existing file or 'w' to overwrite
an existing file. Note that the log file may grow quickly in 'a' mode."""
    import profiler, logger
    if not logfile:
        import os
        logfile, dummy = os.path.splitext(sys.argv[0])
        if os.path.basename(logfile):
            logfile += '.'
        logfile += 'log-psyco'
    if hasattr(_psyco, 'VERBOSE_LEVEL'):
        print >> sys.stderr, 'psyco: logging to', logfile
    # logger.current should be a real file object; subtle problems
    # will show up if its write() and flush() methods are written
    # in Python, as Psyco will invoke them while compiling.
    logger.current = open(logfile, mode)
    logger.print_charges = top
    profiler.logger = logger
    logger.writedate('Logging started')
    cannotcompile(logger.psycowrite)
    _psyco.statwrite(logger=logger.psycowrite)
コード例 #3
0
 def do_profile(self):
     _psyco.statcollect()
     if logger:
         logger.dumpcharges()
     nunit = _psyco.statread('unit') * self.progress
     if nunit > self.reset_limit:
         self.reset()
     else:
         _psyco.statwrite(unit=nunit, callback=self.charge_callback)
     return self.passivealarm_args
コード例 #4
0
ファイル: profiler.py プロジェクト: JasonAng/ResearchScripts
 def do_profile(self):
     _psyco.statcollect()
     if logger:
         logger.dumpcharges()
     nunit = _psyco.statread('unit') * self.progress
     if nunit > self.reset_limit:
         self.reset()
     else:
         _psyco.statwrite(unit = nunit, callback = self.charge_callback)
     return self.passivealarm_args
コード例 #5
0
 def reset(self):
     _psyco.statwrite(unit=self.initial_charge_unit, callback=None)
     _psyco.statreset()
     if logger:
         logger.write("%s: resetting stats" % self.__class__.__name__, 1)
コード例 #6
0
 def do_start(self):
     self.init_charges()
     self.active_start()
     _psyco.statwrite(callback=self.charge_callback)
コード例 #7
0
 def do_stop(self):
     _psyco.profiling('.')
     _psyco.statwrite(callback=None)
コード例 #8
0
 def init_charges(self):
     _psyco.statwrite(watermark=self.watermark, parent2=self.parent2)
コード例 #9
0
ファイル: profiler.py プロジェクト: JasonAng/ResearchScripts
 def reset(self):
     _psyco.statwrite(unit = self.initial_charge_unit, callback = None)
     _psyco.statreset()
     if logger:
         logger.write("%s: resetting stats" % self.__class__.__name__, 1)
コード例 #10
0
ファイル: profiler.py プロジェクト: JasonAng/ResearchScripts
 def do_start(self):
     self.init_charges()
     self.active_start()
     _psyco.statwrite(callback = self.charge_callback)
コード例 #11
0
ファイル: profiler.py プロジェクト: JasonAng/ResearchScripts
 def do_stop(self):
     _psyco.profiling('.')
     _psyco.statwrite(callback = None)
コード例 #12
0
ファイル: profiler.py プロジェクト: JasonAng/ResearchScripts
 def init_charges(self):
     _psyco.statwrite(watermark = self.watermark,
                      parent2   = self.parent2)