Commits

windwiny committed cc92668

add --stdout args

Comments (0)

Files changed (1)

         if not p:
             wx.MessageBox('Error path', 'Error', wx.ICON_ERROR)
             return ''
+        if p.startswith('ssh'):
+            return p
         if sys.platform == 'win32':
             if p[1] != ':':
                 wx.MessageBox('Error Drive:/Path format', 'Error', wx.ICON_ERROR)
-                return ''
+                return p
             if conv:
                 p2 = '/cygdrive/%s/%s' % (p[0], p[3:].replace('\\', '/'))
                 return p2
         else:
             if p[0] != '/':
                 wx.MessageBox('Error /path/file format', 'Error', wx.ICON_ERROR)
-                return ''
+                return p
             return p
 
     @staticmethod
         self._logstc.AppendText('%s\n%s\n\n' % (
             time.strftime('  %Y-%m-%d %H:%M:%S\n'), os.getcwdu()))
         self._logstc.EmptyUndoBuffer()
-        self._stdout, self._stderr = sys.stdout, sys.stderr
-        sys.stdout, sys.stderr = self, self
+        if '--stdout' not in sys.argv:
+            self._stdout, self._stderr = sys.stdout, sys.stderr
+            sys.stdout, sys.stderr = self, self
 
     def OnMygrsyncClose(self, event):
         event.Skip()
-        sys.stdout, sys.stderr = self._stdout, self._stderr
-        print 'reset sys.stdout, mainframe close'
+        if hasattr(self, '_stdout'):
+            sys.stdout, sys.stderr = self._stdout, self._stderr
+            print 'reset sys.stdout, mainframe close'
 
     def write(self, txt):
         if type(txt) == type(u''):