diff --git a/maloja/__pkginfo__.py b/maloja/__pkginfo__.py index 296c657..61d2014 100644 --- a/maloja/__pkginfo__.py +++ b/maloja/__pkginfo__.py @@ -1,44 +1,12 @@ -name = "maloja" -desc = "Self-hosted music scrobble database" -author = { - "name":"Johannes Krattenmacher", - "email":"maloja@dev.krateng.ch", - "github": "krateng" -} -version = 2,13,4 -versionstr = ".".join(str(n) for n in version) -links = { - "pypi":"malojaserver", - "github":"maloja" -} -python_version = ">=3.6" -requires = [ - "bottle>=0.12.16", - "waitress>=1.3", - "doreah>=1.7.1", - "nimrodel>=0.7.0", - "setproctitle>=1.1.10", - "wand>=0.5.4", - "jinja2>=2.11", - "lru-dict>=1.1.6", - "css_html_js_minify>=2.5.5", - "psutil>=5.8.0" -] -resources = [ - "web/*/*/*", - "web/*/*", - "web/*", - "data_files/*/*", - "data_files/*/.*", - "data_files/*/*/*", - "data_files/*/*/.*", - "data_files/*/*/*/*", - "data_files/*/*/*/.*", - "*/*.py", - "*/*/*.py", - "*/*/*/*.py" -] +# This file has now been slighly repurposed and will simply give other parts of +# the package access to some global meta-information about itself -commands = { - "maloja":"proccontrol.control:main" +import pkg_resources +self = pkg_resources.get_distribution('maloja') + +versionstr = self.version +version = self.version.split('.') +urls = { + "repo":"https://github.com/krateng/maloja" } +user_agent = f"Maloja/{versionstr} ( {urls['repo']} )" diff --git a/maloja/proccontrol/control.py b/maloja/proccontrol/control.py index acd238c..8fa7e55 100644 --- a/maloja/proccontrol/control.py +++ b/maloja/proccontrol/control.py @@ -10,12 +10,14 @@ from . import tasks from .. import __pkginfo__ as info from .. import globalconf -print() -print("#####") -print("Maloja v" + info.versionstr) -print("https://github.com/" + info.author['github'] + "/" + info.links['github']) -print("#####") -print() + +def print_header_info(): + print() + print("#####") + print("Maloja v" + info.versionstr) + print(info.urls['repo']) + print("#####") + print() def getInstance(): @@ -42,6 +44,7 @@ def start(): else: setup() try: + print_header_info() #p = subprocess.Popen(["python3","-m","maloja.server"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL) sp = subprocess.Popen(["python3","-m","maloja.proccontrol.supervisor"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL) print(col["green"]("Maloja started!")) @@ -77,6 +80,7 @@ def stop(): def direct(): + print_header_info() setup() from .. import server @@ -85,23 +89,32 @@ def debug(): globalconf.malojaconfig.load_environment() direct() +def print_info(): + print_header_info() + +@mainfunction({"l":"level","v":"version"},shield=True) +def main(*args,**kwargs): -@mainfunction({"l":"level"},shield=True) -def main(action,*args,**kwargs): actions = { "start":start, "restart":restart, "stop":stop, "run":direct, "debug":debug, - "import":tasks.loadlastfm, "backup":tasks.backuphere, # "update":update, "fix":tasks.fixdb, - "generate":tasks.generate_scrobbles + "generate":tasks.generate_scrobbles, + "info":print_info } - if action in actions: actions[action](*args,**kwargs) - else: print("Valid commands: " + " ".join(a for a in actions)) + + if len(args) > 0: + action = args[0] + args = args[1:] + if action in actions: actions[action](*args,**kwargs) + else: print("Valid commands: " + " ".join(a for a in actions)) + else: + print("No action specified!") return True diff --git a/maloja/thirdparty/musicbrainz.py b/maloja/thirdparty/musicbrainz.py index 61ff755..ee86a49 100644 --- a/maloja/thirdparty/musicbrainz.py +++ b/maloja/thirdparty/musicbrainz.py @@ -3,7 +3,7 @@ import urllib.parse, urllib.request import json import time import threading -from ..__pkginfo__ import versionstr, author, links +from ..__pkginfo__ import user_agent class MusicBrainz(MetadataInterface): name = "MusicBrainz" @@ -11,7 +11,7 @@ class MusicBrainz(MetadataInterface): # musicbrainz is rate-limited lock = threading.Lock() - useragent = "Maloja/" + versionstr + " ( https://github.com/" + author["github"] + "/" + links["github"] + " )" + useragent = user_agent settings = { }