|
1 | | -[](https://travis-ci.org/pythonanywhere/helper_scripts) |
| 1 | + |
2 | 2 | [](https://opensource.org/licenses/MIT) |
3 | 3 | [](https://pypi.org/project/pythonanywhere/) |
4 | 4 | [](https://pepy.tech/project/pythonanywhere) |
5 | 5 |
|
6 | | -# PythonAnywhere helper scripts |
| 6 | +# PythonAnywhere cli tool |
7 | 7 |
|
8 | | -These scripts are designed to be run from PythonAnywhere consoles |
| 8 | +`pa` is a single command to manage PythonAnywhere services. |
| 9 | + |
| 10 | +It is designed to be run from PythonAnywhere consoles, but many subcommands can be executed directly |
| 11 | +from your own machine (see [usage](#Usage) below). |
9 | 12 |
|
10 | 13 | ## Installing |
| 14 | +### On PythonAnywhere |
| 15 | +In a PythonAnywhere Bash console, run: |
| 16 | + |
| 17 | + pip3.9 install --user pythonanywhere |
11 | 18 |
|
12 | | - pip3.6 install --user pythonanywhere |
| 19 | +If there is no `python3.9` on your PythonAnywhere account, |
| 20 | +you should upgrade your account to the newest system image. |
| 21 | +See [here](https://help.pythonanywhere.com/pages/ChangingSystemImage) how to do that. |
| 22 | +`pa` works with python 3.6, 3.7 and 3.8, but we recommend using the latest system image. |
| 23 | + |
| 24 | +### On your own machine |
| 25 | +Install the `pythonanywhere` package from [PyPI](https://pypi.org/project/pythonanywhere/). |
| 26 | +We recommend using `pipx` if you want to use it only as a cli tool, or a virtual environment |
| 27 | +if you want to use a programmatic interface in your own code. |
13 | 28 |
|
14 | | -If there is no `python3.6` on your PythonAnywhere account, |
15 | | -you should contact [[email protected]](mailto:[email protected]) and ask for an upgrade. |
16 | | - |
17 | 29 | ## Usage |
18 | 30 |
|
19 | | -There are two ways to use that package. You can just run the scripts or use underlying api wrappers directly in your scripts. |
| 31 | +There are two ways to use the package. You can just run the scripts or use the underlying api wrappers directly in your scripts. |
| 32 | + |
| 33 | +### Command line interface |
| 34 | + |
| 35 | +### Running `pa` on your local machine |
| 36 | + |
| 37 | +`pa` expects the presence of some environment variables that are provided when you run your code in a PythonAnywere console. |
| 38 | +You need to provide them if you run `pa` on your local machine. |
| 39 | + |
| 40 | +`API_TOKEN` -- you need to set this to allow `pa` to connect to the [PythonAnywere API](https://help.pythonanywhere.com/pages/API). |
| 41 | +To get an API token, log into PythonAnywhere and go to the "Account" page using the link at the top right. |
| 42 | +Click on the "API token" tab, and click the "Create a new API token" button to get your token. |
20 | 43 |
|
21 | | -There are scripts provided for dealing with web apps: |
| 44 | +`PYTHONANYWHERE_SITE` is used to connect to PythonAnywhere API and defaults to `www.pythonanywhere.com`, |
| 45 | +but you may need to set it to `eu.pythonanywhere.com` if you use our EU site. |
22 | 46 |
|
23 | | -* [pa_autoconfigure_django.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_autoconfigure_django.py) |
24 | | -* [pa_create_webapp_with_virtualenv.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_create_webapp_with_virtualenv.py) |
25 | | -* [pa_delete_webapp_logs.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_delete_webapp_logs.py) |
26 | | -* [pa_install_webapp_letsencrypt_ssl.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_install_webapp_letsencrypt_ssl.py) |
27 | | -* [pa_install_webapp_ssl.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_install_webapp_ssl.py) |
28 | | -* [pa_reload_webapp.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_reload_webapp.py) |
29 | | -* [pa_start_django_webapp_with_virtualenv.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_start_django_webapp_with_virtualenv.py) |
| 47 | +If your username on PythonAnywhere is different from the username on your local machine, |
| 48 | +you may need to set `USER` for the environment you run `pa` in. |
30 | 49 |
|
31 | | -and scheduled tasks: |
| 50 | +### Programmatic usage in your code |
32 | 51 |
|
33 | | -* [pa_create_scheduled_task.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_create_scheduled_task.py) |
34 | | -* [pa_delete_scheduled_task.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_delete_scheduled_task.py) |
35 | | -* [pa_get_scheduled_tasks_list.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_get_scheduled_tasks_list.py) |
36 | | -* [pa_get_scheduled_task_specs.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_get_scheduled_task_specs.py) |
37 | | -* [pa_update_scheduled_task.py](https://github.com/pythonanywhere/helper_scripts/blob/master/scripts/pa_update_scheduled_task.py) |
| 52 | +Take a look at the [`pythonanywhere.task`](https://github.com/pythonanywhere/helper_scripts/blob/master/pythonanywhere/task.py) |
| 53 | +module and docstrings of `pythonanywhere.task.Task` class and its methods. |
38 | 54 |
|
39 | | -Run any of them with `--help` flag to get information about usage. |
| 55 | +### Legacy scripts |
40 | 56 |
|
41 | | -See the [blog post](https://blog.pythonanywhere.com/155/) |
| 57 | +Some legacy [scripts](https://github.com/pythonanywhere/helper_scripts/blob/master/legacy.md) (separate for each action) are still available. |
42 | 58 |
|
43 | 59 | ## Contributing |
44 | 60 |
|
|
0 commit comments