pythonanywhere-core 0.2.6__tar.gz → 0.2.7__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.6 → pythonanywhere_core-0.2.7}/PKG-INFO +1 -1
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/pyproject.toml +1 -1
- pythonanywhere_core-0.2.7/pythonanywhere_core/__init__.py +1 -0
- pythonanywhere_core-0.2.7/pythonanywhere_core/resources.py +32 -0
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/pythonanywhere_core/website.py +1 -3
- pythonanywhere_core-0.2.6/pythonanywhere_core/__init__.py +0 -1
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/LICENSE +0 -0
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/README.rst +0 -0
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/pythonanywhere_core/base.py +0 -0
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/pythonanywhere_core/exceptions.py +0 -0
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/pythonanywhere_core/files.py +0 -0
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/pythonanywhere_core/schedule.py +0 -0
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/pythonanywhere_core/students.py +0 -0
- {pythonanywhere_core-0.2.6 → pythonanywhere_core-0.2.7}/pythonanywhere_core/webapp.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.7"
|
|
@@ -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 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.6"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|