aboutsummaryrefslogtreecommitdiff
path: root/tools
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
parent63e33f6b950f953ecd9d300e38732f97400ab868 (diff)
[EventClients][python] replace print statement with print function
Diffstat (limited to 'tools')
-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
-rwxr-xr-xtools/EventClients/examples/python/example_action.py2
-rw-r--r--tools/EventClients/lib/python/bt/bt.py8
-rw-r--r--tools/EventClients/lib/python/bt/hid.py4
-rw-r--r--tools/EventClients/lib/python/ps3/sixaxis.py2
-rwxr-xr-xtools/EventClients/lib/python/ps3/sixpair.py8
-rwxr-xr-xtools/EventClients/lib/python/ps3/sixwatch.py4
-rw-r--r--tools/EventClients/lib/python/xbmcclient.py2
-rw-r--r--tools/EventClients/lib/python/zeroconf.py12
11 files changed, 68 insertions, 68 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
diff --git a/tools/EventClients/examples/python/example_action.py b/tools/EventClients/examples/python/example_action.py
index 2e84bc1573..5be3ce05bb 100755
--- a/tools/EventClients/examples/python/example_action.py
+++ b/tools/EventClients/examples/python/example_action.py
@@ -26,7 +26,7 @@ def main():
try:
xbmc.send_action(sys.argv[1], ACTION_EXECBUILTIN)
except Exception, e:
- print str(e)
+ print(str(e))
xbmc.send_action("ActivateWindow(ShutdownMenu)")
diff --git a/tools/EventClients/lib/python/bt/bt.py b/tools/EventClients/lib/python/bt/bt.py
index 5c475b7cfe..979ebf2f43 100644
--- a/tools/EventClients/lib/python/bt/bt.py
+++ b/tools/EventClients/lib/python/bt/bt.py
@@ -24,10 +24,10 @@ except:
try:
import lightblue
except:
- print "ERROR: You need to have either LightBlue or PyBluez installed\n"\
- " in order to use this program."
- print "- PyBluez (Linux / Windows XP) http://org.csail.mit.edu/pybluez/"
- print "- LightBlue (Mac OS X / Linux) http://lightblue.sourceforge.net/"
+ print("ERROR: You need to have either LightBlue or PyBluez installed\n"\
+ " in order to use this program.")
+ print("- PyBluez (Linux / Windows XP) http://org.csail.mit.edu/pybluez/")
+ print("- LightBlue (Mac OS X / Linux) http://lightblue.sourceforge.net/")
exit()
def bt_create_socket():
diff --git a/tools/EventClients/lib/python/bt/hid.py b/tools/EventClients/lib/python/bt/hid.py
index bcab06681d..7c65e100f9 100644
--- a/tools/EventClients/lib/python/bt/hid.py
+++ b/tools/EventClients/lib/python/bt/hid.py
@@ -50,9 +50,9 @@ class HID:
def listen(self):
try:
(self.client_csock, self.caddress) = self.csock.accept()
- print "Accepted Control connection from %s" % self.caddress[0]
+ print("Accepted Control connection from %s" % self.caddress[0])
(self.client_isock, self.iaddress) = self.isock.accept()
- print "Accepted Interrupt connection from %s" % self.iaddress[0]
+ print("Accepted Interrupt connection from %s" % self.iaddress[0])
self.connected = True
return True
except Exception, e:
diff --git a/tools/EventClients/lib/python/ps3/sixaxis.py b/tools/EventClients/lib/python/ps3/sixaxis.py
index f5570065c9..44489e87e8 100644
--- a/tools/EventClients/lib/python/ps3/sixaxis.py
+++ b/tools/EventClients/lib/python/ps3/sixaxis.py
@@ -165,7 +165,7 @@ def set_l2cap_mtu2(sock, mtu):
try:
sock.setsockopt (SOL_L2CAP, L2CAP_OPTIONS, s)
except:
- print "Warning: Unable to set mtu"
+ print("Warning: Unable to set mtu")
class sixaxis():
diff --git a/tools/EventClients/lib/python/ps3/sixpair.py b/tools/EventClients/lib/python/ps3/sixpair.py
index 7a2b9a2394..264c2f778c 100755
--- a/tools/EventClients/lib/python/ps3/sixpair.py
+++ b/tools/EventClients/lib/python/ps3/sixpair.py
@@ -85,7 +85,7 @@ def set_pair_all(mac):
def update_pair(dev, mac):
old = get_pair(dev)
if old != mac:
- print "Re-pairing sixaxis from:" + mac_to_string(old) + " to:" + mac_to_string(mac)
+ print("Re-pairing sixaxis from:" + mac_to_string(old) + " to:" + mac_to_string(mac))
set_pair(dev, mac)
if __name__=="__main__":
@@ -97,17 +97,17 @@ if __name__=="__main__":
mac = sys.argv[1].split(':')
mac = tuple([int(x, 16) for x in mac])
if len(mac) != 6:
- print "Invalid length of HCI address, should be 6 parts"
+ print("Invalid length of HCI address, should be 6 parts")
mac = None
except:
- print "Failed to parse HCI address"
+ print("Failed to parse HCI address")
mac = None
for dev in devs:
if mac:
update_pair(dev, mac)
else:
- print "Found sixaxis paired to: " + mac_to_string(get_pair(dev))
+ print("Found sixaxis paired to: " + mac_to_string(get_pair(dev)))
diff --git a/tools/EventClients/lib/python/ps3/sixwatch.py b/tools/EventClients/lib/python/ps3/sixwatch.py
index b5b7b3be7d..af03a83af1 100755
--- a/tools/EventClients/lib/python/ps3/sixwatch.py
+++ b/tools/EventClients/lib/python/ps3/sixwatch.py
@@ -17,11 +17,11 @@ def main(mac):
if 'ID_VENDOR_ID' in device and 'ID_MODEL_ID' in device:
if device['ID_VENDOR_ID'] == '054c' and device['ID_MODEL_ID'] == '0268':
if action == 'add':
- print "Detected sixaxis connected by usb"
+ print("Detected sixaxis connected by usb")
try:
sixpair.set_pair_filename(device.attributes['busnum'], device.attributes['devnum'], mac)
except Exception, e:
- print "Failed to check pairing of sixaxis: " + str(e)
+ print("Failed to check pairing of sixaxis: " + str(e))
pass
diff --git a/tools/EventClients/lib/python/xbmcclient.py b/tools/EventClients/lib/python/xbmcclient.py
index 9b1e1679b2..fd29f5b4c4 100644
--- a/tools/EventClients/lib/python/xbmcclient.py
+++ b/tools/EventClients/lib/python/xbmcclient.py
@@ -438,7 +438,7 @@ class PacketLOG (Packet):
self.append_payload( chr (loglevel) )
self.append_payload( format_string(logmessage) )
if (autoprint):
- print logmessage
+ print(logmessage)
class PacketACTION (Packet):
"""An ACTION packet
diff --git a/tools/EventClients/lib/python/zeroconf.py b/tools/EventClients/lib/python/zeroconf.py
index e891efa336..5946a4e885 100644
--- a/tools/EventClients/lib/python/zeroconf.py
+++ b/tools/EventClients/lib/python/zeroconf.py
@@ -30,8 +30,8 @@ try:
from dbus import DBusException
from dbus.mainloop.glib import DBusGMainLoop
except Exception, e:
- print "Zeroconf support disabled. To enable, install the following Python modules:"
- print " dbus, gobject, avahi"
+ print("Zeroconf support disabled. To enable, install the following Python modules:")
+ print(" dbus, gobject, avahi")
pass
SERVICE_FOUND = 1
@@ -141,15 +141,15 @@ class Browser:
def _error_handler( self, *args ):
- print 'ERROR: %s ' % str( args[0] )
+ print('ERROR: %s ' % str( args[0] ))
if __name__ == "__main__":
def service_handler( found, service ):
- print "---------------------"
- print ['Found Service', 'Lost Service'][found-1]
+ print("---------------------")
+ print(['Found Service', 'Lost Service'][found-1])
for key in service.keys():
- print key+" : "+str( service[key] )
+ print(key+" : "+str( service[key] ))
browser = Browser( {
'_xbmc-events._udp' : service_handler,