Commits

Miki Tebeka  committed 9316d03

" -> ' and Bye bye

  • Participants
  • Parent commits 02895fe

Comments (0)

Files changed (1)

 #!/usr/bin/env python
-'''A "backdoor" shell for running servers (very much like Twisted manhole).
+'''A 'backdoor' shell for running servers (very much like Twisted manhole).
 
-Once installed, you can "telnet <host> <port>" and run Python commands on your
+Once installed, you can 'telnet <host> <port>' and run Python commands on your
 server environment. This is very helpful in debugging servers.
 
 This one uses only modules found in the standard library.
 '''
 
-__author__ = "Miki Tebeka <miki.tebeka@gmail.com>"
-__version__ = "0.1.0"
+__author__ = 'Miki Tebeka <miki.tebeka@gmail.com>'
+__version__ = '0.1.0'
 
 from SocketServer import StreamRequestHandler, TCPServer, ThreadingMixIn
 from threading import Thread
 
     def handle(self):
         env = self.env.copy()
-        self.wfile.write("Welcome to ingress (type 'exit()' to exit)\n")
+        self.wfile.write('Welcome to ingress (type "exit()" to exit)\n')
 
         if not self.login():
             return
 
         while True:
             try:
-                self.wfile.write(">>> ")
+                self.wfile.write('>>> ')
                 expr = self.rfile.readline().rstrip()
                 if expr == EOF:
+                    self.wfile.write("Bye bye\n")
                     return
                 try:
                     value = eval(expr, globals(), env)
-                    self.wfile.write(format(value) + "\n")
+                    self.wfile.write(format(value) + '\n')
                 except:
                     exec expr in env
             except (EOFError, SystemExit):
+                self.wfile.write("Bye bye\n")
                 return
             except Exception as e:
                 print_exc(file=self.wfile)
             return True
 
         for i in range(3):
-            self.wfile.write("Password: ")
+            self.wfile.write('Password: ')
             password = self.rfile.readline().strip()
             if password == self.password:
                 return True
-            self.wfile.write("Bad password\n")
+            self.wfile.write('Bad password\n')
 
         return False
 
     Handler.env = env
     Handler.password = password
 
-    server = ThreadedServer(("localhost", port), Handler)
+    server = ThreadedServer(('localhost', port), Handler)
     server.serve_forever()
 
 DEFAULT_PORT = 9998
 
     argv = argv or sys.argv
 
-    parser = ArgumentParser(description="Run demo server.")
-    parser.add_argument("-p", "--port", help="port to listen",
+    parser = ArgumentParser(description='Run demo server.')
+    parser.add_argument('-p', '--port', help='port to listen',
                         default=DEFAULT_PORT)
-    parser.add_argument("-l", "--login", help="login password",
+    parser.add_argument('-l', '--login', help='login password',
                         default=None)
     args = parser.parse_args(argv[1:])
 
     t = install(port=args.port, password=args.login)
-    print("Serving on port {0}".format(args.port))
+    print('Serving on port {0}'.format(args.port))
     t.join()
 
 
-if __name__ == "__main__":
+if __name__ == '__main__':
     main()