Re: child.before taking almost 1 minute to execute

2016-02-25 Thread sruthi223
On Wednesday, February 24, 2016 at 3:59:01 PM UTC-5, Emile van Sebille wrote:
> 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

HI EMile,

Thanks for the reply. If I exit based only on EOF, then does it work?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: child.before taking almost 1 minute to execute

2016-02-25 Thread sruthi223
On Wednesday, February 24, 2016 at 4:10:13 PM UTC-5, Gregory Ewing wrote:
> 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)
> 
> If you're talking to an ftp client here, you might like
> to consider using the ftplib module in the standard
> library. It ought to take care of the messy details
> of error detection for you.
> 
> -- 
> Greg

Thanks greg, but my organization is using pexpect as a part of its libraries. 
so I am trying to use the same.
-- 
https://mail.python.org/mailman/listinfo/python-list