From 2eeb2b7bb683ef461b753bdee064c6189da3e0c0 Mon Sep 17 00:00:00 2001 From: Jason Antwi-Appah Date: Sat, 28 Dec 2019 15:45:57 -0600 Subject: [PATCH 1/3] Created a function to check if we are connected to the EOS software --- EOS.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/EOS.py b/EOS.py index 5f2473c..4613328 100644 --- a/EOS.py +++ b/EOS.py @@ -22,20 +22,27 @@ def setConsoleType(self,argument): console_type=5 elif argument=="other": console_type=6 - elif argument=="eosclassic": - console_type=7 + elif argument == "eosclassic": + console_type = 7 else: - console_type=6 + console_type = 6 - def connectToConsole(self,consoleAddress,consolePortRx,consoleType): - client.connect( (consoleAddress, consolePortRx) ) + def connectToConsole(self, consoleAddress, consolePortRx, consoleType): + client.connect((consoleAddress, consolePortRx)) self.setConsoleType(consoleType) global client_connected client_connected = True + def verifyConnection(self): + if client_connected == True: + pass + else: + raise ValueError("Not connected") + return 0 + def go(self): if client_connected == True: - client.send( OSCMessage("/eos/key/go") ) + client.send(OSCMessage("/eos/key/go")) return 1 else: raise ValueError("Not connected") From 5aac119a6c8989bbe4f7fac71afc96853f9d898a Mon Sep 17 00:00:00 2001 From: Jason Antwi-Appah Date: Sat, 28 Dec 2019 15:59:14 -0600 Subject: [PATCH 2/3] Removed the return statements after an error is raised (when the error is raised, any code underneath won't run anyway) --- EOS.py | 71 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/EOS.py b/EOS.py index 4613328..6b978d5 100644 --- a/EOS.py +++ b/EOS.py @@ -6,22 +6,23 @@ client = OSCClient() console_type = 0 + class eosClient(): - def setConsoleType(self,argument): - global console_type - if argument=="ti": - console_type=1 - elif argument=="gio": - console_type=2 - elif argument=="ion": - console_type=3 - elif argument=="element": - console_type=4 - elif argument=="nomad": - console_type=5 - elif argument=="other": - console_type=6 + def setConsoleType(self, argument): + global console_type + if argument == "ti": + console_type = 1 + elif argument == "gio": + console_type = 2 + elif argument == "ion": + console_type = 3 + elif argument == "element": + console_type = 4 + elif argument == "nomad": + console_type = 5 + elif argument == "other": + console_type = 6 elif argument == "eosclassic": console_type = 7 else: @@ -38,7 +39,6 @@ def verifyConnection(self): pass else: raise ValueError("Not connected") - return 0 def go(self): if client_connected == True: @@ -46,52 +46,45 @@ def go(self): return 1 else: raise ValueError("Not connected") - return 0 def stopback(self): - if client_connected==1: - client.send( OSCMessage("/eos/key/stop") ) + if client_connected == 1: + client.send(OSCMessage("/eos/key/stop")) return 1 else: raise ValueError("Not connected") - return 0 - def chanlevel(self,channel,level): - if client_connected==1: - client.send( OSCMessage("/eos/chan/%s/at" % (channel), [level] ) ) + def chanlevel(self, channel, level): + if client_connected == 1: + client.send(OSCMessage("/eos/chan/%s/at" % (channel), [level])) return 1 else: raise ValueError("Not connected") - return 0 - def cmdline(self,commandline): - if client_connected==1: - client.send( OSCMessage("/eos/cmd", [commandline] ) ) + def cmdline(self, commandline): + if client_connected == 1: + client.send(OSCMessage("/eos/cmd", [commandline])) return 1 else: raise ValueError("Not connected") - return 0 - def newcmdline(self,commandline): - if client_connected==1: - client.send( OSCMessage("/eos/newcmd", [commandline] ) ) + def newcmdline(self, commandline): + if client_connected == 1: + client.send(OSCMessage("/eos/newcmd", [commandline])) return 1 else: raise ValueError("Not connected") - return 0 - def cmdlineevent(self,commandline): - if client_connected==1: - client.send( OSCMessage("/eos/event", [commandline] ) ) + def cmdlineevent(self, commandline): + if client_connected == 1: + client.send(OSCMessage("/eos/event", [commandline])) return 1 else: raise ValueError("Not connected") - return 0 - def cmdlinenewevent(self,commandline): - if client_connected==1: - client.send( OSCMessage("/eos/newevent", [commandline] ) ) + def cmdlinenewevent(self, commandline): + if client_connected == 1: + client.send(OSCMessage("/eos/newevent", [commandline])) return 1 else: raise ValueError("Not connected") - return 0 \ No newline at end of file From 749529ed13428066b1e6529a7cd70dbb86ee55cf Mon Sep 17 00:00:00 2001 From: Jason Antwi-Appah Date: Sat, 28 Dec 2019 16:59:57 -0600 Subject: [PATCH 3/3] Edited the commands to use a function to verify connection to an Eos console --- EOS.py | 59 ++++++++++++++++++++++------------------------------------ 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/EOS.py b/EOS.py index 6b978d5..6b9fa3a 100644 --- a/EOS.py +++ b/EOS.py @@ -6,7 +6,6 @@ client = OSCClient() console_type = 0 - class eosClient(): def setConsoleType(self, argument): @@ -35,56 +34,42 @@ def connectToConsole(self, consoleAddress, consolePortRx, consoleType): client_connected = True def verifyConnection(self): - if client_connected == True: + if client_connected: pass else: raise ValueError("Not connected") def go(self): - if client_connected == True: - client.send(OSCMessage("/eos/key/go")) - return 1 - else: - raise ValueError("Not connected") + self.verifyConnection() + client.send(OSCMessage("/eos/key/go")) + return 1 def stopback(self): - if client_connected == 1: - client.send(OSCMessage("/eos/key/stop")) - return 1 - else: - raise ValueError("Not connected") + self.verifyConnection() + client.send(OSCMessage("/eos/key/stop")) + return 1 def chanlevel(self, channel, level): - if client_connected == 1: - client.send(OSCMessage("/eos/chan/%s/at" % (channel), [level])) - return 1 - else: - raise ValueError("Not connected") + self.verifyConnection() + client.send(OSCMessage("/eos/chan/%s/at" % (channel), [level])) + return 1 def cmdline(self, commandline): - if client_connected == 1: - client.send(OSCMessage("/eos/cmd", [commandline])) - return 1 - else: - raise ValueError("Not connected") + self.verifyConnection() + client.send(OSCMessage("/eos/cmd", [commandline])) + return 1 def newcmdline(self, commandline): - if client_connected == 1: - client.send(OSCMessage("/eos/newcmd", [commandline])) - return 1 - else: - raise ValueError("Not connected") + self.verifyConnection() + client.send(OSCMessage("/eos/newcmd", [commandline])) + return 1 def cmdlineevent(self, commandline): - if client_connected == 1: - client.send(OSCMessage("/eos/event", [commandline])) - return 1 - else: - raise ValueError("Not connected") + self.verifyConnection() + client.send(OSCMessage("/eos/event", [commandline])) + return 1 def cmdlinenewevent(self, commandline): - if client_connected == 1: - client.send(OSCMessage("/eos/newevent", [commandline])) - return 1 - else: - raise ValueError("Not connected") + self.verifyConnection() + client.send(OSCMessage("/eos/newevent", [commandline])) + return 1