1
Fork 0

a2j_control: apply python 2to3

This commit is contained in:
Nedko Arnaudov 2022-08-28 20:45:21 +03:00
parent 3f39efb869
commit 955db9d08c
1 changed files with 42 additions and 42 deletions

View File

@ -12,20 +12,20 @@ import dbus
def main():
if len(sys.argv) == 1:
print "Usage: %s [command] [command] ..." % os.path.basename(sys.argv[0])
print "Commands:"
print " exit - exit a2j bridge dbus service"
print " start - start bridging"
print " stop - stop brdiging"
print " status - get bridging status"
print " gjcn - get JACK client name"
print " ma2jp <client_id> <port_id> - map ALSA to JACK playback port"
print " ma2jc <client_id> <port_id> - map ALSA to JACK capture port"
print " mj2a <jack_port_name> - map JACK port to ALSA port"
print " ehw - enable export of hardware ports"
print " dhw - disable export of hardware ports"
print " dup - disallow unique port names"
print " aup - allow unique port names"
print("Usage: %s [command] [command] ..." % os.path.basename(sys.argv[0]))
print("Commands:")
print(" exit - exit a2j bridge dbus service")
print(" start - start bridging")
print(" stop - stop brdiging")
print(" status - get bridging status")
print(" gjcn - get JACK client name")
print(" ma2jp <client_id> <port_id> - map ALSA to JACK playback port")
print(" ma2jc <client_id> <port_id> - map ALSA to JACK capture port")
print(" mj2a <jack_port_name> - map JACK port to ALSA port")
print(" ehw - enable export of hardware ports")
print(" dhw - disable export of hardware ports")
print(" dup - disallow unique port names")
print(" aup - allow unique port names")
sys.exit(0)
bus = dbus.SessionBus()
@ -40,79 +40,79 @@ def main():
index += 1
try:
if arg == "exit":
print "--- exit"
print("--- exit")
control_iface.exit()
elif arg == "start":
print "--- start"
print("--- start")
control_iface.start()
elif arg == "stop":
print "--- stop"
print("--- stop")
control_iface.stop()
elif arg == "status":
print "--- status"
print("--- status")
if control_iface.is_started():
print "Bridging enabled"
print("Bridging enabled")
else:
print "Bridging disabled"
print("Bridging disabled")
if control_iface.get_hw_export():
print "Hardware exported"
print("Hardware exported")
else:
print "Hardware not exported"
print("Hardware not exported")
if control_iface.get_disable_port_uniqueness():
print "Avoiding unique port names"
print("Avoiding unique port names")
else:
print "Allowing unique port names"
print("Allowing unique port names")
elif arg == "gjcn":
print "--- get jack client name"
print control_iface.get_jack_client_name()
print("--- get jack client name")
print(control_iface.get_jack_client_name())
elif arg == 'ma2jp':
print "--- map ALSA to JACK playback port"
print("--- map ALSA to JACK playback port")
if index + 1 >= len(sys.argv):
print "map ALSA to JACK playback port command requires ALSA client ID and ALSA port ID arguments"
print("map ALSA to JACK playback port command requires ALSA client ID and ALSA port ID arguments")
sys.exit()
client_id = sys.argv[index]
index += 1
port_id = sys.argv[index]
index += 1
print "'%s'" % control_iface.map_alsa_to_jack_port(client_id, port_id, True)
print("'%s'" % control_iface.map_alsa_to_jack_port(client_id, port_id, True))
elif arg == 'ma2jc':
print "--- map ALSA to JACK capture port"
print("--- map ALSA to JACK capture port")
if index + 1 >= len(sys.argv):
print "map ALSA to JACK capture port command requires ALSA client ID and ALSA port ID arguments"
print("map ALSA to JACK capture port command requires ALSA client ID and ALSA port ID arguments")
sys.exit()
client_id = sys.argv[index]
index += 1
port_id = sys.argv[index]
index += 1
print "'%s'" % control_iface.map_alsa_to_jack_port(client_id, port_id, False)
print("'%s'" % control_iface.map_alsa_to_jack_port(client_id, port_id, False))
elif arg == 'mj2a':
print "--- map JACK to ALSA port"
print("--- map JACK to ALSA port")
if index >= len(sys.argv):
print "map JACK to ALSA port command requires JACK port name argument"
print("map JACK to ALSA port command requires JACK port name argument")
sys.exit()
jack_port = sys.argv[index]
index += 1
out = control_iface.map_jack_port_to_alsa(jack_port)
print "%u:%u ('%s':'%s')" % (int(out[0]), int(out[1]), str(out[2]), str(out[3]))
print("%u:%u ('%s':'%s')" % (int(out[0]), int(out[1]), str(out[2]), str(out[3])))
elif arg == 'ehw':
print "--- enable export of hardware ports"
print("--- enable export of hardware ports")
control_iface.set_hw_export(True)
elif arg == 'dhw':
print "--- disable export of hardware ports"
print("--- disable export of hardware ports")
control_iface.set_hw_export(False)
elif arg == 'aup':
print "--- allow unique port names"
print("--- allow unique port names")
control_iface.set_disable_port_uniqueness(False)
elif arg == 'dup':
print "--- disallow unique port names"
print("--- disallow unique port names")
control_iface.set_disable_port_uniqueness(True)
else:
print "Unknown command '%s'" % arg
except dbus.DBusException, e:
print "DBus exception: %s" % str(e)
print("Unknown command '%s'" % arg)
except dbus.DBusException as e:
print("DBus exception: %s" % str(e))
if __name__ == '__main__':
main()