class ErrorLogger: """Class can be used for a writer to write to multiple streams. Duplicated in both possible startup files so log can be created without external dependencies""" def __init__(self, outStream): """Init.""" self.outStream = outStream def write(self, message): # Polemos: unicode fix. """Write to outstream.""" for s in self.outStream: try: s.write(message) except: s.write(message.encode('utf-8')) f = file("WryeMash.log", "w+") sys.stdout = ErrorLogger([f, sys.__stdout__]) sys.stderr = ErrorLogger([f, sys.__stderr__]) f.write("Wrye Mash Log!\n") # Main import masher if len(sys.argv) > 1: stdOutCode = int(sys.argv[1]) else: stdOutCode = -1 if stdOutCode >= 0: app = masher.MashApp(stdOutCode) else: app = masher.MashApp() app.MainLoop()
except ImportError: print msg raise #dump the info to sdterr def ForceWxVersion(): """Force wxversion for Python 2.4""" if sys.version[:3] == '2.4': import wxversion wxversion.select("2.5.3.1") # Main ------------------------------------------------------------------------ #This doesn't check if __name__ == '__main__' as it is used by Wrye Mash.pyc CheckWx() ForceWxVersion() import masher if len(sys.argv) > 1: stdOutCode = int(sys.argv[1]) else: stdOutCode = -1 if stdOutCode >= 0: app = masher.MashApp(stdOutCode) else: app = masher.MashApp() app.MainLoop()
"""Class can be used for a writer to write to multiple streams. Duplicated in both possible startup files so log can be created without external dependencies""" def __init__(self, outStream): """Init.""" self.outStream = outStream def write(self, message): """Write to out-stream.""" try: [stream.write(message) for stream in self.outStream] except: pass # Logger start logChk() fl = file('WryeMash.log', 'a+') sys.stdout, sys.stderr = ErrorLogger((fl, sys.__stdout__)), ErrorLogger( (fl, sys.__stderr__)) fl.write( '\n%s: # ===================== Wrye Mash started. ===================== #\n' % datetime.now()) # Main import masher stdOutCode = int(sys.argv[1]) if len(sys.argv) > 1 else -1 app = masher.MashApp(stdOutCode) if stdOutCode >= 0 else masher.MashApp() app.MainLoop() fl.close()