prepare pypi release and fix add monitor

This commit is contained in:
lucasheld 2022-07-07 22:17:47 +02:00
parent b87a1bdaf0
commit 140784c4e0
13 changed files with 96 additions and 52 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ venv
.envrc .envrc
__pycache__ __pycache__
*.egg-info *.egg-info
dist

View file

@ -1,7 +1,7 @@
import re import re
import os import os
from uptimekumaapi import notification_provider_options from uptime_kuma_api import notification_provider_options
def build_notification_provider_map(): def build_notification_provider_map():

View file

@ -1,12 +1,48 @@
from setuptools import setup, find_packages from setuptools import setup
from codecs import open
import os
import sys
# "setup.py publish" shortcut.
if sys.argv[-1] == "publish":
os.system("rm dist/*")
os.system("python setup.py sdist")
os.system("twine upload --repository-url https://test.pypi.org/legacy/ dist/*")
sys.exit()
info = {}
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, "uptime_kuma_api", "__version__.py"), "r", "utf-8") as f:
exec(f.read(), info)
setup( setup(
name="uptimekumaapi", name=info["__title__"],
version="0.0.0", version=info["__version__"],
packages=find_packages(), description="A python wrapper for the Uptime Kuma WebSocket API",
install_requires=[ url="https://github.com/lucasheld/uptime-kuma-api",
"python-socketio==5.6.0", author=info["__author__"],
"requests==2.28.1", author_email="lucasheld@hotmail.de",
"websocket-client==1.3.3", # license=info["__license__"],
], packages=["uptime_kuma_api"],
python_requires=">=3.6, <4",
install_requires=["python-socketio", "requests", "websocket-client"],
classifiers=[
"Development Status :: 1 - Planning",
"Environment :: Web Environment",
"Intended Audience :: Developers",
# "License :: OSI Approved :: ",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries"
]
) )

View file

@ -1,3 +1,4 @@
from .__version__ import __title__, __version__, __author__, __copyright__
from .auth_method import AuthMethod from .auth_method import AuthMethod
from .monitor_type import MonitorType from .monitor_type import MonitorType
from .notification_providers import NotificationType, notification_provider_options from .notification_providers import NotificationType, notification_provider_options

View file

@ -0,0 +1,5 @@
__title__ = "uptime_kuma_api"
__version__ = "0.0.3"
__author__ = "Lucas Held"
# __license__ = ""
__copyright__ = "Copyright 2022 Lucas Held"

View file

@ -14,7 +14,7 @@ from . import convert_from_socket, convert_to_socket, params_map_monitor, params
from . import UptimeKumaException from . import UptimeKumaException
def int_to_bool(data: list[dict] | dict, keys): def int_to_bool(data, keys):
if type(data) == list: if type(data) == list:
for d in data: for d in data:
int_to_bool(d, keys) int_to_bool(d, keys)
@ -102,7 +102,7 @@ def _build_monitor_data(
"keyword": keyword, "keyword": keyword,
}) })
if type_ in [MonitorType.HTTP, MonitorType.KEYWORD]: # if type_ in [MonitorType.HTTP, MonitorType.KEYWORD]:
data.update({ data.update({
"url": url, "url": url,
"certificate_expiry_notification": certificate_expiry_notification, "certificate_expiry_notification": certificate_expiry_notification,
@ -128,7 +128,7 @@ def _build_monitor_data(
"auth_workstation": auth_workstation, "auth_workstation": auth_workstation,
}) })
if type_ in [MonitorType.DNS, MonitorType.PING, MonitorType.STEAM, MonitorType.MQTT]: # if type_ in [MonitorType.DNS, MonitorType.PING, MonitorType.STEAM, MonitorType.MQTT]:
data.update({ data.update({
"hostname": hostname, "hostname": hostname,
}) })
@ -138,13 +138,13 @@ def _build_monitor_data(
"port": port, "port": port,
}) })
if type_ == MonitorType.DNS: # if type_ == MonitorType.DNS:
data.update({ data.update({
"dns_resolve_server": dns_resolve_server, "dns_resolve_server": dns_resolve_server,
"dns_resolve_type": dns_resolve_type, "dns_resolve_type": dns_resolve_type,
}) })
if type_ == MonitorType.MQTT: # if type_ == MonitorType.MQTT:
data.update({ data.update({
"mqtt_username": mqtt_username, "mqtt_username": mqtt_username,
"mqtt_password": mqtt_password, "mqtt_password": mqtt_password,
@ -286,7 +286,8 @@ class UptimeKumaApi(object):
def _call(self, event, data=None): def _call(self, event, data=None):
r = self.sio.call(event, data) r = self.sio.call(event, data)
if type(r) == dict and not r["ok"]: if type(r) == dict and "ok" in r:
if not r["ok"]:
raise UptimeKumaException(r["msg"]) raise UptimeKumaException(r["msg"])
r.pop("ok") r.pop("ok")
return r return r

View file

@ -207,7 +207,7 @@ params_map_settings = {
} }
def _convert_to_from_socket(params_map: dict[str, str], params: list[dict] | dict | str, to_socket=False): def _convert_to_from_socket(params_map: dict[str, str], params, to_socket=False):
if type(params) == list: if type(params) == list:
out = [] out = []
params_list = params params_list = params