From f9cbf2db742251707195ebb9f737751ee43b3a8a Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Fri, 30 Oct 2015 22:16:17 +0100 Subject: [PATCH] some mini fixes for unhealthy people who run the server on windows --- pupy/modules/interactive_shell.py | 7 ++++--- pupy/pupylib/PupyCmd.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pupy/modules/interactive_shell.py b/pupy/modules/interactive_shell.py index d996d1f2..f08c3fbf 100644 --- a/pupy/modules/interactive_shell.py +++ b/pupy/modules/interactive_shell.py @@ -3,9 +3,10 @@ from pupylib.PupyModule import * from pupylib.utils.rpyc_utils import redirected_stdio import sys import os -import termios -import tty -import select +if sys.platform!="win32": + import termios + import tty + import select import time import StringIO from threading import Event diff --git a/pupy/pupylib/PupyCmd.py b/pupy/pupylib/PupyCmd.py index 66a822f8..07dc661b 100644 --- a/pupy/pupylib/PupyCmd.py +++ b/pupy/pupylib/PupyCmd.py @@ -174,6 +174,8 @@ class PupyCmd(cmd.Cmd): self.intro = color(BANNER, 'green') self.intro += color(BANNER_INFO, 'darkgrey') + if sys.platform=="win32": + self.intro+="\n"+self.format_warning("You are running Pupy server on Windows. Pupy server works best on linux. Pupy server on windows has not been really tested and there is probably a lot of bugs. I try my best to code in a portable way but it don't always find the time to fix everything. If you find the courage to patch non portable code, I will gladly accept push requests ! :)\n") self.intro += "\n"+self.format_srvinfo("Server started on %s:%s with transport %s"%(self.pupsrv.address, self.pupsrv.port, self.pupsrv.transport)).rstrip("\n") self.raw_prompt= color('>> ','blue') self.prompt = color('>> ','blue', prompt=True) @@ -390,7 +392,10 @@ class PupyCmd(cmd.Cmd): self.stdout.write("\x1b[0G"+PupyCmd.format_srvinfo(msg)+"\x1b[0E") self.stdout.write("\x1b[2K")#clear line self.stdout.write(self.raw_prompt+buf_bkp)#"\x1b[2K") - readline.redisplay() + try: + readline.redisplay() + except Exception: + pass elif modifier=="warning": self.stdout.write(PupyCmd.format_warning(msg)) else: @@ -632,7 +637,8 @@ class PupyCmd(cmd.Cmd): compfunc = self.completenames self.completion_matches = compfunc(text, line, begidx, endidx) try: - return self.completion_matches[state] + if self.completion_matches: + return self.completion_matches[state] except IndexError: return None