Due to memory constraints I need to convert some Python scripts to C. In my script they used a module called "pexpect" which allows spawning child applications and controlling them automatically. Here I am including a piece of code from a Class. Any leads appreciated.
from pexpect import spawn, EOF, run
def do_transfer(self):
ret_status = DEFAULT_RETURN_VAL
count = 0
while ret_status != 0 and count < self.retry:
if self.user_name and self.password:
cmd = "%s --connect-timeout %s %s %s -o %s -u %s:%s"%(CURL_CMD, self.conn_timeout, DEFAULT_OPTS,
self.remote_url, self.local_path, self.user_name, self.password)
else:
cmd = "%s --connect-timeout %s %s %s -o %s"%(CURL_CMD, self.conn_timeout, DEFAULT_OPTS, self.remote_url, self.local_path)
transfer = spawn(cmd)
transfer.expect(EOF, timeout=self.transfer_timeout)
transfer.close()
if transfer.exitstatus is not None:
ret_status = transfer.exitstatus
elif transfer.signalstatus is not None:
ret_status = transfer.signalstatus
del transfer
count += 1
sleep(3)
return ret_status