diff unix.py @ 136:ed4035661b85

Added a C implementation of the unix module (called _unix)
author Oleg Oshmyan <chortos@inbox.lv>
date Tue, 24 May 2011 20:51:01 +0100
parents e84f33a60a5c
children
line wrap: on
line diff
--- a/unix.py	Tue May 24 18:59:00 2011 +0100
+++ b/unix.py	Tue May 24 20:51:01 2011 +0100
@@ -25,25 +25,6 @@
 __all__ = 'call', 'kill', 'pause', 'clock'
 
 
-if not sys.stdin.isatty():
-	pause = lambda: sys.stdin.read(1)
-	catch_escape = False
-else:
-	try:
-		from select import select
-		import termios, tty, atexit
-	except ImportError:
-		pause = None
-		catch_escape = False
-	else:
-		catch_escape = True
-		def cleanup(old=termios.tcgetattr(sys.stdin.fileno())):
-			termios.tcsetattr(sys.stdin.fileno(), termios.TCSAFLUSH, old)
-		atexit.register(cleanup)
-		tty.setcbreak(sys.stdin.fileno())
-		def pause():
-			sys.stdin.read(1)
-
 try:
 	from signal import SIGCHLD, SIG_DFL, signal, set_wakeup_fd
 	from select import select, error as SelectError
@@ -306,4 +287,27 @@
 				return process.wait()
 			except OSError:
 				if sys.exc_info()[1].errno != EINTR:
-					raise
\ No newline at end of file
+					raise
+
+
+try:
+	from _unix import *
+except ImportError:
+	if not sys.stdin.isatty():
+		pause = lambda: sys.stdin.read(1)
+		catch_escape = False
+	else:
+		try:
+			from select import select
+			import termios, tty, atexit
+		except ImportError:
+			pause = lambda: sys.stdin.read(1)
+			catch_escape = False
+		else:
+			catch_escape = True
+			def cleanup(old=termios.tcgetattr(sys.stdin.fileno())):
+				termios.tcsetattr(sys.stdin.fileno(), termios.TCSAFLUSH, old)
+			atexit.register(cleanup)
+			tty.setcbreak(sys.stdin.fileno())
+			def pause():
+				sys.stdin.read(1)