Ignore:
Timestamp:
03/24/19 08:15:59 (5 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Ran 2to3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/fsuipc.py

    r877 r919  
    11
    2 import fs
    3 import const
    4 import util
    5 import acft
    6 from watchdog import Watchdog
     2from . import fs
     3from . import const
     4from . import util
     5from . import acft
     6from .watchdog import Watchdog
    77
    88import threading
     
    1717    import pyuipc
    1818else:
    19     import pyuipc_sim as pyuipc
     19    from . import pyuipc_sim as pyuipc
    2020
    2121#------------------------------------------------------------------------------
     
    104104        try:
    105105            return fun()
    106         except Exception, e:
    107             print >> sys.stderr, util.utf2unicode(str(e))
     106        except Exception as e:
     107            print(util.utf2unicode(str(e)), file=sys.stderr)
    108108            return None
    109109
     
    133133            try:
    134134                values = pyuipc.read(data)
    135             except TypeError, e:
     135            except TypeError as e:
    136136                exception = e
    137137
     
    174174                try:
    175175                    pyuipc.write(self._data)
    176                 except TypeError, e:
     176                except TypeError as e:
    177177                    exception = e
    178178
     
    420420                self._connected = True
    421421                return attempts
    422             except Exception, e:
    423                 print "fsuipc.Handler._connect: connection failed: " + \
     422            except Exception as e:
     423                print("fsuipc.Handler._connect: connection failed: " + \
    424424                      util.utf2unicode(str(e)) + \
    425                       " (attempts: %d)" % (attempts,)
     425                      " (attempts: %d)" % (attempts,))
    426426                if attempts<self.NUM_CONNECTATTEMPTS:
    427427                    time.sleep(self.CONNECT_INTERVAL)
     
    454454    def _disconnect(self):
    455455        """Disconnect from the flight simulator."""
    456         print "fsuipc.Handler._disconnect"
     456        print("fsuipc.Handler._disconnect")
    457457        if self._connected:
    458458            pyuipc.close()
     
    479479            try:
    480480                if not request.process(time):
    481                     print "fsuipc.Handler._processRequest: FSUIPC returned invalid data too many times, reconnecting"
     481                    print("fsuipc.Handler._processRequest: FSUIPC returned invalid data too many times, reconnecting")
    482482                    needReconnect = True
    483483            except TypeError as e:
    484                 print "fsuipc.Handler._processRequest: type error: " + \
     484                print("fsuipc.Handler._processRequest: type error: " + \
    485485                      util.utf2unicode(str(e)) + \
    486486                      ("." if request.unimportant else
    487                        (", reconnecting (attempts=%d)." % (attempts,)))
     487                       (", reconnecting (attempts=%d)." % (attempts,))))
    488488                needReconnect = not request.unimportant
    489489            except Exception as e:
    490                 print "fsuipc.Handler._processRequest: FSUIPC connection failed (" + \
     490                print("fsuipc.Handler._processRequest: FSUIPC connection failed (" + \
    491491                      util.utf2unicode(str(e)) + \
    492                       "), reconnecting (attempts=%d)." % (attempts,)
     492                      "), reconnecting (attempts=%d)." % (attempts,))
    493493                needReconnect = True
    494494
     
    723723        duration is the number of seconds to keep the message displayed."""
    724724
    725         print "fsuipc.Simulator.sendMessage:", message
     725        print("fsuipc.Simulator.sendMessage:", message)
    726726
    727727        if self._scroll:
     
    732732        try:
    733733            message = str(message)
    734         except Exception, e:
    735             print "fsuipc.Simulator.sendMessage: failed to convert the message to a string:", e
     734        except Exception as e:
     735            print("fsuipc.Simulator.sendMessage: failed to convert the message to a string:", e)
    736736
    737737        data = [(0x3380, -1 - len(message), message),
     
    822822        assert not self._monitoringRequested
    823823
    824         print "fsuipc.Simulator.disconnect", closingMessage, duration
     824        print("fsuipc.Simulator.disconnect", closingMessage, duration)
    825825
    826826        self._stopNormal()
     
    953953            return False
    954954
    955         print "fsuipc.Simulator: new aircraft name and air file path: %s, %s" % \
    956               (name, airPath)
     955        print("fsuipc.Simulator: new aircraft name and air file path: %s, %s" % \
     956              (name, airPath))
    957957
    958958        self._aircraftName = aircraftName
     
    10881088            self._handler.disconnect()
    10891089
    1090     def _handleNumHotkeys(self, data, (id, generation)):
     1090    def _handleNumHotkeys(self, data, xxx_todo_changeme5):
    10911091        """Handle the result of the query of the number of hotkeys"""
     1092        (id, generation) = xxx_todo_changeme5
    10921093        with self._hotkeyLock:
    10931094            if id==self._hotkeySetID and generation==self._hotkeySetGeneration:
    10941095                numHotkeys = data[0]
    1095                 print "fsuipc.Simulator._handleNumHotkeys: numHotkeys:", numHotkeys
     1096                print("fsuipc.Simulator._handleNumHotkeys: numHotkeys:", numHotkeys)
    10961097                data = [(0x3210 + i*4, "d") for i in range(0, numHotkeys)]
    10971098                self._handler.requestRead(data, self._handleHotkeyTable,
     
    11351136
    11361137        for offset in oldHotkeyOffsets:
    1137             writeData.append((offset, "u", long(0)))
     1138            writeData.append((offset, "u", int(0)))
    11381139
    11391140        return writeData
    11401141
    1141     def _handleHotkeyTable(self, data, (id, generation)):
     1142    def _handleHotkeyTable(self, data, xxx_todo_changeme6):
    11421143        """Handle the result of the query of the hotkey table."""
     1144        (id, generation) = xxx_todo_changeme6
    11431145        with self._hotkeyLock:
    11441146            if id==self._hotkeySetID and generation==self._hotkeySetGeneration:
     
    11481150                                           (id, generation))
    11491151
    1150     def _handleHotkeysWritten(self, success, (id, generation)):
     1152    def _handleHotkeysWritten(self, success, xxx_todo_changeme7):
    11511153        """Handle the result of the hotkeys having been written."""
     1154        (id, generation) = xxx_todo_changeme7
    11521155        with self._hotkeyLock:
    11531156            if success and id==self._hotkeySetID and \
     
    11601163                                                      (id, generation))
    11611164
    1162     def _handleHotkeys(self, data, (id, generation)):
     1165    def _handleHotkeys(self, data, xxx_todo_changeme8):
    11631166        """Handle the hotkeys."""
     1167        (id, generation) = xxx_todo_changeme8
    11641168        with self._hotkeyLock:
    11651169            if id!=self._hotkeySetID or generation!=self._hotkeySetGeneration:
     
    14061410        state.flapsSet = self._flapsNotches[flapsIndex]
    14071411        if state.flapsSet != self._flapsSet:
    1408             print "flapsControl: %d, flapsLeft: %d, flapsRight: %d, flapsAxis: %d, flapsIncrement: %d, flapsSet: %d, numNotchesM1: %d" % \
     1412            print("flapsControl: %d, flapsLeft: %d, flapsRight: %d, flapsAxis: %d, flapsIncrement: %d, flapsSet: %d, numNotchesM1: %d" % \
    14091413                  (flapsControl, data[self._monidx_flapsLeft],
    14101414                   data[self._monidx_flapsRight], data[self._monidx_flapsAxis],
    1411                    data[self._monidx_flapsIncrement], state.flapsSet, numNotchesM1)
     1415                   data[self._monidx_flapsIncrement], state.flapsSet, numNotchesM1))
    14121416            self._flapsSet = state.flapsSet
    14131417
     
    15881592        for (tank, level) in levels:
    15891593            offset = _tank2offset[tank]
    1590             value = long(level * 128.0 * 65536.0)
     1594            value = int(level * 128.0 * 65536.0)
    15911595            data.append( (offset, "u", value) )
    15921596
     
    16981702    """A model handler for the PMDG Boeing 737NG model."""
    16991703    @staticmethod
    1700     def doesHandle(aircraft, (name, airPath)):
     1704    def doesHandle(aircraft, xxx_todo_changeme):
    17011705        """Determine if this model handler handles the aircraft with the given
    17021706        name."""
     1707        (name, airPath) = xxx_todo_changeme
    17031708        return aircraft.type in [const.AIRCRAFT_B736,
    17041709                                 const.AIRCRAFT_B737,
     
    17301735
    17311736        if fsType==const.SIM_MSFSX or fsType==const.SIM_P3D:
    1732             print "%s detected, adding PMDG 737 NGX-specific offsets" % \
    1733                   ("FSX" if fsType==const.SIM_MSFSX else "P3D",)
     1737            print("%s detected, adding PMDG 737 NGX-specific offsets" % \
     1738                  ("FSX" if fsType==const.SIM_MSFSX else "P3D",))
    17341739            self._addOffsetWithIndexMember(data, 0x6500, "b",
    17351740                                           "_pmdgidx_lts_positionsw")
     
    17411746            self._addOffsetWithIndexMember(data, 0x65cd, "b", "_pmdgidx_xpdr")
    17421747        else:
    1743             print "FS9 detected, adding PMDG 737 NG-specific offsets"
     1748            print("FS9 detected, adding PMDG 737 NG-specific offsets")
    17441749            self._addOffsetWithIndexMember(data, 0x6202, "b", "_pmdgidx_switches")
    17451750            self._addOffsetWithIndexMember(data, 0x6216, "b", "_pmdgidx_xpdr")
     
    17861791
    17871792        if gearControl!=self._lastGearControl or noseGear!=self._lastNoseGear:
    1788             print "gearControl:", gearControl, " noseGear:", noseGear
     1793            print("gearControl:", gearControl, " noseGear:", noseGear)
    17891794            self._lastGearControl = gearControl
    17901795            self._lastNoseGear = noseGear
     
    18331838    """Model handler for the Dreamwings Dash 8-Q400."""
    18341839    @staticmethod
    1835     def doesHandle(aircraft, (name, airPath)):
     1840    def doesHandle(aircraft, xxx_todo_changeme1):
    18361841        """Determine if this model handler handles the aircraft with the given
    18371842        name."""
     1843        (name, airPath) = xxx_todo_changeme1
    18381844        return aircraft.type==const.AIRCRAFT_DH8D and \
    18391845            (name.find("Dreamwings")!=-1 or airPath.find("Dreamwings")!=-1) and \
     
    18701876    """Model handler for the Majestic Dash 8-Q400."""
    18711877    @staticmethod
    1872     def doesHandle(aircraft, (name, airPath)):
     1878    def doesHandle(aircraft, xxx_todo_changeme2):
    18731879        """Determine if this model handler handles the aircraft with the given
    18741880        name."""
     1881        (name, airPath) = xxx_todo_changeme2
    18751882        return aircraft.type==const.AIRCRAFT_DH8D and \
    18761883            (name.find("MJC8Q400")!=-1 or \
     
    19481955    """Model for the Digital Aviation F70 implementation on FS9."""
    19491956    @staticmethod
    1950     def doesHandle(aircraft, (name, airPath)):
     1957    def doesHandle(aircraft, xxx_todo_changeme3):
    19511958        """Determine if this model handler handles the aircraft with the given
    19521959        name."""
     1960        (name, airPath) = xxx_todo_changeme3
    19531961        return aircraft.type == const.AIRCRAFT_F70 and \
    19541962               (airPath.endswith("fokker70_2k4_v4.1.air") or
     
    21372145    """Project Tupolev Tu-154."""
    21382146    @staticmethod
    2139     def doesHandle(aircraft, (name, airPath)):
     2147    def doesHandle(aircraft, xxx_todo_changeme4):
    21402148        """Determine if this model handler handles the aircraft with the given
    21412149        name."""
    2142         print "PTT154Model.doesHandle", aircraft.type, name, airPath
     2150        (name, airPath) = xxx_todo_changeme4
     2151        print("PTT154Model.doesHandle", aircraft.type, name, airPath)
    21432152        return aircraft.type==const.AIRCRAFT_T154 and \
    21442153               (name.find("Tu-154")!=-1 or name.find("Tu154B")!=-1) and \
Note: See TracChangeset for help on using the changeset viewer.