You can now manage multiple services && main.py is now indexed in the repository

This commit is contained in:
trueold89 2024-03-27 23:45:34 +03:00
parent 2280b74221
commit ae747ca569
Signed by: trueold89
GPG Key ID: C122E85DD49E6B30
3 changed files with 25 additions and 7 deletions

1
.gitignore vendored
View File

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

View File

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

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()