Re: [Tutor] Confirmation if command worked

2011-08-25 Thread Steven D'Aprano
Steven D'Aprano wrote: if some_condition: flag = True else: flag = False is better written as: flag = some_condition Actually, that's a slight over-simplification. some_condition may not actually be a bool. If you don't mind flag also being a non-bool, that's fine, but if you want

Re: [Tutor] Confirmation if command worked

2011-08-25 Thread Steven D'Aprano
Christian Witts wrote: if child.exitstatus and child.exitstatus == 0: success = True else: success = False There is never any need to write Python code that looks like that. (Or in any other language I'm familiar with either.) Anything of the form: if some_conditio

Re: [Tutor] Confirmation if command worked

2011-08-25 Thread Steve Willoughby
On 25-Aug-11 01:37, Christian Witts wrote: Good catch, it should be `if child.exitstatus != None and child.exitstatus == 0:` It's better form to say if child.exitstatus is not None instead of comparing for equality to None with the != operator. -- Steve Willoughby / st...@alchemy.com

Re: [Tutor] Confirmation if command worked

2011-08-25 Thread Christian Witts
On 2011/08/25 10:19 AM, Alan Gauld wrote: On 25/08/11 07:25, Christian Witts wrote: Once you call child.close() the exit and signal status will be stored in .exitstatus and .signalstatus, for a normal exit of the program .exitstatus will store the return code from SCP as per [1] [2] [3] and .si

Re: [Tutor] Confirmation if command worked

2011-08-25 Thread Alan Gauld
On 25/08/11 07:25, Christian Witts wrote: Once you call child.close() the exit and signal status will be stored in .exitstatus and .signalstatus, for a normal exit of the program .exitstatus will store the return code from SCP as per [1] [2] [3] and .signalstatus will be None. If SCP was termin

Re: [Tutor] Confirmation if command worked

2011-08-24 Thread Johan Geldenhuys
Hi Christian, Thanks for that. I'll give it a shot and see if I can catch the error. Lekker dag Johan From: Christian Witts [mailto:cwi...@compuscan.co.za] Sent: Thursday, 25 August 2011 4:25 PM To: Johan Geldenhuys Cc: tutor@python.org Subject: Re: [Tutor] Confirmati

Re: [Tutor] Confirmation if command worked

2011-08-24 Thread Christian Witts
On 2011/08/25 07:51 AM, Johan Geldenhuys wrote: Hi all, I have the following code that uses pexpect to execute a system command. My problem is, I don't know how to identify if the command was successfully executed. The code works as it is to execute the SCP command, but it executes regardless i

[Tutor] Confirmation if command worked

2011-08-24 Thread Johan Geldenhuys
Hi all, I have the following code that uses pexpect to execute a system command. My problem is, I don't know how to identify if the command was successfully executed. The code works as it is to execute the SCP command, but it executes regardless if the SCP session can actually connect to somethin