mirror of
https://github.com/thombashi/subprocrunner.git
synced 2021-05-19 21:14:52 +03:00
Update examples
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
"collapsed": true,
|
||||
"deletable": true,
|
||||
"editable": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -15,19 +17,22 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
"collapsed": false,
|
||||
"deletable": true,
|
||||
"editable": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"command: echo test\n",
|
||||
"return code: 0\n",
|
||||
"stdout: test\n",
|
||||
"\n",
|
||||
"[stdout]\n",
|
||||
"test\n",
|
||||
"\n",
|
||||
"[stderr]\n",
|
||||
"command: ls __not_exist_dir__\n",
|
||||
"return code: 2\n",
|
||||
"stderr: ls: cannot access '__not_exist_dir__': No such file or directory\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
@@ -36,38 +41,44 @@
|
||||
"from subprocrunner import SubprocessRunner\n",
|
||||
"\n",
|
||||
"runner = SubprocessRunner(\"echo test\")\n",
|
||||
"print(\"return code: {:d}\\n\".format(runner.run()))\n",
|
||||
"print(\"[stdout]\\n{}\".format(runner.stdout))\n",
|
||||
"print(\"[stderr]\\n{}\".format(runner.stderr))\n"
|
||||
"print(\"command: {:s}\".format(runner.command))\n",
|
||||
"print(\"return code: {:d}\".format(runner.run()))\n",
|
||||
"print(\"stdout: {:s}\".format(runner.stdout))\n",
|
||||
"\n",
|
||||
"runner = SubprocessRunner(\"ls __not_exist_dir__\")\n",
|
||||
"print(\"command: {:s}\".format(runner.command))\n",
|
||||
"print(\"return code: {:d}\".format(runner.run()))\n",
|
||||
"print(\"stderr: {:s}\".format(runner.stderr))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
"collapsed": false,
|
||||
"deletable": true,
|
||||
"editable": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"return code: 2\n",
|
||||
"\n",
|
||||
"[stdout]\n",
|
||||
"\n",
|
||||
"[stderr]\n",
|
||||
"ls: cannot access '__not_exist_dir__': No such file or directory\n"
|
||||
"echo hoge\n",
|
||||
"echo foo\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from subprocrunner import SubprocessRunner\n",
|
||||
"\n",
|
||||
"runner = SubprocessRunner(\"ls __not_exist_dir__\")\n",
|
||||
"print(\"return code: {:d}\\n\".format(runner.run()))\n",
|
||||
"print(\"[stdout]\\n{}\".format(runner.stdout))\n",
|
||||
"print(\"[stderr]\\n{}\".format(runner.stderr))\n"
|
||||
"SubprocessRunner.clear_history()\n",
|
||||
"SubprocessRunner.is_save_history = True\n",
|
||||
"\n",
|
||||
"SubprocessRunner(\"echo hoge\").run()\n",
|
||||
"SubprocessRunner(\"echo foo\").run()\n",
|
||||
"\n",
|
||||
"print(\"\\n\".join(SubprocessRunner.get_history()))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user