summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-02 06:53:56 +0000
committerDavid Robillard <d@drobilla.net>2012-05-02 06:53:56 +0000
commitf3d50e437022f0d2aabcaea056a8203afc3e32c3 (patch)
tree6e03781cd70521b23902a803d1259978898eef7d /scripts
parentfe353cce9665b33a7372ed2d1683b3c2748625f7 (diff)
downloadingen-f3d50e437022f0d2aabcaea056a8203afc3e32c3.tar.gz
ingen-f3d50e437022f0d2aabcaea056a8203afc3e32c3.tar.bz2
ingen-f3d50e437022f0d2aabcaea056a8203afc3e32c3.zip
Fix ingen_cmd for Python 3.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4312 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ingen_cmd19
1 files changed, 12 insertions, 7 deletions
diff --git a/scripts/ingen_cmd b/scripts/ingen_cmd
index aac616b6..45aede30 100755
--- a/scripts/ingen_cmd
+++ b/scripts/ingen_cmd
@@ -23,15 +23,20 @@ class Client:
def __init__(self, path='/tmp/ingen.sock'):
self.path = path
+ def msgencode(self, msg):
+ if sys.version_info[0] == 3:
+ return bytes(msg, 'utf-8')
+ else:
+ return msg
+
def send(self, msg):
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.connect(self.path)
- print "SENDING:\n%s\n" % msg
- self.sock.send(msg)
+ self.sock.send(self.msgencode(msg))
response = self.sock.recv(1024)
self.sock.close()
- if response != 'OK':
- print 'Error: %s' % response
+ if response != self.msgencode('OK'):
+ print('Error: %s' % response)
return False
else:
return True
@@ -87,7 +92,7 @@ class Client:
''' % (path))
def print_usage():
- print '''Usage: %s COMMAND [ARGUMENT]...
+ print('''Usage: %s COMMAND [ARGUMENT]...
A command line interface to an Ingen server.
Commands:
@@ -111,7 +116,7 @@ Example:
ingen_cmd connect /tone/left_out /combo/left_in
ingen_cmd connect /combo/left_out /left_out
ingen_cmd set /tone/output 'ingen:value 0.7'
-'''
+''')
def abort_if_num_args_less_than(num):
if len(sys.argv) < num:
@@ -138,7 +143,7 @@ elif cmd == 'disconnect':
elif cmd == 'delete':
success = ingen.delete(sys.argv[2])
else:
- print "error: Unknown command `%s'" % cmd
+ print("error: Unknown command `%s'" % cmd)
print_usage()
sys.exit(1)