mirror of
https://github.com/Rudd-O/ansible-qubes.git
synced 2025-03-01 14:22:33 +01:00
Various fixes.
This commit is contained in:
parent
eb8d0ab162
commit
88907adabb
@ -88,7 +88,7 @@ class LoggingEmu():
|
|||||||
string = a[0]
|
string = a[0]
|
||||||
else:
|
else:
|
||||||
string = a[0] % a[1:]
|
string = a[0] % a[1:]
|
||||||
syslog.syslog(prio, ("%.3f " % deltat) + string)
|
syslog.syslog(prio, ("%.3f " % deltat) + threading.currentThread().getName() + ": " + string)
|
||||||
finally:
|
finally:
|
||||||
debug_lock.release()
|
debug_lock.release()
|
||||||
logging = None
|
logging = None
|
||||||
|
@ -129,38 +129,39 @@ def popen(cmd, in_data, outf=sys.stdout):
|
|||||||
def put(out_path):
|
def put(out_path):
|
||||||
try:
|
try:
|
||||||
f = open(out_path, "wb")
|
f = open(out_path, "wb")
|
||||||
sys.stdout.write('{}\n'.format('Y').encode('ascii'))
|
sys.stdout.write(b'Y\n')
|
||||||
except (IOError, OSError) as e:
|
except (IOError, OSError) as e:
|
||||||
sys.stdout.write('{}\n'.format('N').encode('ascii'))
|
sys.stdout.write(b'N\n')
|
||||||
encode_exception(e, sys.stdout)
|
encode_exception(e, sys.stdout)
|
||||||
return
|
return
|
||||||
try:
|
while True:
|
||||||
while True:
|
chunksize = int(sys.stdin.readline(16))
|
||||||
chunksize = int(sys.stdin.readline(16).decode('ascii'))
|
if chunksize == 0:
|
||||||
if chunksize == 0:
|
break
|
||||||
break
|
chunk = sys.stdin.read(chunksize)
|
||||||
chunk = sys.stdin.read(chunksize)
|
|
||||||
try:
|
|
||||||
f.write(chunk)
|
|
||||||
sys.stdout.write('{}\n'.format('Y').encode('ascii'))
|
|
||||||
except (IOError, OSError) as e:
|
|
||||||
sys.stdout.write('{}\n'.format('N').encode('ascii'))
|
|
||||||
encode_exception(e, sys.stdout)
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
f.flush()
|
f.write(chunk)
|
||||||
|
sys.stdout.write(b'Y\n')
|
||||||
except (IOError, OSError) as e:
|
except (IOError, OSError) as e:
|
||||||
sys.stdout.write('{}\n'.format('N').encode('ascii'))
|
sys.stdout.write(b'N\n')
|
||||||
encode_exception(e, sys.stdout)
|
encode_exception(e, sys.stdout)
|
||||||
finally:
|
f.close()
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
f.flush()
|
||||||
|
except (IOError, OSError) as e:
|
||||||
|
sys.stdout.write(b'N\n')
|
||||||
|
encode_exception(e, sys.stdout)
|
||||||
f.close()
|
f.close()
|
||||||
|
return
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def fetch(in_path, bufsize):
|
def fetch(in_path, bufsize):
|
||||||
try:
|
try:
|
||||||
f = open(in_path, "rb")
|
f = open(in_path, "rb")
|
||||||
except (IOError, OSError) as e:
|
except (IOError, OSError) as e:
|
||||||
sys.stdout.write('{}\n'.format('N').encode('ascii'))
|
sys.stdout.write(b'N\n')
|
||||||
encode_exception(e, sys.stdout)
|
encode_exception(e, sys.stdout)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
@ -168,8 +169,9 @@ def fetch(in_path, bufsize):
|
|||||||
try:
|
try:
|
||||||
data = f.read(bufsize)
|
data = f.read(bufsize)
|
||||||
except (IOError, OSError) as e:
|
except (IOError, OSError) as e:
|
||||||
sys.stdout.write('{}\n'.format('N').encode('ascii'))
|
sys.stdout.write(b'N\n')
|
||||||
encode_exception(e, sys.stdout)
|
encode_exception(e, sys.stdout)
|
||||||
|
f.close()
|
||||||
return
|
return
|
||||||
sys.stdout.write('{}\n'.format(len(data)).encode('ascii'))
|
sys.stdout.write('{}\n'.format(len(data)).encode('ascii'))
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
@ -177,8 +179,7 @@ def fetch(in_path, bufsize):
|
|||||||
break
|
break
|
||||||
sys.stdout.write(data)
|
sys.stdout.write(data)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
finally:
|
f.close()
|
||||||
f.close()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -263,11 +264,11 @@ class Connection(ConnectionBase):
|
|||||||
self.transport_cmd = kwargs['transport_cmd']
|
self.transport_cmd = kwargs['transport_cmd']
|
||||||
return
|
return
|
||||||
self.transport_cmd = distutils.spawn.find_executable('qrun')
|
self.transport_cmd = distutils.spawn.find_executable('qrun')
|
||||||
|
self.transport_cmd = None
|
||||||
if not self.transport_cmd:
|
if not self.transport_cmd:
|
||||||
self.transport_cmd = os.path.join(
|
self.transport_cmd = os.path.join(
|
||||||
os.path.dirname(__file__),
|
os.path.dirname(__file__),
|
||||||
os.path.pardir,
|
os.path.pardir,
|
||||||
os.path.pardir,
|
|
||||||
"bin",
|
"bin",
|
||||||
"qrun",
|
"qrun",
|
||||||
)
|
)
|
||||||
@ -296,7 +297,7 @@ class Connection(ConnectionBase):
|
|||||||
if not self._connected:
|
if not self._connected:
|
||||||
remote_cmd = [to_bytes(x, errors='surrogate_or_strict') for x in [
|
remote_cmd = [to_bytes(x, errors='surrogate_or_strict') for x in [
|
||||||
# 'strace', '-s', '2048', '-o', '/tmp/log',
|
# 'strace', '-s', '2048', '-o', '/tmp/log',
|
||||||
'python', '-i', '-c', preamble
|
'python', '-u', '-i', '-c', preamble
|
||||||
]]
|
]]
|
||||||
addr = self._play_context.remote_addr
|
addr = self._play_context.remote_addr
|
||||||
proxy = to_bytes(self.get_option("management_proxy")) if self.get_option("management_proxy") else ""
|
proxy = to_bytes(self.get_option("management_proxy")) if self.get_option("management_proxy") else ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user