child.before taking almost 1 minute to execute

Emile van Sebille emile at fenx.com
Wed Feb 24 15:57:31 EST 2016


On 2/24/2016 7:42 AM, pyfreek wrote:
> The following snippet alone is taking 1 minute to execute. is there any best way to find 'No such file' other than using child.before
>
>                  if not scrutinFile.startswith('/') :
>                          scrutinFile = '/'+ scrutinFile
>                  scrutinFileFtp = directory + scrutinFile
>                  filePath, file = os.path.split(scrutinFileFtp)
>                  p.sendline('cd %s'%(filePath))
>                  p.expect([pexpect.EOF,pexpect.TIMEOUT])
>                  if 'No such file' in p.before:
>                          print "No such directory exists!!"
>                          sys.exit(1)

I'd guess that you've got your p.expect line wrong -- it looks to me 
like you're allowing that line to complete only upon seeing an EOF or 
TIMEOUT, and that it's timing out as a result.

Emile




More information about the Python-list mailing list