Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check for retcode when perform stdout redirect #344

Open
ela34 opened this issue Aug 29, 2017 · 1 comment
Open

How to check for retcode when perform stdout redirect #344

ela34 opened this issue Aug 29, 2017 · 1 comment

Comments

@ela34
Copy link

ela34 commented Aug 29, 2017

I want to do something like this:

  • downloading a file by redirecting curl output to the file and checking curl retcode

I have try this syntax, and I'm probably doing something wrong, but I cannot find out the correct way to achieve this.

(curl('https://www.mysite.com/file', retcode=0) > 'file.txt')()

This version is working:
(curl['https://www.mysite.com/file'] > 'file.txt')()

Any help greatly appreciated.
Thanks.

@ASMfreaK
Copy link
Contributor

Retcode is already checked by plumbum. In example you've given. If retcode is not 0 then a ProcessExecutionError is raised

(curl['https://www.mysite.com/file'] > 'file.txt')()
---------------------------------------------------------------------------
ProcessExecutionError                     Traceback (most recent call last)
<ipython-input-44-d25eb1cb8cba> in <module>()
----> 1 (curl['https://www.mysite.com/file'] > 'file.txt')()
...(Traceback omitted)...
ProcessExecutionError: Command line: ['/usr/bin/curl', 'https://www.mysite.com/file']
Exit code: 7
Stderr:  |   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
         |                                  Dload  Upload   Total   Spent    Left  Speed
         | 
         |   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
         |   0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
         |   0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
         |   0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
         |   0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
         |   0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
curl: (7) Failed to connect to www.mysite.com port 443: В соединении отказано

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants