{"action":"created","issue":{"url":"https://api.github.com/repos/scopatz/xonsh/issues/259","labels_url":"https://api.github.com/repos/scopatz/xonsh/issues/259/labels{/name}","comments_url":"https://api.github.com/repos/scopatz/xonsh/issues/259/comments","events_url":"https://api.github.com/repos/scopatz/xonsh/issues/259/events","html_url":"https://github.com/scopatz/xonsh/pull/259","id":84380104,"number":259,"title":"subprocess exit code exceptions","user":{"login":"rbrewer123","id":743058,"avatar_url":"https://avatars.githubusercontent.com/u/743058?v=3","gravatar_id":"","url":"https://api.github.com/users/rbrewer123","html_url":"https://github.com/rbrewer123","followers_url":"https://api.github.com/users/rbrewer123/followers","following_url":"https://api.github.com/users/rbrewer123/following{/other_user}","gists_url":"https://api.github.com/users/rbrewer123/gists{/gist_id}","starred_url":"https://api.github.com/users/rbrewer123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbrewer123/subscriptions","organizations_url":"https://api.github.com/users/rbrewer123/orgs","repos_url":"https://api.github.com/users/rbrewer123/repos","events_url":"https://api.github.com/users/rbrewer123/events{/privacy}","received_events_url":"https://api.github.com/users/rbrewer123/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-03T05:55:25Z","updated_at":"2015-08-08T22:54:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scopatz/xonsh/pulls/259","html_url":"https://github.com/scopatz/xonsh/pull/259","diff_url":"https://github.com/scopatz/xonsh/pull/259.diff","patch_url":"https://github.com/scopatz/xonsh/pull/259.patch"},"body":"This is a prototype implementation of #220 that will raise a ``subprocess.CalledProcessError`` for subprocesses that return a non-zero exitcode.  This behavior is only activated when the builtin ``__xonsh_subproc_check__`` is set to True (it defaults to False).\r\n\r\nThe below test script ``pinger.xsh`` demonstrates the feature.  Running the script like ``xonsh pinger.xsh localhost`` should print ``success``.  Running the script with an invalid host such as ``xonsh pinger.xsh badhost`` should show a traceback.\r\n\r\nUnfortunately, line 12 of ``pinger.xsh`` (assigning ``__xonsh_subproc_check__`` to True) is not what I would prefer.  I was imagining that a global like line 13 would work.  Any ideas for getting that behavior?  The idea is that line 13 could appear in any .xsh file that uses process-based exception handling, but other imported .xsh files that don't use that behavior would use the default behavior where the subprocess exit codes are not checked and no exceptions are raised.\r\n\r\nI'm interested in feedback and any tips on getting the behavior described above.  I'll probably also try to get a context manager for ``__xonsh_subproc_check__`` before asking this to be merged.\r\n\r\n```python\r\n#!/usr/bin/env xonsh\r\n#\r\n# Usage:\r\n#   pinger.xsh <hostname>\r\n#\r\n\r\nimport builtins\r\nimport platform\r\n\r\nON_WINDOWS = (platform.system() == 'Windows')\r\n\r\nbuiltins.__xonsh_subproc_check__ = True\r\n#__xonsh_subproc_check__ = True\r\n\r\nif ON_WINDOWS:\r\n    ping -n 1 $ARG1 &> NUL:\r\nelse:\r\n    ping -c 1 $ARG1 &> /dev/null\r\n\r\nprint('success')\r\n```"},"comment":{"url":"https://api.github.com/repos/scopatz/xonsh/issues/comments/129060449","html_url":"https://github.com/scopatz/xonsh/pull/259#issuecomment-129060449","issue_url":"https://api.github.com/repos/scopatz/xonsh/issues/259","id":129060449,"user":{"login":"rbrewer123","id":743058,"avatar_url":"https://avatars.githubusercontent.com/u/743058?v=3","gravatar_id":"","url":"https://api.github.com/users/rbrewer123","html_url":"https://github.com/rbrewer123","followers_url":"https://api.github.com/users/rbrewer123/followers","following_url":"https://api.github.com/users/rbrewer123/following{/other_user}","gists_url":"https://api.github.com/users/rbrewer123/gists{/gist_id}","starred_url":"https://api.github.com/users/rbrewer123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbrewer123/subscriptions","organizations_url":"https://api.github.com/users/rbrewer123/orgs","repos_url":"https://api.github.com/users/rbrewer123/repos","events_url":"https://api.github.com/users/rbrewer123/events{/privacy}","received_events_url":"https://api.github.com/users/rbrewer123/received_events","type":"User","site_admin":false},"created_at":"2015-08-08T22:54:41Z","updated_at":"2015-08-08T22:54:41Z","body":"@scopatz, github is saying it could still be merged automatically, has something changed?  I've been away and not following the latest happenings closely; hopefully sometime this week I can get caught up and take another look at this."}}