pythonanywhere-core 0.3.1__tar.gz → 0.3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonanywhere-core
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: API wrapper for programmatic management of PythonAnywhere services.
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pythonanywhere-core"
3
- version = "0.3.1"
3
+ version = "0.3.2"
4
4
  description = "API wrapper for programmatic management of PythonAnywhere services."
5
5
  authors = ["PythonAnywhere <developers@pythonanywhere.com>"]
6
6
  license = "MIT"
@@ -0,0 +1 @@
1
+ __version__ = "0.3.2"
@@ -96,6 +96,5 @@ def call_api(url: str, method: str, **kwargs) -> requests.Response:
96
96
  **kwargs,
97
97
  )
98
98
  if response.status_code == 401:
99
- print(response, response.text)
100
99
  raise AuthenticationError(f"Authentication error {response.status_code} calling API: {response.text}")
101
100
  return response
@@ -137,7 +137,7 @@ class Files:
137
137
  """Checks sharing status for a `path`.
138
138
 
139
139
  Returns url with sharing link if file is shared or an empty
140
- string otherwise."""
140
+ string on HTTP 404 (not shared). Raises on other API errors."""
141
141
 
142
142
  url = f"{self.sharing_endpoint}?path={path}"
143
143
 
@@ -145,9 +145,13 @@ class Files:
145
145
  if result.ok:
146
146
  sharing_url_suffix = result.json()["url"]
147
147
  return self._make_sharing_url(sharing_url_suffix)
148
- else:
148
+ if result.status_code == 404:
149
149
  return ""
150
150
 
151
+ raise PythonAnywhereApiException(
152
+ f"GET sharing status for {url} failed, got {result}{self._error_msg(result)}"
153
+ )
154
+
151
155
  def sharing_delete(self, path: str) -> int:
152
156
  """Stops sharing file at `path`.
153
157
 
@@ -110,10 +110,15 @@ class Website:
110
110
  def delete(self, domain_name: str) -> dict:
111
111
  """Deletes website with ``domain_name``.
112
112
  :param domain_name: domain name for website to delete
113
- :return: empty dictionary"""
113
+ :return: empty dictionary on HTTP 204
114
+ :raises PythonAnywhereApiException: if the response is not HTTP 204"""
114
115
 
115
- call_api(
116
+ response = call_api(
116
117
  f"{self.websites_base_url}{domain_name}/",
117
118
  "delete",
118
119
  )
120
+ if response.status_code != 204:
121
+ raise PythonAnywhereApiException(
122
+ f"DELETE website via API failed, got {response}:{response.text}"
123
+ )
119
124
  return {}
@@ -1 +0,0 @@
1
- __version__ = "0.3.1"