pythonanywhere-core 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/PKG-INFO +2 -2
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/pyproject.toml +4 -3
- pythonanywhere_core-0.2.4/pythonanywhere_core/__init__.py +1 -0
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/pythonanywhere_core/base.py +2 -0
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/pythonanywhere_core/exceptions.py +4 -0
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/pythonanywhere_core/website.py +8 -32
- pythonanywhere_core-0.2.2/pythonanywhere_core/__init__.py +0 -1
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/LICENSE +0 -0
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/README.rst +0 -0
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/pythonanywhere_core/files.py +0 -0
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/pythonanywhere_core/schedule.py +0 -0
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/pythonanywhere_core/students.py +0 -0
- {pythonanywhere_core-0.2.2 → pythonanywhere_core-0.2.4}/pythonanywhere_core/webapp.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pythonanywhere-core
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: API wrapper for programmatic management of PythonAnywhere services.
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: pythonanywhere,api,cloud,web hosting
|
|
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
20
20
|
Classifier: Topic :: Software Development :: Libraries
|
|
21
21
|
Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
|
|
22
22
|
Requires-Dist: requests (>=2.30.0,<3.0.0)
|
|
23
|
-
Requires-Dist: snakesay (>=0.10.
|
|
23
|
+
Requires-Dist: snakesay (>=0.10.3,<0.11.0)
|
|
24
24
|
Requires-Dist: typing_extensions (>=4.5.0,<5.0.0)
|
|
25
25
|
Description-Content-Type: text/x-rst
|
|
26
26
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "pythonanywhere-core"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.4"
|
|
4
4
|
description = "API wrapper for programmatic management of PythonAnywhere services."
|
|
5
5
|
authors = ["PythonAnywhere <developers@pythonanywhere.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -10,6 +10,7 @@ classifiers = [
|
|
|
10
10
|
"Intended Audience :: Developers",
|
|
11
11
|
"Topic :: Software Development :: Libraries",
|
|
12
12
|
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Python :: 3.13",
|
|
13
14
|
"Programming Language :: Python :: 3.12",
|
|
14
15
|
"Programming Language :: Python :: 3.11",
|
|
15
16
|
"Programming Language :: Python :: 3.10",
|
|
@@ -22,7 +23,7 @@ keywords = ["pythonanywhere", "api", "cloud", "web hosting"]
|
|
|
22
23
|
python = "^3.8"
|
|
23
24
|
python-dateutil = "^2.8.2"
|
|
24
25
|
requests = "^2.30.0"
|
|
25
|
-
snakesay = "^0.10.
|
|
26
|
+
snakesay = "^0.10.3"
|
|
26
27
|
typing_extensions = "^4.5.0"
|
|
27
28
|
|
|
28
29
|
[tool.poetry.dev-dependencies]
|
|
@@ -31,7 +32,7 @@ pytest-cov = "^5.0.0"
|
|
|
31
32
|
pytest-mock = "^3.10.0"
|
|
32
33
|
responses = "^0.25.0"
|
|
33
34
|
sphinx = "7.1.2"
|
|
34
|
-
sphinx-rtd-theme = "^
|
|
35
|
+
sphinx-rtd-theme = "^3.0.0"
|
|
35
36
|
|
|
36
37
|
[tool.black]
|
|
37
38
|
line-length = 120
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.4"
|
|
@@ -4,7 +4,7 @@ from snakesay import snakesay
|
|
|
4
4
|
from textwrap import dedent
|
|
5
5
|
|
|
6
6
|
from pythonanywhere_core.base import call_api, get_api_endpoint
|
|
7
|
-
from pythonanywhere_core.exceptions import
|
|
7
|
+
from pythonanywhere_core.exceptions import DomainAlreadyExistsException, PythonAnywhereApiException
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class Website:
|
|
@@ -29,44 +29,14 @@ class Website:
|
|
|
29
29
|
self.websites_base_url = get_api_endpoint(username=getpass.getuser(), flavor="websites")
|
|
30
30
|
self.domains_base_url = get_api_endpoint(username=getpass.getuser(), flavor="domains")
|
|
31
31
|
|
|
32
|
-
def sanity_check(self, domain_name: str, nuke: bool = False) -> None:
|
|
33
|
-
"""Check that we have a token, and that we don't already have a webapp for this domain"""
|
|
34
|
-
print(snakesay("Running API sanity checks"))
|
|
35
|
-
token = os.environ.get("API_TOKEN")
|
|
36
|
-
if not token:
|
|
37
|
-
raise SanityException(
|
|
38
|
-
dedent(
|
|
39
|
-
"""
|
|
40
|
-
Could not find your API token.
|
|
41
|
-
You may need to create it on the Accounts page?
|
|
42
|
-
You will also need to close this console and open a new one once you've done that.
|
|
43
|
-
"""
|
|
44
|
-
)
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
if nuke:
|
|
48
|
-
return
|
|
49
32
|
|
|
50
|
-
|
|
51
|
-
f"{self.websites_base_url}{domain_name}/",
|
|
52
|
-
"get"
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
if response.status_code == 200:
|
|
56
|
-
raise SanityException(
|
|
57
|
-
f"You already have a webapp for {domain_name}.\n\nUse the --nuke option if you want to replace it."
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def create(self, domain_name: str, command: str, nuke: bool = False) -> dict:
|
|
33
|
+
def create(self, domain_name: str, command: str) -> dict:
|
|
62
34
|
"""Creates new website with ``domain_name`` and ``command``.
|
|
63
35
|
|
|
64
36
|
:param domain_name: domain name for new website
|
|
65
37
|
:param command: command for new website
|
|
66
38
|
:returns: dictionary with created website info"""
|
|
67
39
|
|
|
68
|
-
self.sanity_check(domain_name, nuke)
|
|
69
|
-
|
|
70
40
|
response = call_api(
|
|
71
41
|
self.websites_base_url,
|
|
72
42
|
"post",
|
|
@@ -76,6 +46,12 @@ class Website:
|
|
|
76
46
|
"webapp": {"command": command}
|
|
77
47
|
}
|
|
78
48
|
)
|
|
49
|
+
if response.status_code == 400 and "domain with this domain name already exists" in response.text:
|
|
50
|
+
raise DomainAlreadyExistsException
|
|
51
|
+
|
|
52
|
+
if not response.ok:
|
|
53
|
+
raise PythonAnywhereApiException(f"POST to create website failed with status code {response.status_code} and error message: {response.text}")
|
|
54
|
+
|
|
79
55
|
return response.json()
|
|
80
56
|
|
|
81
57
|
def get(self, domain_name: str) -> dict:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.2.0'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|