This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sync2gm.py
62 lines (40 loc) · 2.13 KB
/
sync2gm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import argparse
import appdirs
import os
import sqlite3
from sync2gm import service
def setup(args):
print service.init_config(args.confname, args.mp_type, args.mp_db_path)
def run(args):
ret = service.start_service(args.confname, args.port, args.email, args.password)
if ret is not True:
print ret
def stop(args):
service.stop_service(args.port)
def status(args):
print service.is_service_running(args.port)
def main():
parser = argparse.ArgumentParser(description="Sync a local mediaplayer to Google Music.")
subparsers = parser.add_subparsers(help='commands')
confname_help = 'A user-defined name to identify different configurations.'
parser_setup = subparsers.add_parser('setup', help='Create or rewrite a configuration.')
parser_setup.add_argument('confname', help=confname_help)
parser_setup.add_argument('mp_type', help='A supported mediaplayer type.') #should use choices here
parser_setup.add_argument('mp_db_path', help='The path of the mediaplayer database file.')
parser_setup.set_defaults(func=setup)
parser_act = subparsers.add_parser('run', help='Run a service for some configuration.')
parser_act.add_argument('confname', help=confname_help)
parser_act.add_argument('email', help="Gmail address to authenticate with.")
parser_act.add_argument('password', help="Account password.")
parser_act.add_argument('--port', default=9000, type=int, help='The port to run on. (default: %(default)s)')
parser_act.set_defaults(func=run)
parser_stop = subparsers.add_parser('stop', help='Stop a currently running service.')
parser_stop.add_argument('--port', default=9000, type=int, help='The port the service is running on (default: %(default)s)')
parser_stop.set_defaults(func=stop)
parser_status = subparsers.add_parser('status', help='Display "True" if the service is running.')
parser_status.add_argument('--port', default=9000, type=int, help='The port the service is running on (default: %(default)s)')
parser_status.set_defaults(func=status)
args = parser.parse_args()
args.func(args)
if __name__ == '__main__':
main()