For debugging porposes, use:
from subprocess import Popen, PIPE, STDOUT
with open('debug.log', 'a') as log:
log.write('Starting subprocess\n')
log.flush()
handle = Popen('winexe --system -U user%password //ip_client "cmd /C wmic os get osarchitecture"', shell=True, stdout=PIPE, stderr=STDOUT, stdin=PIPE)
log.write('Outputting everything that the subprocess does...\n')
log.flush()
while handle.poll() is None:
log.write('Output: ' + str(handle.stdout.read()) + '\n')
log.flush()
log.write('Command ended with code: ' + str(handle.poll()) + '\n')
log.flush()
handle.stdout.close()
handle.stdin.close()