summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Gonzalez <roger@rogs.me>2023-08-17 11:35:32 -0300
committerRoger Gonzalez <roger@rogs.me>2023-08-17 11:35:32 -0300
commit2f68cf8907af297b7d58ea286d37ca1ce8f11f85 (patch)
tree26107ac17c574bce0c75f7fefb777e4c2aca18c4
parente97d289e11c5281b60d0e8d88a9d027f87ec289d (diff)
Added gitlab-ci, testing first automatic deployment
-rw-r--r--.gitlab-ci.yml7
-rwxr-xr-xpyproject.toml7
-rw-r--r--src/ute_wrapper/__init__.py (renamed from src/ute/__init__.py)0
-rwxr-xr-xsrc/ute_wrapper/ute.py (renamed from src/ute/ute.py)36
-rw-r--r--src/ute_wrapper/utils.py (renamed from src/ute/utils.py)0
5 files changed, 19 insertions, 31 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..41ad7e1
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,7 @@
+image: python:latest
+
+run:
+ script:
+ - pip install build twine
+ - python -m build
+ - TWINE_PASSWORD=$PYPI_PASSWORD TWINE_USERNAME=$PYPI_USERNAME python3 -m twine upload --repository testpypi dist/*
diff --git a/pyproject.toml b/pyproject.toml
index 8ebcc82..a1a8217 100755
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -45,16 +45,19 @@ build-backend = "hatchling.build"
[project]
name = "ute_wrapper"
-version = "1.0.0"
+version = "1.0.5"
authors = [
{ name="Roger Gonzalez", email="roger@rogs.me" },
]
description = "A wrapper to interact with UTE's API"
+dependencies = [
+ "requests"
+]
readme = "README.md"
requires-python = ">=3.7"
+license = {file = "LICENSE"}
classifiers = [
"Programming Language :: Python :: 3",
- "License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
diff --git a/src/ute/__init__.py b/src/ute_wrapper/__init__.py
index e69de29..e69de29 100644
--- a/src/ute/__init__.py
+++ b/src/ute_wrapper/__init__.py
diff --git a/src/ute/ute.py b/src/ute_wrapper/ute.py
index 7685685..aa53bca 100755
--- a/src/ute/ute.py
+++ b/src/ute_wrapper/ute.py
@@ -16,15 +16,11 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
-import os
from datetime import datetime, timedelta
from time import sleep
from typing import List, Optional
-from dotenv import load_dotenv
-from utils import get_average_price, make_request
-
-load_dotenv()
+from .utils import make_request
BASE_URL = "https://rocme.ute.com.uy/api/v1"
@@ -50,7 +46,7 @@ def login(email: str, phone_number: str) -> str:
return make_request("POST", url, data=data).text
-def get_ute_device_list() -> List[dict]:
+def get_ute_device_list(authorization: str) -> List[dict]:
"""
Get UTE device list
@@ -62,7 +58,7 @@ def get_ute_device_list() -> List[dict]:
return make_request("GET", accounts_url, authorization=authorization).json()["data"]
-def get_ute_account_info(device_id: str) -> dict:
+def get_ute_account_info(device_id: str, authorization: str) -> dict:
"""
Get UTE account info from device id
@@ -77,7 +73,7 @@ def get_ute_account_info(device_id: str) -> dict:
return make_request("GET", accounts_by_id_url, authorization=authorization).json()["data"]
-def get_ute_peak_info(device_id: str) -> dict:
+def get_ute_peak_info(device_id: str, authorization: str) -> dict:
"""
Get UTE peak info from device id
@@ -92,7 +88,7 @@ def get_ute_peak_info(device_id: str) -> dict:
return make_request("GET", peak_by_id_url, authorization=authorization).json()["data"]
-def get_ute_network_status() -> dict:
+def get_ute_network_status(authorization: str) -> dict:
"""
Get UTE network status from device id
@@ -104,7 +100,7 @@ def get_ute_network_status() -> dict:
return make_request("GET", network_status_url, authorization=authorization).json()["data"]["summary"]
-def get_ute_renewable_sources() -> str:
+def get_ute_renewable_sources(authorization: str) -> str:
"""
Get UTE renewable sources
@@ -119,6 +115,7 @@ def get_ute_renewable_sources() -> str:
def get_ute_historic_info(
device_id: str,
authorization: str,
+ average_price: float,
cost_per_kwh: float,
date_start: Optional[str] = None,
date_end: Optional[str] = None,
@@ -229,22 +226,3 @@ def get_current_usage_info(device_id: str, authorization: str) -> dict:
return_dict["data"]["power_in_watts"] = power_in_watts
return return_dict
-
-
-if __name__ == "__main__":
- date_start = "2023-08-01"
- date_end = "2023-08-31"
- EMAIL = os.environ.get("EMAIL")
- PHONE_NUMBER = os.environ.get("PHONE_NUMBER")
-
- average_price = get_average_price("triple")
- authorization = login(EMAIL, PHONE_NUMBER)
- device_list = get_ute_device_list()
- device_id = device_list[0]["accountServicePointId"]
- account_info = get_ute_account_info(device_id)
- peak_info = get_ute_peak_info(device_id)
- network_status = get_ute_network_status()
- renewable_sources = get_ute_renewable_sources()
-
- ute_historic_usage = get_ute_historic_info(device_id, authorization, average_price, date_start, date_end)
- ute_current_usage = get_current_usage_info(device_id, authorization)
diff --git a/src/ute/utils.py b/src/ute_wrapper/utils.py
index 530d508..530d508 100644
--- a/src/ute/utils.py
+++ b/src/ute_wrapper/utils.py