Changeset 919:2ce8ca39525b for src/mlx/xplane.py
- Timestamp:
- 03/24/19 08:15:59 (5 years ago)
- Branch:
- python3
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/xplane.py
r909 r919 1 1 2 import fs3 import const4 import util5 from watchdog import Watchdog2 from . import fs 3 from . import const 4 from . import util 5 from .watchdog import Watchdog 6 6 7 7 import threading … … 106 106 else: 107 107 return False 108 except ProtocolException ,e:108 except ProtocolException as e: 109 109 self._result = None 110 110 return True … … 241 241 try: 242 242 return fun() 243 except Exception ,e:244 print >> sys.stderr, util.utf2unicode(str(e))243 except Exception as e: 244 print(util.utf2unicode(str(e)), file=sys.stderr) 245 245 return None 246 246 … … 312 312 try: 313 313 multiGetter.execute() 314 except ProtocolException ,e:315 print "xplane.Handler._performRead: " + str(e)314 except ProtocolException as e: 315 print("xplane.Handler._performRead: " + str(e)) 316 316 raise 317 317 … … 514 514 self._connected = True 515 515 return attempts 516 except Exception ,e:517 print 516 except Exception as e: 517 print("xplane.Handler._connect: connection failed: " + \ 518 518 util.utf2unicode(str(e)) + \ 519 " (attempts: %d)" % (attempts,) 519 " (attempts: %d)" % (attempts,)) 520 520 if attempts<self.NUM_CONNECTATTEMPTS: 521 521 time.sleep(self.CONNECT_INTERVAL) … … 549 549 def _disconnect(self): 550 550 """Disconnect from the flight simulator.""" 551 print "xplane.Handler._disconnect"551 print("xplane.Handler._disconnect") 552 552 if self._connected: 553 553 try: … … 578 578 try: 579 579 if not request.process(time): 580 print "xplane.Handler._processRequest: X-Plane returned invalid data too many times, reconnecting"580 print("xplane.Handler._processRequest: X-Plane returned invalid data too many times, reconnecting") 581 581 needReconnect = True 582 582 except Exception as e: 583 print 583 print("xplane.Handler._processRequest: X-Plane connection failed (" + \ 584 584 util.utf2unicode(str(e)) + \ 585 "), reconnecting (attempts=%d)." % (attempts,) 585 "), reconnecting (attempts=%d)." % (attempts,)) 586 586 needReconnect = True 587 587 … … 804 804 805 805 duration is the number of seconds to keep the message displayed.""" 806 print "xplra.Simulator.sendMessage:", message806 print("xplra.Simulator.sendMessage:", message) 807 807 self._handler.requestShowMessage(message, duration, 808 808 self._handleMessageSent, … … 887 887 assert not self._monitoringRequested 888 888 889 print "xplra.Simulator.disconnect", closingMessage, duration889 print("xplra.Simulator.disconnect", closingMessage, duration) 890 890 891 891 self._stopNormal() … … 938 938 if self._lastZuluSeconds is not None and \ 939 939 zuluSeconds<self._lastZuluSeconds: 940 print 941 (self._lastZuluSeconds, zuluSeconds) 940 print("xplane.Simulator._getTimestamp: Zulu seconds have gone backwards (%f -> %f), increasing day offset" % \ 941 (self._lastZuluSeconds, zuluSeconds)) 942 942 self._timestampDaysOffset += 1 943 943 … … 1016 1016 return False 1017 1017 1018 print 1019 (tailnum, author, description, notes, icao, liveryPath) 1018 print("xplane.Simulator: new data: %s, %s, %s, %s, %s, %s" % \ 1019 (tailnum, author, description, notes, icao, liveryPath)) 1020 1020 1021 1021 self._aircraftInfo = aircraftInfo … … 1140 1140 self._handler.disconnect() 1141 1141 1142 def _handleHotkeysRegistered(self, success, (id, generation)):1142 def _handleHotkeysRegistered(self, success, xxx_todo_changeme2): 1143 1143 """Handle the result of the hotkeys having been written.""" 1144 (id, generation) = xxx_todo_changeme2 1144 1145 with self._hotkeyLock: 1145 1146 if success and id==self._hotkeySetID and \ … … 1150 1151 (id, generation)) 1151 1152 1152 def _handleHotkeys(self, data, (id, generation)):1153 def _handleHotkeys(self, data, xxx_todo_changeme3): 1153 1154 """Handle the hotkeys.""" 1155 (id, generation) = xxx_todo_changeme3 1154 1156 with self._hotkeyLock: 1155 1157 if id!=self._hotkeySetID or generation!=self._hotkeySetGeneration: … … 1617 1619 [level * self._fuelTankCapacities[index]]) ) 1618 1620 except: 1619 print 1620 (tank,) 1621 print("xplane.Simulator.setFuelLevel: invalid tank constant: %d" % \ 1622 (tank,)) 1621 1623 1622 1624 handler.requestWrite(data, self._handleFuelWritten) … … 1748 1750 """Model handler for the FlyJSim Dash 8-Q400.""" 1749 1751 @staticmethod 1750 def doesHandle(aircraft, (tailnum, author, description, notes, 1751 icao, liveryPath)): 1752 def doesHandle(aircraft, xxx_todo_changeme): 1752 1753 """Determine if this model handler handles the aircraft with the given 1753 1754 name.""" 1755 (tailnum, author, description, notes, 1756 icao, liveryPath) = xxx_todo_changeme 1754 1757 return aircraft.type==const.AIRCRAFT_DH8D and \ 1755 1758 description.find("Dash 8 Q400")!=-1 and \ … … 1909 1912 """Model for Felis' Tupolev Tu-154-M aircraft.""" 1910 1913 @staticmethod 1911 def doesHandle(aircraft, (tailnum, author, description, notes, 1912 icao, liveryPath)): 1914 def doesHandle(aircraft, xxx_todo_changeme1): 1913 1915 """Determine if this model handler handles the aircraft with the given 1914 1916 name.""" 1917 (tailnum, author, description, notes, 1918 icao, liveryPath) = xxx_todo_changeme1 1915 1919 return aircraft.type==const.AIRCRAFT_T154 and \ 1916 1920 author.find("Felis")!=-1 and \
Note:
See TracChangeset
for help on using the changeset viewer.