pythonanywhere-core 0.2.6__tar.gz → 0.2.8__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,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: pythonanywhere-core
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: API wrapper for programmatic management of PythonAnywhere services.
5
5
  License: MIT
6
+ License-File: LICENSE
6
7
  Keywords: pythonanywhere,api,cloud,web hosting
7
8
  Author: PythonAnywhere
8
9
  Author-email: developers@pythonanywhere.com
@@ -15,11 +16,15 @@ Classifier: Programming Language :: Python :: 3.10
15
16
  Classifier: Programming Language :: Python :: 3.11
16
17
  Classifier: Programming Language :: Python :: 3.12
17
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
18
20
  Classifier: Topic :: Software Development :: Libraries
19
21
  Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
20
22
  Requires-Dist: requests (>=2.30.0,<3.0.0)
21
23
  Requires-Dist: snakesay (>=0.10.3,<0.11.0)
22
24
  Requires-Dist: typing_extensions (>=4.5.0,<5.0.0)
25
+ Project-URL: Documentation, https://core.pythonanywhere.com/
26
+ Project-URL: Homepage, https://core.pythonanywhere.com/
27
+ Project-URL: Repository, https://github.com/pythonanywhere/pythonanywhere-core
23
28
  Description-Content-Type: text/x-rst
24
29
 
25
30
  API wrapper for programmatic management of PythonAnywhere services.
@@ -28,6 +33,11 @@ It's a core code behind `PythonAnywhere cli tool`_.
28
33
 
29
34
  .. _PythonAnywhere cli tool: https://pypi.org/project/pythonanywhere/
30
35
 
36
+ Documentation
37
+ =============
38
+
39
+ Full documentation is available at https://core.pythonanywhere.com/
40
+
31
41
 
32
42
  Development
33
43
  ===========
@@ -4,6 +4,11 @@ It's a core code behind `PythonAnywhere cli tool`_.
4
4
 
5
5
  .. _PythonAnywhere cli tool: https://pypi.org/project/pythonanywhere/
6
6
 
7
+ Documentation
8
+ =============
9
+
10
+ Full documentation is available at https://core.pythonanywhere.com/
11
+
7
12
 
8
13
  Development
9
14
  ===========
@@ -1,10 +1,13 @@
1
1
  [tool.poetry]
2
2
  name = "pythonanywhere-core"
3
- version = "0.2.6"
3
+ version = "0.2.8"
4
4
  description = "API wrapper for programmatic management of PythonAnywhere services."
5
5
  authors = ["PythonAnywhere <developers@pythonanywhere.com>"]
6
6
  license = "MIT"
7
7
  readme = "README.rst"
8
+ homepage = "https://core.pythonanywhere.com/"
9
+ documentation = "https://core.pythonanywhere.com/"
10
+ repository = "https://github.com/pythonanywhere/pythonanywhere-core"
8
11
  classifiers = [
9
12
  "Development Status :: 3 - Alpha",
10
13
  "Intended Audience :: Developers",
@@ -26,7 +29,7 @@ typing_extensions = "^4.5.0"
26
29
 
27
30
  [tool.poetry.group.dev.dependencies]
28
31
  pytest = "^8.0.0"
29
- pytest-cov = "^6.0.0"
32
+ pytest-cov = "^7.0.0"
30
33
  pytest-mock = "^3.10.0"
31
34
  responses = "^0.25.0"
32
35
  sphinx = "7.4.7"
@@ -0,0 +1 @@
1
+ __version__ = "0.2.8"
@@ -14,6 +14,7 @@ PYTHON_VERSIONS: Dict[str, str] = {
14
14
  "3.11": "python311",
15
15
  "3.12": "python312",
16
16
  "3.13": "python313",
17
+ "3.14": "python314",
17
18
  }
18
19
 
19
20
 
@@ -58,12 +59,10 @@ def call_api(url: str, method: str, **kwargs) -> requests.Response:
58
59
  token = os.environ.get("API_TOKEN")
59
60
  if token is None:
60
61
  raise NoTokenError(helpful_token_error_message())
61
- insecure = os.environ.get("PYTHONANYWHERE_INSECURE_API") == "true"
62
62
  response = requests.request(
63
63
  method=method,
64
64
  url=url,
65
65
  headers={"Authorization": f"Token {token}"},
66
- verify=not insecure,
67
66
  **kwargs,
68
67
  )
69
68
  if response.status_code == 401:
@@ -0,0 +1,32 @@
1
+ import getpass
2
+
3
+ from pythonanywhere_core.base import call_api, get_api_endpoint
4
+ from pythonanywhere_core.exceptions import PythonAnywhereApiException
5
+
6
+
7
+ class CPU:
8
+ """Interface for PythonAnywhere CPU resources API.
9
+
10
+ Uses `pythonanywhere_core.base` :method: `get_api_endpoint` to
11
+ create url, which is stored in a class variable `CPU.base_url`,
12
+ then calls `call_api` with appropriate arguments to execute CPU
13
+ resource actions.
14
+
15
+ Methods:
16
+ - :meth:`CPU.get_cpu_usage`: Get current CPU usage information.
17
+ """
18
+
19
+ def __init__(self):
20
+ self.base_url = get_api_endpoint(username=getpass.getuser(), flavor="cpu")
21
+
22
+ def get_cpu_usage(self):
23
+ """Get current CPU usage information.
24
+
25
+ :returns: dictionary with CPU usage information including daily limit,
26
+ total usage, and next reset time
27
+ :raises PythonAnywhereApiException: if API call fails
28
+ """
29
+ response = call_api(url=self.base_url, method="GET")
30
+ if not response.ok:
31
+ raise PythonAnywhereApiException(f"GET to {self.base_url} failed, got {response}:{response.text}")
32
+ return response.json()
@@ -1,7 +1,5 @@
1
- import os
2
1
  import getpass
3
- from snakesay import snakesay
4
- from textwrap import dedent
2
+
5
3
 
6
4
  from pythonanywhere_core.base import call_api, get_api_endpoint
7
5
  from pythonanywhere_core.exceptions import DomainAlreadyExistsException, PythonAnywhereApiException
@@ -1 +0,0 @@
1
- __version__ = "0.2.6"