mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
Changed the way the CLI is installed
This commit is contained in:
parent
82b5ca3cae
commit
1ce2f6fe70
@ -8,21 +8,12 @@
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
import sys
|
||||
|
||||
from supysonic.cli import SupysonicCLI
|
||||
from supysonic.config import IniConfig
|
||||
from supysonic.db import init_database, release_database
|
||||
import warnings
|
||||
from supysonic.cli import main
|
||||
|
||||
if __name__ == "__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()
|
||||
|
||||
warnings.warn(
|
||||
"You're using an old version of the `supysonic-cli` script. "
|
||||
"It should have been replaced on install."
|
||||
)
|
||||
main()
|
||||
|
6
setup.py
6
setup.py
@ -37,8 +37,10 @@ setup(
|
||||
license=project.LICENSE,
|
||||
packages=find_packages(exclude=['tests*']),
|
||||
install_requires = reqs,
|
||||
scripts=['bin/supysonic-cli'],
|
||||
entry_points={ 'console_scripts': ['supysonic-daemon=supysonic.daemon:main'] },
|
||||
entry_points={ 'console_scripts': [
|
||||
'supysonic-cli=supysonic.cli:main',
|
||||
'supysonic-daemon=supysonic.daemon:main'
|
||||
] },
|
||||
zip_safe=False,
|
||||
include_package_data=True,
|
||||
test_suite='tests.suite',
|
||||
|
17
supysonic/cli.py
Normal file → Executable file
17
supysonic/cli.py
Normal file → Executable file
@ -16,9 +16,10 @@ import time
|
||||
from pony.orm import db_session, select
|
||||
from pony.orm import ObjectNotFound
|
||||
|
||||
from .config import IniConfig
|
||||
from .daemon.client import DaemonClient
|
||||
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.user import UserManager
|
||||
from .scanner import Scanner
|
||||
@ -293,3 +294,17 @@ class SupysonicCLI(cmd.Cmd):
|
||||
except ObjectNotFound as 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()
|
||||
|
Loading…
Reference in New Issue
Block a user