summaryrefslogtreecommitdiffstats
path: root/hostwatch.py
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2010-10-02 16:34:24 -0700
committerAvery Pennarun <apenwarr@gmail.com>2010-10-02 16:34:35 -0700
commitae32fe2a59934c39a57b0e06a554033af9c553bb (patch)
tree6767ffe65340499b37cae2e5cd7fc8efb9015143 /hostwatch.py
parent518df41049692c8f4efec840fe246ee2f164f28e (diff)
parent5070f2ffcfcb85925aab46e51079605b8d7f065d (diff)
Merge branch 'python23' - python 2.3 compatibilitysshuttle-0.41
* python23: Oops, missed another << operator to replace with _shl(). socket.SHUT_RD and socket.SHUT_WR don't exist in python 2.3. compat/ssubprocess.py: some python versions don't have os.closerange(). _nb_clean: don't catch EPIPE after all. Fix busy-waiting in two situations: Factor out common mainloop code between client and server. Implement our own left-shift operator to shut up python 2.3 warnings. Don't use set() since it's not in python 2.3. import and use subprocess.py from python 2.6. Remove list comprehensions for python 2.3 compatibility.
Diffstat (limited to 'hostwatch.py')
-rw-r--r--hostwatch.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/hostwatch.py b/hostwatch.py
index 7a71e9d..d77a58f 100644
--- a/hostwatch.py
+++ b/hostwatch.py
@@ -1,5 +1,6 @@
-import subprocess, time, socket, re, select, errno
+import time, socket, re, select, errno
if not globals().get('skip_imports'):
+ import compat.ssubprocess as ssubprocess
import helpers
from helpers import *
@@ -108,7 +109,7 @@ def _check_netstat():
debug2(' > netstat\n')
argv = ['netstat', '-n']
try:
- p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=null)
+ p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null)
content = p.stdout.read()
p.wait()
except OSError, e:
@@ -128,7 +129,7 @@ def _check_smb(hostname):
argv = ['smbclient', '-U', '%', '-L', hostname]
debug2(' > smb: %s\n' % hostname)
try:
- p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=null)
+ p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null)
lines = p.stdout.readlines()
p.wait()
except OSError, e:
@@ -185,7 +186,7 @@ def _check_nmb(hostname, is_workgroup, is_master):
argv = ['nmblookup'] + ['-M']*is_master + ['--', hostname]
debug2(' > n%d%d: %s\n' % (is_workgroup, is_master, hostname))
try:
- p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=null)
+ p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null)
lines = p.stdout.readlines()
rv = p.wait()
except OSError, e: