1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-09 11:42:16 +00:00

Changed the way the CLI is installed

This commit is contained in:
spl0k 2019-06-16 16:02:50 +02:00
parent 82b5ca3cae
commit 1ce2f6fe70
3 changed files with 27 additions and 19 deletions

View File

@ -8,21 +8,12 @@
# #
# Distributed under terms of the GNU AGPLv3 license. # Distributed under terms of the GNU AGPLv3 license.
import sys import warnings
from supysonic.cli import main
from supysonic.cli import SupysonicCLI
from supysonic.config import IniConfig
from supysonic.db import init_database, release_database
if __name__ == "__main__": if __name__ == "__main__":
config = IniConfig.from_common_locations() warnings.warn(
init_database(config.BASE['database_uri']) "You're using an old version of the `supysonic-cli` script. "
"It should have been replaced on install."
cli = SupysonicCLI(config) )
if len(sys.argv) > 1: main()
cli.onecmd(' '.join(sys.argv[1:]))
else:
cli.cmdloop()
release_database()

View File

@ -37,8 +37,10 @@ setup(
license=project.LICENSE, license=project.LICENSE,
packages=find_packages(exclude=['tests*']), packages=find_packages(exclude=['tests*']),
install_requires = reqs, install_requires = reqs,
scripts=['bin/supysonic-cli'], entry_points={ 'console_scripts': [
entry_points={ 'console_scripts': ['supysonic-daemon=supysonic.daemon:main'] }, 'supysonic-cli=supysonic.cli:main',
'supysonic-daemon=supysonic.daemon:main'
] },
zip_safe=False, zip_safe=False,
include_package_data=True, include_package_data=True,
test_suite='tests.suite', test_suite='tests.suite',

17
supysonic/cli.py Normal file → Executable file
View File

@ -16,9 +16,10 @@ import time
from pony.orm import db_session, select from pony.orm import db_session, select
from pony.orm import ObjectNotFound from pony.orm import ObjectNotFound
from .config import IniConfig
from .daemon.client import DaemonClient from .daemon.client import DaemonClient
from .daemon.exceptions import DaemonUnavailableError from .daemon.exceptions import DaemonUnavailableError
from .db import Folder, User from .db import Folder, User, init_database, release_database
from .managers.folder import FolderManager from .managers.folder import FolderManager
from .managers.user import UserManager from .managers.user import UserManager
from .scanner import Scanner from .scanner import Scanner
@ -293,3 +294,17 @@ class SupysonicCLI(cmd.Cmd):
except ObjectNotFound as e: except ObjectNotFound as e:
self.write_error_line(str(e)) self.write_error_line(str(e))
def main():
config = IniConfig.from_common_locations()
init_database(config.BASE['database_uri'])
cli = SupysonicCLI(config)
if len(sys.argv) > 1:
cli.onecmd(' '.join(sys.argv[1:]))
else:
cli.cmdloop()
release_database()
if __name__ == "__main__":
main()