From 631c4e5bc999d94b58110ba4aa16dd608b846340 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Sun, 19 Apr 2020 07:03:33 +1000 Subject: [PATCH 1/2] Support Python 3 Signed-off-by: Christian Heinrich --- python/stathat.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/stathat.py b/python/stathat.py index 9b126ab..9dc878f 100644 --- a/python/stathat.py +++ b/python/stathat.py @@ -1,12 +1,13 @@ -import urllib -import urllib2 +from urllib.parse import urlencode +from urllib.request import Request, urlopen class StatHat: def http_post(self, path, data): - pdata = urllib.urlencode(data) - req = urllib2.Request('http://api.stathat.com' + path, pdata) - resp = urllib2.urlopen(req) + pdata = urlencode(data) + pdata = pdata.encode('ascii') + req = Request('http://api.stathat.com' + path, pdata) + resp = urlopen(req) return resp.read() def post_value(self, user_key, stat_key, value, timestamp=None): From cc2554bd2c1b40768bc9698cfb58558c35547682 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Tue, 12 Jul 2022 01:14:42 -0400 Subject: [PATCH 2/2] Create Python Package --- python/LICENSE | 21 +++++++++++++++++++++ python/README.md | 1 + python/pyproject.toml | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 python/LICENSE create mode 100644 python/README.md create mode 100644 python/pyproject.toml diff --git a/python/LICENSE b/python/LICENSE new file mode 100644 index 0000000..645cde3 --- /dev/null +++ b/python/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Numerotron Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/python/README.md b/python/README.md new file mode 100644 index 0000000..a8576d0 --- /dev/null +++ b/python/README.md @@ -0,0 +1 @@ +A Python Library to interface with [Stathat](https://www.stathat.com/) diff --git a/python/pyproject.toml b/python/pyproject.toml new file mode 100644 index 0000000..890a80e --- /dev/null +++ b/python/pyproject.toml @@ -0,0 +1,22 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" +[project] +name = "stathat" +version = "0.0.1" +authors = [ + { name="Christian Heinrich", email="christian.heinrich@cmlh.id.au" }, +] +description = "A Python Library to interface with Stathat" +readme = "README.md" +license = { file="LICENSE" } +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://github.com/stathat/shlibs" +"Bug Tracker" = "https://github.com/stathat/shlib/issues"