Compare commits

...

5 Commits
0.2 ... main

Author SHA1 Message Date
trueold89 63a941b52b
Json files are h-readable now 2024-03-28 01:02:07 +03:00
trueold89 635e0b55f8
0.2.1
- Now you can manage multiple services
- Reviewed-on: #2
2024-03-28 00:11:47 +03:00
trueold89 f245de2044
Add xbps-src template 2024-03-28 00:07:28 +03:00
trueold89 3f15909e69
Update README.md && setup.py 2024-03-28 00:07:21 +03:00
trueold89 ae747ca569
You can now manage multiple services && main.py is now indexed in the repository 2024-03-27 23:45:34 +03:00
8 changed files with 84 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
old/
VoidServiceControl/main.py
__pycache__
.idea
.venv

View File

@ -1,6 +1,12 @@
# Void Service Control (VSC)
## A simple script that will allow you to manage runit services in Void Linux
## Available on:
[![](https://cloud.orudo.ru/apps/files_sharing/publicpreview/RpcoJB8FwgNmqHC?file=/&fileId=48757&x=1920&y=1200&a=true&etag=10effec96382ba8b9fc181a5c1c85012)](https://git.orudo.ru/trueold89/void-service-control)
[![](https://cloud.orudo.ru/s/D8xtkTS8ZBCq8fC/download/GH.png)](https://github.com/Trueold89/void-service-control)
***
- [Installation](#install)
- [Usage](#usage)
- [Build from sources](#build-from_sources)
@ -14,7 +20,7 @@
From [git.orudo.ru](https://git.orudo.ru/trueold89/void-service-control/releases):
```bash
$ pip install https://git.orudo.ru/trueold89/void-service-control/releases/download/0.2/VoidServiceControl-0.2.tar.gz
$ pip install https://git.orudo.ru/trueold89/void-service-control/releases/download/0.2.1/VoidServiceControl-0.2.1.tar.gz
```
or pypi
@ -26,6 +32,12 @@ $ pip install void-service-control
**Or by downloading the pre-built binary / xbps-package from the **[releases](https://git.orudo.ru/trueold89/void-service-control/releases)** page**
#### Install [.xbps package](https://git.orudo.ru/trueold89/void-service-control/releases):
```bash
& xbps-rindex -a *.xbps && xbps-install --repository=$PWD void-service-control
```
***
### Usage:
@ -42,6 +54,11 @@ $ vsc e <service_name>
$ vsc d <service_name>
```
**Action with multiple services:**
```bash
$ vsc e <first_service_name> <second_service_name>
```
**Print help:**
```bash

View File

@ -70,12 +70,10 @@ class Args(object):
"""
Checks the arguments
"""
if len(self.__arguments) == 0:
raise TypeError(lang.errors["usage"])
if len(self.__arguments) != 2 and self.__arguments[0] not in Arg.HELP.value:
raise TypeError(lang.errors["usage"])
if self.__arguments[0] in Arg.HELP.value:
if len(self.__arguments) == 1 and self.__arguments[0] in Arg.HELP.value:
raise Help()
if len(self.__arguments) < 2:
raise TypeError(lang.errors["usage"])
if self.__arguments[0] not in Arg.all():
raise TypeError(lang.errors["args"])
@ -91,7 +89,7 @@ class Args(object):
def __iter__(self):
yield self.__action()
yield self.__arguments[1]
yield self.__arguments[1:]
class Service(object):

View File

@ -1 +1,14 @@
{"errors": {"su": "Error: Access denied", "usage": "Bad usage", "args": "Error: Invalid args", "ne": "Error: Service '{}' doesn't exists", "enabled": "Error: Service '{}' already enabled", "disabled": "Error: Service '{}' already disabled"}, "messages": {"enabled": "Service '{}' successfully enabled", "disabled": "Service '{}' successfully disabled", "help": "Usage:\n---\nvsc {e/enable/on/up} <service_name> - Run service and add it to autostart\nvsc {d/disable/off/down <service_name> - Stop service and remove it from autostart"}}
{
"errors": {
"su": "Error: Access denied",
"usage": "Bad usage",
"args": "Error: Invalid args",
"ne": "Error: Service '{}' doesn't exists",
"enabled": "Error: Service '{}' already enabled",
"disabled": "Error: Service '{}' already disabled"},
"messages": {
"enabled": "Service '{}' successfully enabled",
"disabled": "Service '{}' successfully disabled",
"help": "Usage:\n---\nvsc {e/enable/on/up} <service_name> - Run service and add it to autostart\nvsc {d/disable/off/down} <service_name> - Stop service and remove it from autostart"
}
}

21
VoidServiceControl/main.py Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from VoidServiceControl.classes import Su, Interface, Args, Help
def main() -> None:
try:
Su()
action, services = tuple(Args())
for service_name in services:
service = Interface(service_name)
service.action(action)
del service
except TypeError as e:
print(f"{e}\n\n{Help()}")
except (ValueError, PermissionError, Help) as e:
print(e)
if __name__ == '__main__':
main()

View File

@ -1 +1,14 @@
{"errors": {"su": "\u041e\u0448\u0438\u0431\u043a\u0430: \u0414\u043e\u0441\u0442\u0443\u043f \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d", "usage": "\u041e\u0448\u0438\u0431\u043a\u0430: \u041d\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435", "args": "\u041e\u0448\u0438\u0431\u043a\u0430: \u041d\u0435\u0432\u0435\u0440\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b", "ne": "\u041e\u0448\u0438\u0431\u043a\u0430: \u0421\u0435\u0440\u0432\u0438\u0441 '{}' \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442", "enabled": "\u041e\u0448\u0438\u0431\u043a\u0430: \u0421\u0435\u0440\u0432\u0438\u0441 '{}' \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d", "disabled": "\u041e\u0448\u0438\u0431\u043a\u0430: \u0421\u0435\u0440\u0432\u0438\u0441 '{}' \u0443\u0436\u0435 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d"}, "messages": {"enabled": "\u0421\u0435\u0440\u0432\u0438\u0441 '{}' \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d", "disabled": "\u0421\u0435\u0440\u0432\u0438\u0441 '{}' \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d", "help": "\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435:\n---\nvsc {e/enable/on/up} <\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0441\u0435\u0440\u0432\u0438\u0441\u0430> - \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a\nvsc {d/disable/off/down <\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0441\u0435\u0440\u0432\u0438\u0441\u0430> - \u0412\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0437 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a\u0430"}}
{
"errors": {
"su": "Ошибка: Доступ запрещен",
"usage": "Ошибка: Неверное использование",
"args": "Ошибка: Неверные аргументы",
"ne": "Ошибка: Сервис '{}' не существует",
"enabled": "Ошибка: Сервис '{}' уже включен",
"disabled": "Ошибка: Сервис '{}' уже выключен"},
"messages": {
"enabled": "Сервис '{}' успешно включен",
"disabled": "Сервис '{}' успешно выключен",
"help": "Использование:\n---\nvsc {e/enable/on/up} <название_сервиса> - Запустить и добавить в автозапуск\nvsc {d/disable/off/down} <название_сервиса> - Выключить и удалить из автозапуска"
}
}

12
VoidTemplate Normal file
View File

@ -0,0 +1,12 @@
# Template file for 'void-service-control'
pkgname=void-service-control
version=
revision=1
build_style=python3-module
hostmakedepends="python3-setuptools"
short_desc="A simple script that will allow you to manage runit services in Void Linux"
maintainer="Trueold89 <trueold89@orudo.ru>"
license="GPL-3"
homepage="https://git.orudo.ru/trueold89/void-service-control"
distfiles="https://git.orudo.ru/trueold89/void-service-control/releases/download/${version}/VoidServiceControl-${version}.tar.gz"
checksum=

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup(
name='VoidServiceControl',
version='0.2',
version='0.2.1',
url='https://git.orudo.ru/trueold89/void-service-control',
author='trueold89',
author_email='trueold89@orudo.ru',