Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103449 > unrolled thread
| Started by | pyfreek <sruthi223@gmail.com> |
|---|---|
| First post | 2016-02-24 07:42 -0800 |
| Last post | 2016-02-25 07:12 -0800 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.python
child.before taking almost 1 minute to execute pyfreek <sruthi223@gmail.com> - 2016-02-24 07:42 -0800
Re: child.before taking almost 1 minute to execute Emile van Sebille <emile@fenx.com> - 2016-02-24 12:57 -0800
Re: child.before taking almost 1 minute to execute sruthi223@gmail.com - 2016-02-25 07:12 -0800
Re: child.before taking almost 1 minute to execute Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-02-25 10:09 +1300
Re: child.before taking almost 1 minute to execute sruthi223@gmail.com - 2016-02-25 07:12 -0800
| From | pyfreek <sruthi223@gmail.com> |
|---|---|
| Date | 2016-02-24 07:42 -0800 |
| Subject | child.before taking almost 1 minute to execute |
| Message-ID | <ae3896fc-10e2-436f-aaac-bfb201f83c81@googlegroups.com> |
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)
pyfreek
[toc] | [next] | [standalone]
| From | Emile van Sebille <emile@fenx.com> |
|---|---|
| Date | 2016-02-24 12:57 -0800 |
| Message-ID | <mailman.104.1456347518.20994.python-list@python.org> |
| In reply to | #103449 |
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
[toc] | [prev] | [next] | [standalone]
| From | sruthi223@gmail.com |
|---|---|
| Date | 2016-02-25 07:12 -0800 |
| Message-ID | <720905f6-dfd2-4580-8cd2-abb41a27343a@googlegroups.com> |
| In reply to | #103458 |
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?
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2016-02-25 10:09 +1300 |
| Message-ID | <dj6kh2FddcnU1@mid.individual.net> |
| In reply to | #103449 |
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
[toc] | [prev] | [next] | [standalone]
| From | sruthi223@gmail.com |
|---|---|
| Date | 2016-02-25 07:12 -0800 |
| Message-ID | <6df04be8-136f-4558-8e7e-874f7717f4b6@googlegroups.com> |
| In reply to | #103461 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web