Jason R. Coombs avatar Jason R. Coombs committed 2909bd2

Fixed errors with whois module on Windows

Comments (0)

Files changed (1)

jaraco/net/whois.py

 import select
 import SocketServer
 
+import jaraco.util.logging
 from ClientForm import ParseResponse, ItemNotFoundError
 from BeautifulSoup import BeautifulSoup, UnicodeDammit
 from jaraco.util.meta import LeafClassesMeta
 try:
 	import win32service
 	import win32serviceutil
-	import win32event
+	import servicemanager
 except ImportError:
 	pass
 
 	"""This is not a typical Whois handler, but rather a special
 	handler that returns the source of this file"""
 	services = r'^source$'
+
 	def LoadHTTP(self): pass
+
 	def ParseResponse(self, s_out):
 		filename = os.path.splitext(__file__)[0] + '.py'
 		s_out.write(open(filename).read())
 			self.listener.server_close()
 
 		def SvcDoRun(self):
-			import servicemanager
-
 			self._setup_logging()
 
 			log.info('%s service is starting.', self._svc_display_name_)
 			self.listener.serve_until_closed()
 
 		def _setup_logging(self):
-			from jaraco.util import TimestampFileHandler, LogFileWrapper
 			logfile = os.path.join(os.environ['WINDIR'], 'system32', 'LogFiles', self._svc_display_name_, 'events.log')
-			handler = TimestampFileHandler(logfile)
+			handler = jaraco.util.logging.TimestampFileHandler(logfile)
 			handlerFormat = '[%(asctime)s] - %(levelname)s - [%(name)s] %(message)s'
 			handler.setFormatter(logging.Formatter(handlerFormat))
 			logging.root.addHandler(handler)
 			# if I don't redirect stdoutput and stderr, when the stdio flushes,
 			#  an exception will be thrown and the service will bail
-			sys.stdout = LogFileWrapper('stdout')
-			sys.stderr = LogFileWrapper('stderr')
+			sys.stdout = jaraco.util.logging.LogFileWrapper('stdout')
+			sys.stderr = jaraco.util.logging.LogFileWrapper('stderr')
 			logging.root.level = logging.INFO
 
 		@classmethod
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.