1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Repurposed __pkginfo__ module

This commit is contained in:
krateng 2021-12-24 06:30:19 +01:00
parent c745d4a647
commit 73a6c18b17
3 changed files with 37 additions and 56 deletions

View File

@ -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']} )"

View File

@ -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

View File

@ -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 = {
}