From 0af54e6d15d76eb5e146e80f9a192b7adc732b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Garc=C3=ADa=20Amor?= Date: Mon, 10 Apr 2023 13:27:08 +0200 Subject: [PATCH] Adds several improvements and updates - Removes setup.py in favor of pyproject.toml. - Upgrades bootstrap to version 5.2.3. - Replace jquery functions with pure js. - Removes all external dependencies that were loaded from the HTML, now sysdweb can run in a completely isolated environment. - Fixes a problem that caused the journal not to be displayed in the systemd user units. --- .github/FUNDING.yml | 1 + .github/workflows/python-publish.yml | 28 ++ MANIFEST.in | 8 - README.md | 23 +- pyproject.toml | 55 ++++ requirements.txt | 4 - sysdweb.py => run.py | 2 +- setup.py | 65 ---- sysdweb.conf | 4 +- sysdweb/__init__.py | 15 - sysdweb/config.py | 96 +++--- sysdweb/main.py | 6 +- sysdweb/server.py | 28 +- sysdweb/systemd.py | 9 +- .../static/css/bootstrap-theme.min.css | 6 - .../templates/static/css/bootstrap.min.css | 11 +- .../static/css/bootstrap.min.css.map | 1 + sysdweb/templates/static/css/sysdweb.css | 12 +- .../fonts/glyphicons-halflings-regular.eot | Bin 20127 -> 0 bytes .../fonts/glyphicons-halflings-regular.svg | 288 ------------------ .../fonts/glyphicons-halflings-regular.ttf | Bin 45404 -> 0 bytes .../fonts/glyphicons-halflings-regular.woff | Bin 23424 -> 0 bytes .../fonts/glyphicons-halflings-regular.woff2 | Bin 18028 -> 0 bytes .../static/js/bootstrap.bundle.min.js | 7 + .../static/js/bootstrap.bundle.min.js.map | 1 + sysdweb/templates/static/js/bootstrap.min.js | 7 - sysdweb/templates/static/js/sysdweb.js | 46 +-- sysdweb/templates/views/index.tpl | 119 ++++---- sysdweb/templates/views/journal.tpl | 25 +- 29 files changed, 274 insertions(+), 593 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/python-publish.yml delete mode 100644 MANIFEST.in create mode 100644 pyproject.toml delete mode 100644 requirements.txt rename sysdweb.py => run.py (75%) delete mode 100644 setup.py delete mode 100644 sysdweb/templates/static/css/bootstrap-theme.min.css create mode 100644 sysdweb/templates/static/css/bootstrap.min.css.map delete mode 100644 sysdweb/templates/static/fonts/glyphicons-halflings-regular.eot delete mode 100644 sysdweb/templates/static/fonts/glyphicons-halflings-regular.svg delete mode 100644 sysdweb/templates/static/fonts/glyphicons-halflings-regular.ttf delete mode 100644 sysdweb/templates/static/fonts/glyphicons-halflings-regular.woff delete mode 100644 sysdweb/templates/static/fonts/glyphicons-halflings-regular.woff2 create mode 100644 sysdweb/templates/static/js/bootstrap.bundle.min.js create mode 100644 sysdweb/templates/static/js/bootstrap.bundle.min.js.map delete mode 100644 sysdweb/templates/static/js/bootstrap.min.js diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..201c1cf --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: ogarcia diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..28bad63 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,28 @@ +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + name: Upload to PyPi + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install build and publish dependencies + run: | + python -m pip install --upgrade pip + pip install build twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m build --sdist --no-isolation + twine upload dist/* diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 1085ca8..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,8 +0,0 @@ -# Include the license file -include LICENSE - -# Include the requirements file -include requirements.txt - -# Include the sample config file -include sysdweb.conf diff --git a/README.md b/README.md index 0c6b4f5..d28ca1a 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,7 @@ git clone https://github.com/ogarcia/sysdweb.git virtualenv3 ./sysdweb-venv source ./sysdweb-venv/bin/activate cd sysdweb -pip install -r requirements.txt -python setup.py install +pip install . ``` ### From pypi @@ -45,7 +44,7 @@ Once you have configured sysdweb, simply run. sysdweb ``` -By default sysdweb listen in 10080 port to 127.0.0.1, you can change listen +By default sysdweb listen in 10088 port to 127.0.0.1, you can change listen port and address with `-p` and `-l` or via environment variables. ```sh @@ -113,17 +112,17 @@ file of `` unit. You can specify the number of lines by this way. /api/v1//journal/200 ``` -In the example defined above all valid enpoins are. +In the example defined above all valid endpoints are. ``` -http://127.0.0.1:10080/api/v1/ngx/start -http://127.0.0.1:10080/api/v1/ngx/stop -http://127.0.0.1:10080/api/v1/ngx/restart -http://127.0.0.1:10080/api/v1/ngx/reload -http://127.0.0.1:10080/api/v1/ngx/reloadorrestart -http://127.0.0.1:10080/api/v1/ngx/status -http://127.0.0.1:10080/api/v1/ngx/journal -http://127.0.0.1:10080/api/v1/ngx/journal/ +http://127.0.0.1:10088/api/v1/ngx/start +http://127.0.0.1:10088/api/v1/ngx/stop +http://127.0.0.1:10088/api/v1/ngx/restart +http://127.0.0.1:10088/api/v1/ngx/reload +http://127.0.0.1:10088/api/v1/ngx/reloadorrestart +http://127.0.0.1:10088/api/v1/ngx/status +http://127.0.0.1:10088/api/v1/ngx/journal +http://127.0.0.1:10088/api/v1/ngx/journal/ ``` [1]: https://aur.archlinux.org/packages/sysdweb/ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5f819c7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "sysdweb" +version = "1.1.5" +description = "Control systemd services through Web or REST API" +readme = "README.md" +requires-python = ">=3.10" +license = {file = "LICENSE"} +keywords = ["REST API", "systemd"] +authors = [ + {name = "Óscar García Amor", email = "ogarcia@connectical.com"} +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Framework :: Bottle", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3", + "Topic :: System", + "Topic :: Utilities" +] +dependencies = [ + "bottle ~= 0.12.25", + "dbus-python ~= 1.3.2", + "python-pam ~= 2.0.2", + "systemd-python" +] + +[tool.setuptools.packages.find] +include = ["sysdweb*"] + +[tool.setuptools.package-data] +"*" = [ + "sysdweb.conf" +] +sysdweb = [ + "templates/static/css/*", + "templates/static/img/*", + "templates/static/js/*", + "templates/views/*" +] + +[project.scripts] +sysdweb = "sysdweb.main:main" + +[project.urls] +"Bug Reports" = "https://github.com/ogarcia/sysdweb/issues" +"Source" = "https://github.com/ogarcia/sysdweb" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d1e259c..0000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -bottle >= 0.12.10 -dbus-python -python-pam -systemd-python diff --git a/sysdweb.py b/run.py similarity index 75% rename from sysdweb.py rename to run.py index 2db37d8..3bd2a90 100755 --- a/sysdweb.py +++ b/run.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # vim:fenc=utf-8 # -# Copyright © 2016-2018 Óscar García Amor +# Copyright © 2016-2023 Óscar García Amor # # Distributed under terms of the GNU GPLv3 license. diff --git a/setup.py b/setup.py deleted file mode 100644 index d85067d..0000000 --- a/setup.py +++ /dev/null @@ -1,65 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf-8 -*- -# vim:fenc=utf-8 -# -# Copyright © 2016-2018 Óscar García Amor -# -# Distributed under terms of the GNU GPLv3 license. - -import sysdweb as project - -import os -from setuptools import find_packages -from setuptools import setup - -# Utility function to read the README file. -# Used for the long_description. It's nice, because now 1) we have a top level -# README file and 2) it's easier to type in the README file than to put a raw -# string in below ... -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() - -setup( - name = project.NAME, - version = project.VERSION, - author = project.AUTHOR_NAME, - author_email = project.AUTHOR_EMAIL, - description = project.DESCRIPTION, - license = project.LICENSE, - keywords = project.KEYWORDS, - url = project.URL, - long_description=read('README.md'), - long_description_content_type='text/markdown', - packages=find_packages(), - install_requires=read('requirements.txt'), - package_data={'sysdweb': [ - 'templates/static/css/*', - 'templates/static/fonts/*', - 'templates/static/img/*', - 'templates/static/js/*', - 'templates/views/*' - ] - }, - entry_points={ - 'console_scripts': [ - 'sysdweb = sysdweb.main:main' - ] - }, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Web Environment', - 'Framework :: Bottle', - 'Intended Audience :: End Users/Desktop', - 'Intended Audience :: System Administrators', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Natural Language :: English', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python :: 3', - 'Topic :: System', - 'Topic :: Utilities', - ], - project_urls={ - 'Bug Reports': 'https://github.com/ogarcia/sysdweb/issues', - 'Source': 'https://github.com/ogarcia/sysdweb', - }, -) diff --git a/sysdweb.conf b/sysdweb.conf index d757b99..5efd0ae 100644 --- a/sysdweb.conf +++ b/sysdweb.conf @@ -4,7 +4,7 @@ # # Entries consist of: # - [label]. It maches with URL /api/v1/