Index: src/mlx/fsuipc.py
===================================================================
--- src/mlx/fsuipc.py	(revision 877)
+++ src/mlx/fsuipc.py	(revision 919)
@@ -1,8 +1,8 @@
 
-import fs
-import const
-import util
-import acft
-from watchdog import Watchdog
+from . import fs
+from . import const
+from . import util
+from . import acft
+from .watchdog import Watchdog
 
 import threading
@@ -17,5 +17,5 @@
     import pyuipc
 else:
-    import pyuipc_sim as pyuipc
+    from . import pyuipc_sim as pyuipc
 
 #------------------------------------------------------------------------------
@@ -104,6 +104,6 @@
         try:
             return fun()
-        except Exception, e:
-            print >> sys.stderr, util.utf2unicode(str(e))
+        except Exception as e:
+            print(util.utf2unicode(str(e)), file=sys.stderr)
             return None
 
@@ -133,5 +133,5 @@
             try:
                 values = pyuipc.read(data)
-            except TypeError, e:
+            except TypeError as e:
                 exception = e
 
@@ -174,5 +174,5 @@
                 try:
                     pyuipc.write(self._data)
-                except TypeError, e:
+                except TypeError as e:
                     exception = e
 
@@ -420,8 +420,8 @@
                 self._connected = True
                 return attempts
-            except Exception, e:
-                print "fsuipc.Handler._connect: connection failed: " + \
+            except Exception as e:
+                print("fsuipc.Handler._connect: connection failed: " + \
                       util.utf2unicode(str(e)) + \
-                      " (attempts: %d)" % (attempts,)
+                      " (attempts: %d)" % (attempts,))
                 if attempts<self.NUM_CONNECTATTEMPTS:
                     time.sleep(self.CONNECT_INTERVAL)
@@ -454,5 +454,5 @@
     def _disconnect(self):
         """Disconnect from the flight simulator."""
-        print "fsuipc.Handler._disconnect"
+        print("fsuipc.Handler._disconnect")
         if self._connected:
             pyuipc.close()
@@ -479,16 +479,16 @@
             try:
                 if not request.process(time):
-                    print "fsuipc.Handler._processRequest: FSUIPC returned invalid data too many times, reconnecting"
+                    print("fsuipc.Handler._processRequest: FSUIPC returned invalid data too many times, reconnecting")
                     needReconnect = True
             except TypeError as e:
-                print "fsuipc.Handler._processRequest: type error: " + \
+                print("fsuipc.Handler._processRequest: type error: " + \
                       util.utf2unicode(str(e)) + \
                       ("." if request.unimportant else
-                       (", reconnecting (attempts=%d)." % (attempts,)))
+                       (", reconnecting (attempts=%d)." % (attempts,))))
                 needReconnect = not request.unimportant
             except Exception as e:
-                print "fsuipc.Handler._processRequest: FSUIPC connection failed (" + \
+                print("fsuipc.Handler._processRequest: FSUIPC connection failed (" + \
                       util.utf2unicode(str(e)) + \
-                      "), reconnecting (attempts=%d)." % (attempts,)
+                      "), reconnecting (attempts=%d)." % (attempts,))
                 needReconnect = True
 
@@ -723,5 +723,5 @@
         duration is the number of seconds to keep the message displayed."""
 
-        print "fsuipc.Simulator.sendMessage:", message
+        print("fsuipc.Simulator.sendMessage:", message)
 
         if self._scroll:
@@ -732,6 +732,6 @@
         try:
             message = str(message)
-        except Exception, e:
-            print "fsuipc.Simulator.sendMessage: failed to convert the message to a string:", e
+        except Exception as e:
+            print("fsuipc.Simulator.sendMessage: failed to convert the message to a string:", e)
 
         data = [(0x3380, -1 - len(message), message),
@@ -822,5 +822,5 @@
         assert not self._monitoringRequested
 
-        print "fsuipc.Simulator.disconnect", closingMessage, duration
+        print("fsuipc.Simulator.disconnect", closingMessage, duration)
 
         self._stopNormal()
@@ -953,6 +953,6 @@
             return False
 
-        print "fsuipc.Simulator: new aircraft name and air file path: %s, %s" % \
-              (name, airPath)
+        print("fsuipc.Simulator: new aircraft name and air file path: %s, %s" % \
+              (name, airPath))
 
         self._aircraftName = aircraftName
@@ -1088,10 +1088,11 @@
             self._handler.disconnect()
 
-    def _handleNumHotkeys(self, data, (id, generation)):
+    def _handleNumHotkeys(self, data, xxx_todo_changeme5):
         """Handle the result of the query of the number of hotkeys"""
+        (id, generation) = xxx_todo_changeme5
         with self._hotkeyLock:
             if id==self._hotkeySetID and generation==self._hotkeySetGeneration:
                 numHotkeys = data[0]
-                print "fsuipc.Simulator._handleNumHotkeys: numHotkeys:", numHotkeys
+                print("fsuipc.Simulator._handleNumHotkeys: numHotkeys:", numHotkeys)
                 data = [(0x3210 + i*4, "d") for i in range(0, numHotkeys)]
                 self._handler.requestRead(data, self._handleHotkeyTable,
@@ -1135,10 +1136,11 @@
 
         for offset in oldHotkeyOffsets:
-            writeData.append((offset, "u", long(0)))
+            writeData.append((offset, "u", int(0)))
 
         return writeData
 
-    def _handleHotkeyTable(self, data, (id, generation)):
+    def _handleHotkeyTable(self, data, xxx_todo_changeme6):
         """Handle the result of the query of the hotkey table."""
+        (id, generation) = xxx_todo_changeme6
         with self._hotkeyLock:
             if id==self._hotkeySetID and generation==self._hotkeySetGeneration:
@@ -1148,6 +1150,7 @@
                                            (id, generation))
 
-    def _handleHotkeysWritten(self, success, (id, generation)):
+    def _handleHotkeysWritten(self, success, xxx_todo_changeme7):
         """Handle the result of the hotkeys having been written."""
+        (id, generation) = xxx_todo_changeme7
         with self._hotkeyLock:
             if success and id==self._hotkeySetID and \
@@ -1160,6 +1163,7 @@
                                                       (id, generation))
 
-    def _handleHotkeys(self, data, (id, generation)):
+    def _handleHotkeys(self, data, xxx_todo_changeme8):
         """Handle the hotkeys."""
+        (id, generation) = xxx_todo_changeme8
         with self._hotkeyLock:
             if id!=self._hotkeySetID or generation!=self._hotkeySetGeneration:
@@ -1406,8 +1410,8 @@
         state.flapsSet = self._flapsNotches[flapsIndex]
         if state.flapsSet != self._flapsSet:
-            print "flapsControl: %d, flapsLeft: %d, flapsRight: %d, flapsAxis: %d, flapsIncrement: %d, flapsSet: %d, numNotchesM1: %d" % \
+            print("flapsControl: %d, flapsLeft: %d, flapsRight: %d, flapsAxis: %d, flapsIncrement: %d, flapsSet: %d, numNotchesM1: %d" % \
                   (flapsControl, data[self._monidx_flapsLeft],
                    data[self._monidx_flapsRight], data[self._monidx_flapsAxis],
-                   data[self._monidx_flapsIncrement], state.flapsSet, numNotchesM1)
+                   data[self._monidx_flapsIncrement], state.flapsSet, numNotchesM1))
             self._flapsSet = state.flapsSet
 
@@ -1588,5 +1592,5 @@
         for (tank, level) in levels:
             offset = _tank2offset[tank]
-            value = long(level * 128.0 * 65536.0)
+            value = int(level * 128.0 * 65536.0)
             data.append( (offset, "u", value) )
 
@@ -1698,7 +1702,8 @@
     """A model handler for the PMDG Boeing 737NG model."""
     @staticmethod
-    def doesHandle(aircraft, (name, airPath)):
+    def doesHandle(aircraft, xxx_todo_changeme):
         """Determine if this model handler handles the aircraft with the given
         name."""
+        (name, airPath) = xxx_todo_changeme
         return aircraft.type in [const.AIRCRAFT_B736,
                                  const.AIRCRAFT_B737,
@@ -1730,6 +1735,6 @@
 
         if fsType==const.SIM_MSFSX or fsType==const.SIM_P3D:
-            print "%s detected, adding PMDG 737 NGX-specific offsets" % \
-                  ("FSX" if fsType==const.SIM_MSFSX else "P3D",)
+            print("%s detected, adding PMDG 737 NGX-specific offsets" % \
+                  ("FSX" if fsType==const.SIM_MSFSX else "P3D",))
             self._addOffsetWithIndexMember(data, 0x6500, "b",
                                            "_pmdgidx_lts_positionsw")
@@ -1741,5 +1746,5 @@
             self._addOffsetWithIndexMember(data, 0x65cd, "b", "_pmdgidx_xpdr")
         else:
-            print "FS9 detected, adding PMDG 737 NG-specific offsets"
+            print("FS9 detected, adding PMDG 737 NG-specific offsets")
             self._addOffsetWithIndexMember(data, 0x6202, "b", "_pmdgidx_switches")
             self._addOffsetWithIndexMember(data, 0x6216, "b", "_pmdgidx_xpdr")
@@ -1786,5 +1791,5 @@
 
         if gearControl!=self._lastGearControl or noseGear!=self._lastNoseGear:
-            print "gearControl:", gearControl, " noseGear:", noseGear
+            print("gearControl:", gearControl, " noseGear:", noseGear)
             self._lastGearControl = gearControl
             self._lastNoseGear = noseGear
@@ -1833,7 +1838,8 @@
     """Model handler for the Dreamwings Dash 8-Q400."""
     @staticmethod
-    def doesHandle(aircraft, (name, airPath)):
+    def doesHandle(aircraft, xxx_todo_changeme1):
         """Determine if this model handler handles the aircraft with the given
         name."""
+        (name, airPath) = xxx_todo_changeme1
         return aircraft.type==const.AIRCRAFT_DH8D and \
             (name.find("Dreamwings")!=-1 or airPath.find("Dreamwings")!=-1) and \
@@ -1870,7 +1876,8 @@
     """Model handler for the Majestic Dash 8-Q400."""
     @staticmethod
-    def doesHandle(aircraft, (name, airPath)):
+    def doesHandle(aircraft, xxx_todo_changeme2):
         """Determine if this model handler handles the aircraft with the given
         name."""
+        (name, airPath) = xxx_todo_changeme2
         return aircraft.type==const.AIRCRAFT_DH8D and \
             (name.find("MJC8Q400")!=-1 or \
@@ -1948,7 +1955,8 @@
     """Model for the Digital Aviation F70 implementation on FS9."""
     @staticmethod
-    def doesHandle(aircraft, (name, airPath)):
+    def doesHandle(aircraft, xxx_todo_changeme3):
         """Determine if this model handler handles the aircraft with the given
         name."""
+        (name, airPath) = xxx_todo_changeme3
         return aircraft.type == const.AIRCRAFT_F70 and \
                (airPath.endswith("fokker70_2k4_v4.1.air") or
@@ -2137,8 +2145,9 @@
     """Project Tupolev Tu-154."""
     @staticmethod
-    def doesHandle(aircraft, (name, airPath)):
+    def doesHandle(aircraft, xxx_todo_changeme4):
         """Determine if this model handler handles the aircraft with the given
         name."""
-        print "PTT154Model.doesHandle", aircraft.type, name, airPath
+        (name, airPath) = xxx_todo_changeme4
+        print("PTT154Model.doesHandle", aircraft.type, name, airPath)
         return aircraft.type==const.AIRCRAFT_T154 and \
                (name.find("Tu-154")!=-1 or name.find("Tu154B")!=-1) and \
