pythonanywhere-core 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl

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.
@@ -1 +1 @@
1
- __version__ = '0.2.0'
1
+ __version__ = "0.2.4"
@@ -12,6 +12,8 @@ PYTHON_VERSIONS: Dict[str, str] = {
12
12
  "3.9": "python39",
13
13
  "3.10": "python310",
14
14
  "3.11": "python311",
15
+ "3.12": "python312",
16
+ "3.13": "python313",
15
17
  }
16
18
 
17
19
 
@@ -12,3 +12,7 @@ class PythonAnywhereApiException(Exception):
12
12
 
13
13
  class NoTokenError(PythonAnywhereApiException):
14
14
  pass
15
+
16
+
17
+ class DomainAlreadyExistsException(PythonAnywhereApiException):
18
+ pass
@@ -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 SanityException, PythonAnywhereApiException
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
- response = call_api(
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pythonanywhere-core
3
- Version: 0.2.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.2,<0.11.0)
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
 
@@ -0,0 +1,12 @@
1
+ pythonanywhere_core/__init__.py,sha256=SBl2EPFW-ltPvQ7vbVWItyAsz3aKYIpjO7vcfr84GkU,22
2
+ pythonanywhere_core/base.py,sha256=ro1ByvW1Wlf8Qv2d3NFnHdmM7viujmDJmxUBATqvvHI,2572
3
+ pythonanywhere_core/exceptions.py,sha256=NT6JBtd0VK3PbFc69qx4bnAygA94-pOTghp70xxz1Xw,281
4
+ pythonanywhere_core/files.py,sha256=qIfbcg472TPeOejpif_i64PtWP_qROlxoz5JbePzX8Q,6491
5
+ pythonanywhere_core/schedule.py,sha256=giSO-Gssshkto9de2hSA3VeNKotXYu-lBG-iyqDolIw,3904
6
+ pythonanywhere_core/students.py,sha256=PeBLUP7AOCRwCDiaH71wURwFx3H3PLQW91f5AjOPQmU,1778
7
+ pythonanywhere_core/webapp.py,sha256=Oa4DTgFY3iMPsW_PqWGFb6WkMbCQz35q8VuK_-sKBKQ,8969
8
+ pythonanywhere_core/website.py,sha256=PZlheuqfD0_qYtcjb7fSyqq9KxphtTAXQwU0xrBKxOs,4415
9
+ pythonanywhere_core-0.2.4.dist-info/LICENSE,sha256=zOJT_E5Fv8crFEKS5ulv0btbjnUiIkdsEBPEBmLHRlQ,1080
10
+ pythonanywhere_core-0.2.4.dist-info/METADATA,sha256=l7aRizHVEIWWM8zDO5EOo9kCFQMLeh7z1RQrcQjNNns,1529
11
+ pythonanywhere_core-0.2.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ pythonanywhere_core-0.2.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,12 +0,0 @@
1
- pythonanywhere_core/__init__.py,sha256=FVHPBGkfhbQDi_z3v0PiKJrXXqXOx0vGW_1VaqNJi7U,22
2
- pythonanywhere_core/base.py,sha256=DobWnSmqhpszP1XqvxTdHYScl45AyMphrD1pAFZpLbI,2522
3
- pythonanywhere_core/exceptions.py,sha256=-Rklwd5mKRQ0z28L3cWqP_S2ONCBhSX1Kh8GnNRmDWM,207
4
- pythonanywhere_core/files.py,sha256=qIfbcg472TPeOejpif_i64PtWP_qROlxoz5JbePzX8Q,6491
5
- pythonanywhere_core/schedule.py,sha256=giSO-Gssshkto9de2hSA3VeNKotXYu-lBG-iyqDolIw,3904
6
- pythonanywhere_core/students.py,sha256=PeBLUP7AOCRwCDiaH71wURwFx3H3PLQW91f5AjOPQmU,1778
7
- pythonanywhere_core/webapp.py,sha256=Oa4DTgFY3iMPsW_PqWGFb6WkMbCQz35q8VuK_-sKBKQ,8969
8
- pythonanywhere_core/website.py,sha256=II4BZy47DP30P6eVh76iJSUd12HcSBfG0AFqiZ5HYME,5124
9
- pythonanywhere_core-0.2.2.dist-info/LICENSE,sha256=zOJT_E5Fv8crFEKS5ulv0btbjnUiIkdsEBPEBmLHRlQ,1080
10
- pythonanywhere_core-0.2.2.dist-info/METADATA,sha256=r0wiK6C4dcApri8TygyHyT2_-RkD-F5J8e1678ii9ps,1529
11
- pythonanywhere_core-0.2.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
12
- pythonanywhere_core-0.2.2.dist-info/RECORD,,