Commits

Edwin Marshall committed 695978a

- wrapped unix-specific calls in try/except
- eventually, it may be worth either extracting such calls entirely for better cross-platform support, or writing windows-specific equivalents to provide analogous functionality

Comments (0)

Files changed (3)

circuits/app/env.py

 
 from os import mkdir
 from os import makedirs
-from signal import SIGHUP
+try:
+    from signal import SIGHUP
+except ImportError:
+    # Windows doesn't share the signals concept
+    pass
+
 from os.path import abspath, isabs, join as joinpath
 
 from circuits import handler, BaseComponent, Event

circuits/app/startup.py

 import os
 import errno
 from time import sleep
-from signal import SIGINT, SIGHUP, SIGTERM
+try:
+    from signal import SIGINT, SIGHUP, SIGTERM
+except ImportError:
+    # Windows doesn't share Unix's signal mechanism
+    SIGINT = None
+    SIGHUP = None
+    SIGTERM = None
 
 from circuits import handler, Event, BaseComponent
 

circuits/net/sockets.py

 from socket import gethostname, gethostbyname, socket
 
 from socket import SOL_SOCKET, SO_BROADCAST, SO_REUSEADDR, TCP_NODELAY
-from socket import AF_INET, AF_UNIX, IPPROTO_TCP, SOCK_STREAM, SOCK_DGRAM
+from socket import AF_INET, IPPROTO_TCP, SOCK_STREAM, SOCK_DGRAM
+try:
+    from socket import AF_UNIX
+except:
+    # not running on Unix
+    pass
 
 try:
     from ssl import wrap_socket as ssl_socket