aboutsummaryrefslogtreecommitdiff
path: root/tools/EventClients/Clients
diff options
context:
space:
mode:
authorRechi <Rechi@users.noreply.github.com>2017-11-23 09:11:02 +0100
committerRechi <Rechi@users.noreply.github.com>2017-11-23 09:11:02 +0100
commit0a70fe9893dac8654c648f87272e7588297bc71d (patch)
tree709d6c313faaa2bafbd6f278b5cc74d8eddc77d5 /tools/EventClients/Clients
parent63e33f6b950f953ecd9d300e38732f97400ab868 (diff)
[EventClients][python] replace print statement with print function
Diffstat (limited to 'tools/EventClients/Clients')
-rwxr-xr-xtools/EventClients/Clients/Kodi Send/kodi-send.py20
-rwxr-xr-xtools/EventClients/Clients/PS3 BD Remote/ps3_remote.py30
-rwxr-xr-xtools/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py44
3 files changed, 47 insertions, 47 deletions
diff --git a/tools/EventClients/Clients/Kodi Send/kodi-send.py b/tools/EventClients/Clients/Kodi Send/kodi-send.py
index f5a85b57e5..4d97646105 100755
--- a/tools/EventClients/Clients/Kodi Send/kodi-send.py
+++ b/tools/EventClients/Clients/Kodi Send/kodi-send.py
@@ -29,14 +29,14 @@ except:
from xbmcclient import *
def usage():
- print "kodi-send [OPTION] --action=ACTION"
- print 'Example'
- print '\tkodi-send --host=192.168.0.1 --port=9777 --action="Quit"'
- print "Options"
- print "\t-?, --help\t\t\tWill bring up this message"
- print "\t--host=HOST\t\t\tChoose what HOST to connect to (default=localhost)"
- print "\t--port=PORT\t\t\tChoose what PORT to connect to (default=9777)"
- print '\t--action=ACTION\t\t\tSends an action to XBMC, this option can be added multiple times to create a macro'
+ print("kodi-send [OPTION] --action=ACTION")
+ print('Example')
+ print('\tkodi-send --host=192.168.0.1 --port=9777 --action="Quit"')
+ print("Options")
+ print("\t-?, --help\t\t\tWill bring up this message")
+ print("\t--host=HOST\t\t\tChoose what HOST to connect to (default=localhost)")
+ print("\t--port=PORT\t\t\tChoose what PORT to connect to (default=9777)")
+ print('\t--action=ACTION\t\t\tSends an action to XBMC, this option can be added multiple times to create a macro')
pass
def main():
@@ -44,7 +44,7 @@ def main():
opts, args = getopt.getopt(sys.argv[1:], "?pa:v", ["help", "host=", "port=", "action="])
except getopt.GetoptError, err:
# print help information and exit:
- print str(err) # will print something like "option -a not recognized"
+ print(str(err)) # will print something like "option -a not recognized"
usage()
sys.exit(2)
ip = "localhost"
@@ -72,7 +72,7 @@ def main():
sys.exit(0)
for action in actions:
- print 'Sending action:', action
+ print('Sending action: %s' % action)
packet = PacketACTION(actionmessage=action, actiontype=ACTION_BUTTON)
packet.send(sock, addr)
diff --git a/tools/EventClients/Clients/PS3 BD Remote/ps3_remote.py b/tools/EventClients/Clients/PS3 BD Remote/ps3_remote.py
index 26ea1cd190..a9f57ccb5a 100755
--- a/tools/EventClients/Clients/PS3 BD Remote/ps3_remote.py
+++ b/tools/EventClients/Clients/PS3 BD Remote/ps3_remote.py
@@ -62,16 +62,16 @@ def get_remote_address(remote, target_name = "BD Remote Control"):
xbmc.send_notification("Action Required!",
"Hold Start+Enter on your remote.",
bticon)
- print "Searching for %s" % target_name
- print "(Hold Start + Enter on remote to make it discoverable)"
+ print("Searching for %s" % target_name)
+ print("(Hold Start + Enter on remote to make it discoverable)")
time.sleep(2)
if not target_address:
try:
nearby_devices = bt_discover_devices()
except Exception, e:
- print "Error performing bluetooth discovery"
- print str(e)
+ print("Error performing bluetooth discovery")
+ print(str(e))
xbmc.send_notification("Error", "Unable to find devices.", bticon)
time.sleep(5)
continue
@@ -79,22 +79,22 @@ def get_remote_address(remote, target_name = "BD Remote Control"):
for bdaddr in nearby_devices:
bname = bt_lookup_name( bdaddr )
addr = bt_lookup_addr ( bdaddr )
- print "%s (%s) in range" % (bname,addr)
+ print("%s (%s) in range" % (bname,addr))
if target_name == bname:
target_address = addr
break
if target_address is not None:
- print "Found %s with address %s" % (target_name, target_address)
+ print("Found %s with address %s" % (target_name, target_address))
xbmc.send_notification("Found Device",
"Pairing %s, please wait." % target_name,
bticon)
- print "Attempting to pair with remote"
+ print("Attempting to pair with remote")
try:
remote.connect((target_address,19))
target_connected = True
- print "Remote Paired.\a"
+ print("Remote Paired.\a")
xbmc.send_notification("Pairing Successful",
"Your remote was successfully "\
"paired and is ready to be used.",
@@ -106,17 +106,17 @@ def get_remote_address(remote, target_name = "BD Remote Control"):
xbmc.send_notification("Pairing Failed",
"An error occurred while attempting to "\
"pair.", bticon)
- print "ERROR - Could Not Connect. Trying again..."
+ print("ERROR - Could Not Connect. Trying again...")
time.sleep(2)
else:
xbmc.send_notification("Error", "No remotes were found.", bticon)
- print "Could not find BD Remote Control. Trying again..."
+ print("Could not find BD Remote Control. Trying again...")
time.sleep(2)
return (remote,target_address)
def usage():
- print """
+ print("""
PS3 Blu-Ray Remote Control Client for XBMC v0.1
Usage: ps3_remote.py <address> [port]
@@ -126,7 +126,7 @@ Usage: ps3_remote.py <address> [port]
port => port to send packets to
(default 9777)
-"""
+""")
def process_keys(remote, xbmc):
"""
@@ -179,7 +179,7 @@ def process_keys(remote, xbmc):
if g_keymap[keycode]:
xbmc.send_remote_button(g_keymap[keycode])
except Exception, e:
- print "Unknown data: %s" % str(e)
+ print("Unknown data: %s" % str(e))
return done
def main():
@@ -209,11 +209,11 @@ def main():
while True:
if process_keys(remote, xbmc):
break
- print "Disconnected."
+ print("Disconnected.")
try:
remote.close()
except:
- print "Cannot close."
+ print("Cannot close.")
if __name__=="__main__":
main()
diff --git a/tools/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py b/tools/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py
index 1b54700edd..d83ab3447e 100755
--- a/tools/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py
+++ b/tools/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py
@@ -35,7 +35,7 @@ if os.path.exists("../../lib/python"):
try:
from ps3 import sixwatch
except Exception, e:
- print "Failed to import sixwatch now disabled: " + str(e)
+ print("Failed to import sixwatch now disabled: " + str(e))
sixwatch = None
try:
@@ -54,7 +54,7 @@ else:
try:
from kodi.ps3 import sixwatch
except Exception, e:
- print "Failed to import sixwatch now disabled: " + str(e)
+ print("Failed to import sixwatch now disabled: " + str(e))
sixwatch = None
try:
import kodi.zeroconf as zeroconf
@@ -142,7 +142,7 @@ class PS3SixaxisThread ( StoppableThread ):
if six.process_socket(self.isock):
self.reset_timeout()
except Exception, e:
- print e
+ print(e)
break
except Exception, e:
@@ -171,7 +171,7 @@ class PS3RemoteThread ( StoppableThread ):
self.zeroconf_service_handler)
self.zeroconf_thread.start()
except Exception, e:
- print str(e)
+ print(str(e))
# main thread loop
while not self.stop():
@@ -192,7 +192,7 @@ class PS3RemoteThread ( StoppableThread ):
# process_remote() will raise an exception on read errors
except Exception, e:
- print str(e)
+ print(str(e))
self.zeroconf_thread.stop()
self.close_sockets()
@@ -221,11 +221,11 @@ class PS3RemoteThread ( StoppableThread ):
"""
try:
service = self.services[ self.current_xbmc ]
- print "Connecting to %s" % service['name']
+ print("Connecting to %s" % service['name'])
self.xbmc.connect( service['address'], service['port'] )
self.xbmc.send_notification("PS3 Blu-Ray Remote", "New Connection", None)
except Exception, e:
- print str(e)
+ print(str(e))
def zeroconf_service_handler(self, event, service):
"""
@@ -257,7 +257,7 @@ class SixWatch(threading.Thread):
try:
sixwatch.main(self.mac)
except Exception, e:
- print "Exception caught in sixwatch, restarting: " + str(e)
+ print("Exception caught in sixwatch, restarting: " + str(e))
class ZeroconfThread ( threading.Thread ):
"""
@@ -302,7 +302,7 @@ class ZeroconfThread ( threading.Thread ):
def usage():
- print """
+ print("""
PS3 Sixaxis / Blu-Ray Remote HID Server v0.1
Usage: ps3.py [bdaddress] [XBMC host]
@@ -311,7 +311,7 @@ Usage: ps3.py [bdaddress] [XBMC host]
(e.g. aa:bb:cc:dd:ee:ff)
ip address => IP address or hostname of the XBMC instance (default: localhost)
(e.g. 192.168.1.110)
-"""
+""")
def start_hidd(bdaddr=None, ipaddr="127.0.0.1"):
devices = [ 'PLAYSTATION(R)3 Controller',
@@ -320,10 +320,10 @@ def start_hidd(bdaddr=None, ipaddr="127.0.0.1"):
watch = None
if sixwatch:
try:
- print "Starting USB sixwatch"
+ print("Starting USB sixwatch")
watch = SixWatch(hid.get_local_address())
except Exception, e:
- print "Failed to initialize sixwatch" + str(e)
+ print("Failed to initialize sixwatch" + str(e))
pass
while True:
@@ -337,10 +337,10 @@ def start_hidd(bdaddr=None, ipaddr="127.0.0.1"):
# handle the PS3 remote
handle_ps3_remote(hid, ipaddr)
else:
- print "Unknown Device: %s" % (device_name)
+ print("Unknown Device: %s" % (device_name))
def handle_ps3_controller(hid, ipaddr):
- print "Received connection from a Sixaxis PS3 Controller"
+ print("Received connection from a Sixaxis PS3 Controller")
csock = hid.get_control_socket()[0]
isock = hid.get_interrupt_socket()[0]
sixaxis = PS3SixaxisThread(csock, isock, ipaddr)
@@ -349,7 +349,7 @@ def handle_ps3_controller(hid, ipaddr):
return
def handle_ps3_remote(hid, ipaddr):
- print "Received connection from a PS3 Blu-Ray Remote"
+ print("Received connection from a PS3 Blu-Ray Remote")
csock = hid.get_control_socket()[0]
isock = hid.get_interrupt_socket()[0]
isock.settimeout(1)
@@ -374,18 +374,18 @@ def main():
if "".join([ str(len(a)) for a in addr.split(":") ]) != "222222":
raise Exception("Invalid format")
bdaddr = addr
- print "Connecting to Bluetooth device: %s" % bdaddr
+ print("Connecting to Bluetooth device: %s" % bdaddr)
except Exception, e:
try:
ipaddr = addr
- print "Connecting to : %s" % ipaddr
+ print("Connecting to : %s" % ipaddr)
except:
- print str(e)
+ print(str(e))
return usage()
except Exception, e:
pass
- print "Starting HID daemon"
+ print("Starting HID daemon")
start_hidd(bdaddr, ipaddr)
if __name__=="__main__":
@@ -394,13 +394,13 @@ if __name__=="__main__":
finally:
for t in event_threads:
try:
- print "Waiting for thread "+str(t)+" to terminate"
+ print("Waiting for thread "+str(t)+" to terminate")
t.stop_thread()
if t.isAlive():
t.join()
- print "Thread "+str(t)+" terminated"
+ print("Thread "+str(t)+" terminated")
except Exception, e:
- print str(e)
+ print(str(e))
pass