1 import sys, os, pwd, subprocess, errno
12 if e.errno == errno.EEXIST:
19 p = subprocess.Popen(argv, stdout=subprocess.PIPE)
31 _username = pwd.getpwuid(uid)[0]
33 _username = 'user%d' % uid
43 _userfullname = pwd.getpwuid(uid)[4].split(',')[0]
45 _userfullname = 'user%d' % uid
54 _hostname = readpipe(['hostname', '-f']).strip()
57 return _hostname or 'localhost'
61 def __init__(self, inp, outp):
67 return self.inp.read(size)
71 return self.inp.readline()
73 def write(self, data):
74 #log('%d writing: %d bytes\n' % (os.getpid(), len(data)))
83 for rl in linereader(self.inp):
84 #log('%d got line: %r\n' % (os.getpid(), rl))
85 if not rl: # empty line
90 raise Exception('expected "ok", got %r' % rl)
91 raise Exception('server exited unexpectedly; see errors above')
102 def chunkyreader(f, count = None):
105 b = f.read(min(count, 65536))
107 raise IOError('EOF with %d bytes remaining' % count)