Name | runscript JSON |
Version |
0.3.5
JSON |
| download |
home_page | |
Summary | Simple script launcher |
upload_time | 2023-08-11 13:49:37 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | The MIT License (MIT) Copyright (c) 2014, Gregory Petukhov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
script
cli
utility
run
launch
task
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
|
coveralls test coverage |
No coveralls.
|
# Runscript package
It is not a rare case when the project has a few tasks to run periodically or at certain times e.g. deploying the project on the server or initial generation of data for new work place. Runscript package provides simple `run` utility that you can use to run your tasks. The `run` command is nothing more than launcher of the `main()` function of one of your scripts stored in predefined directory. Also `run` utility slightly simplifies the handling of command line arguments.
## Real world example
Suppose you need to save some data from database into text file. For example, you have some web-site with user accounts and you want to dump the ID of each user account and also its email. Also you want to be able to choose the country of accounts to dump. Create "script/" directory in the root of your project and then create the file "script/dump.py" with content:
```python
import pymongo
def setup_arg_parser(parser):
parser.add_argument('-c', '--count')
def main(count, **kwargs):
with open('export/user.csv', 'w') as out:
for user in db.user.find({'country': country}):
out.write('%s:%s\n' % (user['_id'], user['email']))
```
Few words about what is going here. The value of `parser` option that is passed to `setup_arg_parser` is the instance of `ArgumentParser` class. You can add any option you need or just do not specify `setup_arg_parser` in you script. If you define some custom options then their values will be passed in `**kwargs` arguments to your `main` function.
OK, now you can run the following command from the console:
```shell
$ run dump
```
That's all :) Of course this is not the rocket science, but I found that this simple script launcher saved me a lot of time.
Raw data
{
"_id": null,
"home_page": "",
"name": "runscript",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "script,cli,utility,run,launch,task",
"author": "",
"author_email": "Gregory Petukhov <lorien@lorien.name>",
"download_url": "https://files.pythonhosted.org/packages/e6/81/9d298a1417bf04925b2066d5115032498b730e5f3b400be00cdfd310929e/runscript-0.3.5.tar.gz",
"platform": null,
"description": "# Runscript package\n\nIt is not a rare case when the project has a few tasks to run periodically or at certain times e.g. deploying the project on the server or initial generation of data for new work place. Runscript package provides simple `run` utility that you can use to run your tasks. The `run` command is nothing more than launcher of the `main()` function of one of your scripts stored in predefined directory. Also `run` utility slightly simplifies the handling of command line arguments.\n\n\n## Real world example\n\nSuppose you need to save some data from database into text file. For example, you have some web-site with user accounts and you want to dump the ID of each user account and also its email. Also you want to be able to choose the country of accounts to dump. Create \"script/\" directory in the root of your project and then create the file \"script/dump.py\" with content:\n\n```python\nimport pymongo\n\ndef setup_arg_parser(parser):\n parser.add_argument('-c', '--count')\n\ndef main(count, **kwargs):\n with open('export/user.csv', 'w') as out:\n for user in db.user.find({'country': country}):\n out.write('%s:%s\\n' % (user['_id'], user['email'])) \n```\n\n\nFew words about what is going here. The value of `parser` option that is passed to `setup_arg_parser` is the instance of `ArgumentParser` class. You can add any option you need or just do not specify `setup_arg_parser` in you script. If you define some custom options then their values will be passed in `**kwargs` arguments to your `main` function.\n\nOK, now you can run the following command from the console:\n\n```shell\n$ run dump\n```\n\nThat's all :) Of course this is not the rocket science, but I found that this simple script launcher saved me a lot of time.\n",
"bugtrack_url": null,
"license": "The MIT License (MIT) Copyright (c) 2014, Gregory Petukhov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Simple script launcher",
"version": "0.3.5",
"project_urls": {
"homepage": "http://github.com/lorien/runscript"
},
"split_keywords": [
"script",
"cli",
"utility",
"run",
"launch",
"task"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e6819d298a1417bf04925b2066d5115032498b730e5f3b400be00cdfd310929e",
"md5": "013ae2bf858fcd7545636c8887390948",
"sha256": "8b79c169a17b160181e496f8e4a66bb5323081d0ed43db7ec8785093ea067302"
},
"downloads": -1,
"filename": "runscript-0.3.5.tar.gz",
"has_sig": false,
"md5_digest": "013ae2bf858fcd7545636c8887390948",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6107,
"upload_time": "2023-08-11T13:49:37",
"upload_time_iso_8601": "2023-08-11T13:49:37.914163Z",
"url": "https://files.pythonhosted.org/packages/e6/81/9d298a1417bf04925b2066d5115032498b730e5f3b400be00cdfd310929e/runscript-0.3.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-11 13:49:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lorien",
"github_project": "runscript",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "runscript"
}