Update of /cvsroot/freevo/freevo/src In directory sc8-pr-cvs1:/tmp/cvs-serv5367
Modified Files: childapp.py Log Message: childapp can now log. Please remove the MPLAYER_DEBUG from the players Index: childapp.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/childapp.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** childapp.py 11 Nov 2003 17:59:03 -0000 1.41 --- childapp.py 22 Nov 2003 15:30:33 -0000 1.42 *************** *** 10,13 **** --- 10,16 ---- # ----------------------------------------------------------------------- # $Log$ + # Revision 1.42 2003/11/22 15:30:33 dischi + # childapp can now log. Please remove the MPLAYER_DEBUG from the players + # # Revision 1.41 2003/11/11 17:59:03 dischi # remove empty vals from app list *************** *** 150,154 **** start_str = '%s %s' % (config.RUNAPP, app) ! else: --- 153,157 ---- start_str = '%s %s' % (config.RUNAPP, app) ! debug_name = app[:app.find(' ')] else: *************** *** 171,174 **** --- 174,185 ---- start_str = app + debug_name = app[0] + + + if debug_name.rfind('/') > 0: + debug_name = debug_name[debug_name.rfind('/')+1:] + else: + debug_name = debug_name + self.child = util.popen3.Popen3(start_str) self.outfile = self.child.fromchild *************** *** 176,184 **** self.infile = self.child.tochild ! self.t1 = Read_Thread('stdout', self.outfile, self.stdout_cb) self.t1.setDaemon(1) self.t1.start() ! self.t2 = Read_Thread('stderr', self.errfile, self.stderr_cb) self.t2.setDaemon(1) self.t2.start() --- 187,195 ---- self.infile = self.child.tochild ! self.t1 = Read_Thread('stdout', self.outfile, self.stdout_cb, debug_name) self.t1.setDaemon(1) self.t1.start() ! self.t2 = Read_Thread('stderr', self.errfile, self.stderr_cb, debug_name) self.t2.setDaemon(1) self.t2.start() *************** *** 317,326 **** class Read_Thread(threading.Thread): ! def __init__(self, name, fp, callback): threading.Thread.__init__(self) self.name = name self.fp = fp self.callback = callback ! def run(self): --- 328,353 ---- class Read_Thread(threading.Thread): ! def __init__(self, name, fp, callback, logger=None): threading.Thread.__init__(self) self.name = name self.fp = fp self.callback = callback ! self.logger = None ! if logger and config.CHILDAPP_DEBUG: ! logger = os.path.join(config.LOGDIR, '%s-%s.log' % (logger, name)) ! try: ! try: ! os.unlink(logger) ! except: ! pass ! self.logger = open(logger, 'w') ! print _( 'logging child to "%s"' ) % logger ! except IOError: ! print ! print _('ERROR') + ': ' + _( 'Cannot open "%s" for logging!') % logger ! print _('Set CHILDAPP_DEBUG=0 in local_conf.py, or make %s writable!' ) % \ ! config.LOGDIR ! print ! def run(self): *************** *** 342,345 **** --- 369,374 ---- _debug_('%s: No data, stopping (pid %s)!' % (self.name, os.getpid()),2) self.fp.close() + if self.logger: + self.logger.close() break else: *************** *** 352,355 **** --- 381,386 ---- else: # Combine saved data and first line, send to app + if self.logger: + self.logger.write(saved + lines[0]+'\n') self.callback(saved + lines[0]) saved = '' *************** *** 362,369 **** --- 393,404 ---- # Send all lines except the last partial line to the app for line in lines[1:-1]: + if self.logger: + self.logger.write(line+'\n') self.callback(line) else: # Send all lines to the app for line in lines[1:]: + if self.logger: + self.logger.write(line+'\n') self.callback(line) ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Freevo-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freevo-cvslog