Skip to content

Commit 1ce4da9

Browse files
committed
A few changes to transporter.py
1 parent a3e87e0 commit 1ce4da9

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

examples/transporter.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,45 @@
11
#!/usr/bin/env python3
22
"""Query or change the JACK transport state."""
3-
43
import argparse
54
import string
6-
import sys
75

86
import jack
97

108

11-
STATE_LABELS = {
12-
jack.ROLLING: "rolling",
13-
jack.STOPPED: "stopped",
14-
jack.STARTING: "starting",
15-
jack.NETSTARTING: "waiting for network sync",
16-
}
17-
18-
199
def main(args=None):
2010
ap = argparse.ArgumentParser(description=__doc__)
2111
ap.add_argument(
2212
'-c', '--client-name',
2313
metavar='NAME',
2414
default='transporter',
25-
help="JACK client name (default: %(default)s)")
15+
help='JACK client name (default: %(default)s)')
2616
ap.add_argument(
2717
'command',
2818
nargs='?',
2919
default='status',
3020
choices=['query', 'rewind', 'start', 'status', 'stop', 'toggle'],
31-
help="Transport command")
21+
help='transport command')
3222

3323
args = ap.parse_args(args)
3424

3525
try:
3626
client = jack.Client(args.client_name)
3727
except jack.JackError as exc:
38-
return "Could not create JACK client: {}".format(exc)
28+
ap.exit('Could not create JACK client: {}'.format(exc))
3929

4030
state = client.transport_state
4131
result = 0
4232

4333
if args.command == 'status':
44-
print("JACK transport is {}.".format(STATE_LABELS[state]))
34+
print('JACK transport state is {}.'.format(state))
4535
result = 1 if state == jack.STOPPED else 0
4636
elif args.command == 'query':
47-
print("State: {}".format(STATE_LABELS[state]))
37+
print('State: {}'.format(state))
4838
info = client.transport_query()[1]
4939

5040
for field in sorted(info):
5141
label = string.capwords(field.replace('_', ' '))
52-
print("{}: {}".format(label, info[field]))
42+
print('{}: {}'.format(label, info[field]))
5343

5444
result = 1 if state == jack.STOPPED else 0
5545
elif args.command == 'start':
@@ -67,8 +57,8 @@ def main(args=None):
6757
client.transport_frame = 0
6858

6959
client.close()
70-
return result
60+
ap.exit(result)
7161

7262

7363
if __name__ == '__main__':
74-
sys.exit(main() or 0)
64+
main()

0 commit comments

Comments
 (0)