Changeset 919:2ce8ca39525b for src
- Timestamp:
- 03/24/19 08:15:59 (6 years ago)
- Branch:
- python3
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 45 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acars.py
r743 r919 1 1 2 import const2 from . import const 3 3 4 4 #------------------------------------------------------------------------------ -
src/mlx/acft.py
r905 r919 1 1 2 import const3 import gates4 import checks5 import fs6 from i18n import xstr7 import util2 from . import const 3 from . import gates 4 from . import checks 5 from . import fs 6 from .i18n import xstr 7 from . import util 8 8 9 9 import sys … … 308 308 ("-" if value is None else "enabled" if value else "disabled",) 309 309 elif dt!=DERATE_NONE: 310 print "mlx.acft.getDerateLine: invalid derate type: " + dt310 print("mlx.acft.getDerateLine: invalid derate type: " + dt) 311 311 312 312 return None … … 343 343 self._aircraftState, aircraftState) 344 344 except: 345 print >> sys.stderr, "Checker", checker, "failed"345 print("Checker", checker, "failed", file=sys.stderr) 346 346 traceback.print_exc() 347 347 … … 351 351 self._minVS = min(self._minVS, aircraftState.vs) 352 352 except: 353 print >> sys.stderr, "Failed to handle the state"353 print("Failed to handle the state", file=sys.stderr) 354 354 traceback.print_exc() 355 355 finally: … … 403 403 self._logQNH(aircraftState) 404 404 elif newStage==const.STAGE_GOAROUND: 405 from logger import Logger405 from .logger import Logger 406 406 self._flight.handleFault("goaround", 407 407 aircraftState.timestamp, … … 1284 1284 value = SmoothedValue() 1285 1285 1286 print "Adding 1, 12.0"1286 print("Adding 1, 12.0") 1287 1287 value.add(1, 12.0) 1288 print value.get()1289 1290 print "Adding 1, 15.0"1288 print(value.get()) 1289 1290 print("Adding 1, 15.0") 1291 1291 value.add(1, 15.0) 1292 print value.get()1293 1294 print "Adding 2, 18.0"1292 print(value.get()) 1293 1294 print("Adding 2, 18.0") 1295 1295 value.add(2, 18.0) 1296 print value.get()1297 1298 print "Adding 2, 20.0"1296 print(value.get()) 1297 1298 print("Adding 2, 20.0") 1299 1299 value.add(2, 20.0) 1300 print value.get()1301 1302 print "Adding 5, 22.0"1300 print(value.get()) 1301 1302 print("Adding 5, 22.0") 1303 1303 value.add(5, 22.0) 1304 print value.get()1305 1306 print "Adding 5, 25.0"1304 print(value.get()) 1305 1306 print("Adding 5, 25.0") 1307 1307 value.add(5, 25.0) 1308 print value.get()1309 1310 print "Adding 5, 29.0"1308 print(value.get()) 1309 1310 print("Adding 5, 29.0") 1311 1311 value.add(5, 29.0) 1312 print value.get()1313 1314 print "Adding 5, 21.0"1312 print(value.get()) 1313 1314 print("Adding 5, 21.0") 1315 1315 value.add(5, 21.0) 1316 print value.get()1317 1318 print "Adding 5, 26.0"1316 print(value.get()) 1317 1318 print("Adding 5, 26.0") 1319 1319 value.add(5, 26.0) 1320 print value.get()1321 1322 print "Adding 2, 30.0"1320 print(value.get()) 1321 1322 print("Adding 2, 30.0") 1323 1323 value.add(2, 30.0) 1324 print value.get()1325 1326 print "Adding 2, 55.0"1324 print(value.get()) 1325 1326 print("Adding 2, 55.0") 1327 1327 value.add(2, 55.0) 1328 print value.get()1329 1330 #--------------------------------------------------------------------------------------- 1328 print(value.get()) 1329 1330 #--------------------------------------------------------------------------------------- -
src/mlx/airports.py
r325 r919 88 88 89 89 if __name__ == "__main__": 90 for (town, airport) in airportNames. itervalues():91 print town, airport92 print getWelcomeMessage("LIRF")93 print getWelcomeMessage("LHDC")94 print getWelcomeMessage("LIRN")95 print getWelcomeMessage("LHBP")96 print getWelcomeMessage("EDDF")90 for (town, airport) in airportNames.values(): 91 print(town, airport) 92 print(getWelcomeMessage("LIRF")) 93 print(getWelcomeMessage("LHDC")) 94 print(getWelcomeMessage("LIRN")) 95 print(getWelcomeMessage("LHBP")) 96 print(getWelcomeMessage("EDDF")) 97 97 98 98 #----------------------------------------------------------------------------- -
src/mlx/checks.py
r912 r919 1 1 2 import fs3 import const4 import util5 from acars import ACARS6 from sound import startSound2 from . import fs 3 from . import const 4 from . import util 5 from .acars import ACARS 6 from .sound import startSound 7 7 8 8 import time … … 129 129 """Callback for ACARS sending.""" 130 130 if returned: 131 print "Sent online ACARS"131 print("Sent online ACARS") 132 132 self._lastSent = time.time() if self._lastSent is None \ 133 133 else self._lastSent + ACARSSender.INTERVAL 134 134 else: 135 print "Failed to send the ACARS"135 print("Failed to send the ACARS") 136 136 self._sending = False 137 137 … … 517 517 def getMessage(logName, frequency, obs): 518 518 """Get the message for the given NAV radio setting.""" 519 message = u"%-5s %s" % (logName + ":", frequency)520 if obs is not None: message += u" (%03d\u00b0)" % (obs,)519 message = "%-5s %s" % (logName + ":", frequency) 520 if obs is not None: message += " (%03d\u00b0)" % (obs,) 521 521 return message 522 522 … … 747 747 message = what 748 748 if value is None: 749 message += u" cannot be detected, will not log"749 message += " cannot be detected, will not log" 750 750 else: 751 message += u": " + format % (value,)751 message += ": " + format % (value,) 752 752 logger.message(timestamp, message) 753 753 … … 767 767 def _logAPHeading(logger, timestamp, state): 768 768 """Log the AP heading.""" 769 APLogger._logNumeric(logger, timestamp, u"AP heading",770 u"%03.0f\u00b0", state.apHeading)769 APLogger._logNumeric(logger, timestamp, "AP heading", 770 "%03.0f\u00b0", state.apHeading) 771 771 772 772 @staticmethod … … 779 779 def _logAPAltitude(logger, timestamp, state): 780 780 """Log the AP heading.""" 781 APLogger._logNumeric(logger, timestamp, u"AP altitude",782 u"%.0f ft", state.apAltitude)781 APLogger._logNumeric(logger, timestamp, "AP altitude", 782 "%.0f ft", state.apAltitude) 783 783 784 784 def __init__(self): -
src/mlx/common.py
r800 r919 24 24 # Due to CEF, PyGTK is the default 25 25 if "FORCE_PYGOBJECT" not in os.environ: 26 print "Using PyGTK"26 print("Using PyGTK") 27 27 pygobject = False 28 28 import gobject 29 29 else: 30 print "Using PyGObject"30 print("Using PyGObject") 31 31 pygobject = True 32 32 -
src/mlx/config.py
r738 r919 1 1 # -*- encoding: utf-8 -*- 2 2 3 import const4 from util import secondaryInstallation, utf2unicode3 from . import const 4 from .util import secondaryInstallation, utf2unicode 5 5 6 6 import os 7 7 import sys 8 8 import traceback 9 import ConfigParser9 import configparser 10 10 11 11 ## @package mlx.config … … 163 163 baseName = "callouts." + const.icaoCodes[aircraftType] + "." 164 164 index = 0 165 for (altitude, path) in self._mapping.ite ritems():165 for (altitude, path) in self._mapping.items(): 166 166 option = baseName + str(index) 167 167 config.set(ApproachCallouts.SECTION, option, … … 171 171 def getAltitudes(self, descending = True): 172 172 """Get the altitudes in decreasing order by default.""" 173 altitudes = self._mapping.keys()173 altitudes = list(self._mapping.keys()) 174 174 altitudes.sort(reverse = descending) 175 175 return altitudes 176 176 177 def __ nonzero__(self):177 def __bool__(self): 178 178 """Return if there is anything in the mapping.""" 179 179 return not not self._mapping … … 704 704 """Load the configuration from its default location.""" 705 705 try: 706 config = ConfigParser.RawConfigParser()706 config = configparser.RawConfigParser() 707 707 config.read(configPath) 708 708 except: … … 806 806 return 807 807 808 config = ConfigParser.RawConfigParser()808 config = configparser.RawConfigParser() 809 809 810 810 config.add_section("login") … … 892 892 try: 893 893 fd = os.open(configPath, os.O_CREAT|os.O_TRUNC|os.O_WRONLY, 894 0 600)894 0o600) 895 895 with os.fdopen(fd, "wt") as f: 896 896 config.write(f) 897 897 self._modified = False 898 898 899 print "Configuration saved:"899 print("Configuration saved:") 900 900 self.log() 901 901 902 except Exception ,e:903 print >> sys.stderr,"Failed to update config: " + \904 utf2unicode(str(e)) 902 except Exception as e: 903 print("Failed to update config: " + \ 904 utf2unicode(str(e)), file=sys.stderr) 905 905 906 906 def _getBoolean(self, config, section, option, default): … … 945 945 import locale 946 946 if self._language: 947 print "Setting up locale for", self._language947 print("Setting up locale for", self._language) 948 948 os.environ["LANGUAGE"] = self._language 949 949 langAndEncoding = self._language + "." + locale.getpreferredencoding() … … 978 978 def log(self): 979 979 """Log the configuration by printing the values""" 980 print " pilot ID:", self._pilotID981 print " rememberPassword:", self._rememberPassword982 983 print " language:", self._language984 985 print " hideMinimizedWindow:", self._hideMinimizedWindow986 print " quitOnClose:", self._quitOnClose987 988 print " onlineGateSystem:", self._onlineGateSystem989 print " onlineACARS:", self._onlineACARS990 991 print " flareTimeFromFS:", self._flareTimeFromFS992 print " syncFSTime:", self._syncFSTime993 print " usingFS2Crew:", self._usingFS2Crew994 995 print " iasSmoothingLength:", self._iasSmoothingLength996 print " vsSmoothingLength:", self._vsSmoothingLength997 998 print " useSimBrief:", self._useSimBrief999 print " simBriefUserName:", self._simBriefUserName1000 print " rememberSimBriefPassword:", self._rememberSimBriefPassword1001 1002 print " pirepDirectory:", self._pirepDirectory1003 print " pirepAutoSave:", self._pirepAutoSave1004 1005 print " defaultMSFS:", self._defaultMSFS1006 1007 print " enableSounds:", self._enableSounds1008 1009 print " pilotControlsSounds:", self._pilotControlsSounds1010 print " pilotHotkey:", str(self._pilotHotkey)1011 1012 print " enableApproachCallouts:", self._enableApproachCallouts1013 print " speedbrakeAtTD:", self._speedbrakeAtTD1014 1015 print " enableChecklists:", self._enableChecklists1016 print " checklistHotkey:", str(self._checklistHotkey)1017 1018 print " autoUpdate:", self._autoUpdate1019 print " updateURL:", self._updateURL1020 print " useRPC:", self._useRPC1021 1022 print " messageTypeLevels:"1023 for (type, level) in self._messageTypeLevels.ite ritems():1024 print 1025 const.messageLevel2string(level)) 1026 1027 print " checklists:"1028 for (type, checklist) in self._checklists.ite ritems():1029 print " %s:" % (const.icaoCodes[type],)980 print(" pilot ID:", self._pilotID) 981 print(" rememberPassword:", self._rememberPassword) 982 983 print(" language:", self._language) 984 985 print(" hideMinimizedWindow:", self._hideMinimizedWindow) 986 print(" quitOnClose:", self._quitOnClose) 987 988 print(" onlineGateSystem:", self._onlineGateSystem) 989 print(" onlineACARS:", self._onlineACARS) 990 991 print(" flareTimeFromFS:", self._flareTimeFromFS) 992 print(" syncFSTime:", self._syncFSTime) 993 print(" usingFS2Crew:", self._usingFS2Crew) 994 995 print(" iasSmoothingLength:", self._iasSmoothingLength) 996 print(" vsSmoothingLength:", self._vsSmoothingLength) 997 998 print(" useSimBrief:", self._useSimBrief) 999 print(" simBriefUserName:", self._simBriefUserName) 1000 print(" rememberSimBriefPassword:", self._rememberSimBriefPassword) 1001 1002 print(" pirepDirectory:", self._pirepDirectory) 1003 print(" pirepAutoSave:", self._pirepAutoSave) 1004 1005 print(" defaultMSFS:", self._defaultMSFS) 1006 1007 print(" enableSounds:", self._enableSounds) 1008 1009 print(" pilotControlsSounds:", self._pilotControlsSounds) 1010 print(" pilotHotkey:", str(self._pilotHotkey)) 1011 1012 print(" enableApproachCallouts:", self._enableApproachCallouts) 1013 print(" speedbrakeAtTD:", self._speedbrakeAtTD) 1014 1015 print(" enableChecklists:", self._enableChecklists) 1016 print(" checklistHotkey:", str(self._checklistHotkey)) 1017 1018 print(" autoUpdate:", self._autoUpdate) 1019 print(" updateURL:", self._updateURL) 1020 print(" useRPC:", self._useRPC) 1021 1022 print(" messageTypeLevels:") 1023 for (type, level) in self._messageTypeLevels.items(): 1024 print(" %s: %s" % (const.messageType2string(type), 1025 const.messageLevel2string(level))) 1026 1027 print(" checklists:") 1028 for (type, checklist) in self._checklists.items(): 1029 print(" %s:" % (const.icaoCodes[type],)) 1030 1030 for path in checklist: 1031 print " " + path1032 1033 print " approachCallouts:"1034 for (type, approachCallouts) in self._approachCallouts.ite ritems():1035 print " %s:" % (const.icaoCodes[type],)1031 print(" " + path) 1032 1033 print(" approachCallouts:") 1034 for (type, approachCallouts) in self._approachCallouts.items(): 1035 print(" %s:" % (const.icaoCodes[type],)) 1036 1036 for (altitude, path) in approachCallouts: 1037 print " %d: %s" % (altitude, path)1037 print(" %d: %s" % (altitude, path)) 1038 1038 1039 1039 #------------------------------------------------------------------------------- -
src/mlx/const.py
r911 r919 193 193 def aircraftType2Family(aircraftType): 194 194 """Get the family for the given aircraft type.""" 195 for (family, types) in aircraftFamily2Types.ite ritems():195 for (family, types) in aircraftFamily2Types.items(): 196 196 if aircraftType in types: 197 197 return family … … 424 424 def string2messageLevel(str): 425 425 """Get the message level for the given string.""" 426 for (value, s) in _messageLevelStrings.ite ritems():426 for (value, s) in _messageLevelStrings.items(): 427 427 if str==s: 428 428 return value -
src/mlx/flight.py
r846 r919 1 1 2 from soundsched import SoundScheduler, ChecklistScheduler3 from checks import SpeedChecker4 5 import const6 import util2 from .soundsched import SoundScheduler, ChecklistScheduler 3 from .checks import SpeedChecker 4 5 from . import const 6 from . import util 7 7 import time 8 8 -
src/mlx/fs.py
r909 r919 1 1 2 import const3 from sound import startSound2 from . import const 3 from .sound import startSound 4 4 5 5 import os 6 6 7 import fsuipc8 import xplane7 from . import fsuipc 8 from . import xplane 9 9 10 10 import threading … … 36 36 """Called when a connection has been established to the flight 37 37 simulator of the given type.""" 38 print "fs.ConnectionListener.connected, fsType:", fsType, ", descriptor:", descriptor38 print("fs.ConnectionListener.connected, fsType:", fsType, ", descriptor:", descriptor) 39 39 40 40 def connectionFailed(self): 41 41 """Called when the connection could not be established.""" 42 print "fs.ConnectionListener.connectionFailed"42 print("fs.ConnectionListener.connectionFailed") 43 43 44 44 def disconnected(self): 45 45 """Called when a connection to the flight simulator has been broken.""" 46 print "fs.ConnectionListener.disconnected"46 print("fs.ConnectionListener.disconnected") 47 47 48 48 #------------------------------------------------------------------------------- -
src/mlx/fsuipc.py
r877 r919 1 1 2 import fs3 import const4 import util5 import acft6 from watchdog import Watchdog2 from . import fs 3 from . import const 4 from . import util 5 from . import acft 6 from .watchdog import Watchdog 7 7 8 8 import threading … … 17 17 import pyuipc 18 18 else: 19 import pyuipc_sim as pyuipc19 from . import pyuipc_sim as pyuipc 20 20 21 21 #------------------------------------------------------------------------------ … … 104 104 try: 105 105 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) 108 108 return None 109 109 … … 133 133 try: 134 134 values = pyuipc.read(data) 135 except TypeError ,e:135 except TypeError as e: 136 136 exception = e 137 137 … … 174 174 try: 175 175 pyuipc.write(self._data) 176 except TypeError ,e:176 except TypeError as e: 177 177 exception = e 178 178 … … 420 420 self._connected = True 421 421 return attempts 422 except Exception ,e:423 print 422 except Exception as e: 423 print("fsuipc.Handler._connect: connection failed: " + \ 424 424 util.utf2unicode(str(e)) + \ 425 " (attempts: %d)" % (attempts,) 425 " (attempts: %d)" % (attempts,)) 426 426 if attempts<self.NUM_CONNECTATTEMPTS: 427 427 time.sleep(self.CONNECT_INTERVAL) … … 454 454 def _disconnect(self): 455 455 """Disconnect from the flight simulator.""" 456 print "fsuipc.Handler._disconnect"456 print("fsuipc.Handler._disconnect") 457 457 if self._connected: 458 458 pyuipc.close() … … 479 479 try: 480 480 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") 482 482 needReconnect = True 483 483 except TypeError as e: 484 print 484 print("fsuipc.Handler._processRequest: type error: " + \ 485 485 util.utf2unicode(str(e)) + \ 486 486 ("." if request.unimportant else 487 (", reconnecting (attempts=%d)." % (attempts,))) 487 (", reconnecting (attempts=%d)." % (attempts,)))) 488 488 needReconnect = not request.unimportant 489 489 except Exception as e: 490 print 490 print("fsuipc.Handler._processRequest: FSUIPC connection failed (" + \ 491 491 util.utf2unicode(str(e)) + \ 492 "), reconnecting (attempts=%d)." % (attempts,) 492 "), reconnecting (attempts=%d)." % (attempts,)) 493 493 needReconnect = True 494 494 … … 723 723 duration is the number of seconds to keep the message displayed.""" 724 724 725 print "fsuipc.Simulator.sendMessage:", message725 print("fsuipc.Simulator.sendMessage:", message) 726 726 727 727 if self._scroll: … … 732 732 try: 733 733 message = str(message) 734 except Exception ,e:735 print "fsuipc.Simulator.sendMessage: failed to convert the message to a string:", e734 except Exception as e: 735 print("fsuipc.Simulator.sendMessage: failed to convert the message to a string:", e) 736 736 737 737 data = [(0x3380, -1 - len(message), message), … … 822 822 assert not self._monitoringRequested 823 823 824 print "fsuipc.Simulator.disconnect", closingMessage, duration824 print("fsuipc.Simulator.disconnect", closingMessage, duration) 825 825 826 826 self._stopNormal() … … 953 953 return False 954 954 955 print 956 (name, airPath) 955 print("fsuipc.Simulator: new aircraft name and air file path: %s, %s" % \ 956 (name, airPath)) 957 957 958 958 self._aircraftName = aircraftName … … 1088 1088 self._handler.disconnect() 1089 1089 1090 def _handleNumHotkeys(self, data, (id, generation)):1090 def _handleNumHotkeys(self, data, xxx_todo_changeme5): 1091 1091 """Handle the result of the query of the number of hotkeys""" 1092 (id, generation) = xxx_todo_changeme5 1092 1093 with self._hotkeyLock: 1093 1094 if id==self._hotkeySetID and generation==self._hotkeySetGeneration: 1094 1095 numHotkeys = data[0] 1095 print "fsuipc.Simulator._handleNumHotkeys: numHotkeys:", numHotkeys1096 print("fsuipc.Simulator._handleNumHotkeys: numHotkeys:", numHotkeys) 1096 1097 data = [(0x3210 + i*4, "d") for i in range(0, numHotkeys)] 1097 1098 self._handler.requestRead(data, self._handleHotkeyTable, … … 1135 1136 1136 1137 for offset in oldHotkeyOffsets: 1137 writeData.append((offset, "u", long(0)))1138 writeData.append((offset, "u", int(0))) 1138 1139 1139 1140 return writeData 1140 1141 1141 def _handleHotkeyTable(self, data, (id, generation)):1142 def _handleHotkeyTable(self, data, xxx_todo_changeme6): 1142 1143 """Handle the result of the query of the hotkey table.""" 1144 (id, generation) = xxx_todo_changeme6 1143 1145 with self._hotkeyLock: 1144 1146 if id==self._hotkeySetID and generation==self._hotkeySetGeneration: … … 1148 1150 (id, generation)) 1149 1151 1150 def _handleHotkeysWritten(self, success, (id, generation)):1152 def _handleHotkeysWritten(self, success, xxx_todo_changeme7): 1151 1153 """Handle the result of the hotkeys having been written.""" 1154 (id, generation) = xxx_todo_changeme7 1152 1155 with self._hotkeyLock: 1153 1156 if success and id==self._hotkeySetID and \ … … 1160 1163 (id, generation)) 1161 1164 1162 def _handleHotkeys(self, data, (id, generation)):1165 def _handleHotkeys(self, data, xxx_todo_changeme8): 1163 1166 """Handle the hotkeys.""" 1167 (id, generation) = xxx_todo_changeme8 1164 1168 with self._hotkeyLock: 1165 1169 if id!=self._hotkeySetID or generation!=self._hotkeySetGeneration: … … 1406 1410 state.flapsSet = self._flapsNotches[flapsIndex] 1407 1411 if state.flapsSet != self._flapsSet: 1408 print 1412 print("flapsControl: %d, flapsLeft: %d, flapsRight: %d, flapsAxis: %d, flapsIncrement: %d, flapsSet: %d, numNotchesM1: %d" % \ 1409 1413 (flapsControl, data[self._monidx_flapsLeft], 1410 1414 data[self._monidx_flapsRight], data[self._monidx_flapsAxis], 1411 data[self._monidx_flapsIncrement], state.flapsSet, numNotchesM1) 1415 data[self._monidx_flapsIncrement], state.flapsSet, numNotchesM1)) 1412 1416 self._flapsSet = state.flapsSet 1413 1417 … … 1588 1592 for (tank, level) in levels: 1589 1593 offset = _tank2offset[tank] 1590 value = long(level * 128.0 * 65536.0)1594 value = int(level * 128.0 * 65536.0) 1591 1595 data.append( (offset, "u", value) ) 1592 1596 … … 1698 1702 """A model handler for the PMDG Boeing 737NG model.""" 1699 1703 @staticmethod 1700 def doesHandle(aircraft, (name, airPath)):1704 def doesHandle(aircraft, xxx_todo_changeme): 1701 1705 """Determine if this model handler handles the aircraft with the given 1702 1706 name.""" 1707 (name, airPath) = xxx_todo_changeme 1703 1708 return aircraft.type in [const.AIRCRAFT_B736, 1704 1709 const.AIRCRAFT_B737, … … 1730 1735 1731 1736 if fsType==const.SIM_MSFSX or fsType==const.SIM_P3D: 1732 print 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",)) 1734 1739 self._addOffsetWithIndexMember(data, 0x6500, "b", 1735 1740 "_pmdgidx_lts_positionsw") … … 1741 1746 self._addOffsetWithIndexMember(data, 0x65cd, "b", "_pmdgidx_xpdr") 1742 1747 else: 1743 print "FS9 detected, adding PMDG 737 NG-specific offsets"1748 print("FS9 detected, adding PMDG 737 NG-specific offsets") 1744 1749 self._addOffsetWithIndexMember(data, 0x6202, "b", "_pmdgidx_switches") 1745 1750 self._addOffsetWithIndexMember(data, 0x6216, "b", "_pmdgidx_xpdr") … … 1786 1791 1787 1792 if gearControl!=self._lastGearControl or noseGear!=self._lastNoseGear: 1788 print "gearControl:", gearControl, " noseGear:", noseGear1793 print("gearControl:", gearControl, " noseGear:", noseGear) 1789 1794 self._lastGearControl = gearControl 1790 1795 self._lastNoseGear = noseGear … … 1833 1838 """Model handler for the Dreamwings Dash 8-Q400.""" 1834 1839 @staticmethod 1835 def doesHandle(aircraft, (name, airPath)):1840 def doesHandle(aircraft, xxx_todo_changeme1): 1836 1841 """Determine if this model handler handles the aircraft with the given 1837 1842 name.""" 1843 (name, airPath) = xxx_todo_changeme1 1838 1844 return aircraft.type==const.AIRCRAFT_DH8D and \ 1839 1845 (name.find("Dreamwings")!=-1 or airPath.find("Dreamwings")!=-1) and \ … … 1870 1876 """Model handler for the Majestic Dash 8-Q400.""" 1871 1877 @staticmethod 1872 def doesHandle(aircraft, (name, airPath)):1878 def doesHandle(aircraft, xxx_todo_changeme2): 1873 1879 """Determine if this model handler handles the aircraft with the given 1874 1880 name.""" 1881 (name, airPath) = xxx_todo_changeme2 1875 1882 return aircraft.type==const.AIRCRAFT_DH8D and \ 1876 1883 (name.find("MJC8Q400")!=-1 or \ … … 1948 1955 """Model for the Digital Aviation F70 implementation on FS9.""" 1949 1956 @staticmethod 1950 def doesHandle(aircraft, (name, airPath)):1957 def doesHandle(aircraft, xxx_todo_changeme3): 1951 1958 """Determine if this model handler handles the aircraft with the given 1952 1959 name.""" 1960 (name, airPath) = xxx_todo_changeme3 1953 1961 return aircraft.type == const.AIRCRAFT_F70 and \ 1954 1962 (airPath.endswith("fokker70_2k4_v4.1.air") or … … 2137 2145 """Project Tupolev Tu-154.""" 2138 2146 @staticmethod 2139 def doesHandle(aircraft, (name, airPath)):2147 def doesHandle(aircraft, xxx_todo_changeme4): 2140 2148 """Determine if this model handler handles the aircraft with the given 2141 2149 name.""" 2142 print "PTT154Model.doesHandle", aircraft.type, name, airPath 2150 (name, airPath) = xxx_todo_changeme4 2151 print("PTT154Model.doesHandle", aircraft.type, name, airPath) 2143 2152 return aircraft.type==const.AIRCRAFT_T154 and \ 2144 2153 (name.find("Tu-154")!=-1 or name.find("Tu154B")!=-1) and \ -
src/mlx/gui/acars.py
r747 r919 1 1 2 from common import *2 from .common import * 3 3 4 4 from mlx.i18n import xstr 5 5 import mlx.const as const 6 6 7 import cef7 from . import cef 8 8 9 9 #------------------------------------------------------------------------------ -
src/mlx/gui/bugreport.py
r492 r919 1 1 2 from common import *2 from .common import * 3 3 4 4 from mlx.i18n import xstr … … 105 105 response = super(BugReportDialog, self).run() 106 106 107 print "response", response, RESPONSETYPE_ACCEPT107 print("response", response, RESPONSETYPE_ACCEPT) 108 108 if response==RESPONSETYPE_ACCEPT: 109 109 self._send() -
src/mlx/gui/callouts.py
r300 r919 1 1 2 from common import *2 from .common import * 3 3 4 4 from mlx.i18n import xstr … … 208 208 config = self._gui.config 209 209 for (aircraftType, approachCallouts) in \ 210 self._approachCallouts.ite ritems():210 self._approachCallouts.items(): 211 211 config.setApproachCallouts(aircraftType, approachCallouts) 212 212 config.save() -
src/mlx/gui/cef.py
r915 r919 1 from common import *1 from .common import * 2 2 3 3 from mlx.util import secondaryInstallation … … 10 10 import os 11 11 import re 12 import thread12 import _thread 13 13 import threading 14 14 import tempfile 15 15 import traceback 16 import urllib 216 import urllib.request, urllib.error, urllib.parse 17 17 from lxml import etree 18 from StringIOimport StringIO18 from io import StringIO 19 19 import lxml.html 20 20 … … 115 115 """Called when a page has been loaded in the SimBrief browser.""" 116 116 url = frame.GetUrl() 117 print "gui.cef.SimBriefHandler._onLoadEnd", httpCode, url117 print("gui.cef.SimBriefHandler._onLoadEnd", httpCode, url) 118 118 if httpCode>=300: 119 119 self._updateProgress(self._lastProgress, … … 127 127 128 128 js = "form=document.getElementById(\"sbapiform\");" 129 for (name, value) in self._plan.ite ritems():129 for (name, value) in self._plan.items(): 130 130 js += "form." + name + ".value=\"" + value + "\";" 131 for (name, value) in SimBriefHandler._querySettings.ite ritems():131 for (name, value) in SimBriefHandler._querySettings.items(): 132 132 if isinstance(value, bool): 133 133 js += "form." + name + ".checked=" + \ … … 175 175 176 176 thread = threading.Thread(target = self._getResults, args = (link,)) 177 thread.daemon = True178 thread.start()177 _thread.daemon = True 178 _thread.start() 179 179 else: 180 180 self._updateProgress(SIMBRIEF_PROGRESS_RETRIEVING_BRIEFING, … … 219 219 220 220 # Obtaining the xml 221 response = urllib 2.urlopen(link)221 response = urllib.request.urlopen(link) 222 222 xmlContent = response.read() 223 223 # Processing xml … … 242 242 imageLinks.append(imageLink[2]) 243 243 flightInfo["image_links"] = imageLinks 244 print( sorted(availableInfo.keys()))244 print((sorted(availableInfo.keys()))) 245 245 htmlFilePath = "simbrief_plan.html" if self._htmlFilePath is None \ 246 246 else self._htmlFilePath … … 266 266 def _initializeCEF(args, initializedCallback): 267 267 """Perform the actual initialization of CEF using the given arguments.""" 268 print "Initializing CEF with args:", args268 print("Initializing CEF with args:", args) 269 269 270 270 settings = { … … 290 290 switches[arg[2:assignIndex]] = arg[assignIndex+1:] 291 291 else: 292 print "Unhandled switch", arg292 print("Unhandled switch", arg) 293 293 294 294 cefpython.Initialize(settings, switches) … … 296 296 gobject.timeout_add(10, _handleTimeout) 297 297 298 print "Initialized, executing callback..."298 print("Initialized, executing callback...") 299 299 initializedCallback() 300 300 … … 322 322 window = container.get_window() 323 323 if window is None: 324 print "mlx.gui.cef.startInContainer: no window found!"324 print("mlx.gui.cef.startInContainer: no window found!") 325 325 windowID = None 326 326 else: -
src/mlx/gui/checklist.py
r300 r919 1 1 2 from common import *2 from .common import * 3 3 4 4 from mlx.i18n import xstr … … 190 190 self._saveChecklist() 191 191 config = self._gui.config 192 for (aircraftType, checklist) in self._checklists.ite ritems():192 for (aircraftType, checklist) in self._checklists.items(): 193 193 config.setChecklist(aircraftType, checklist) 194 194 config.save() -
src/mlx/gui/common.py
r863 r919 31 31 32 32 if not pygobject: 33 print "Using PyGTK"33 print("Using PyGTK") 34 34 pygobject = False 35 35 import pygtk … … 42 42 import appindicator 43 43 appIndicator = True 44 except Exception ,e:44 except Exception as e: 45 45 pass 46 46 … … 113 113 def text2unicode(text): 114 114 """Convert the given text, returned by a Gtk widget, to Unicode.""" 115 return unicode(text)115 return str(text) 116 116 117 117 def text2str(text): -
src/mlx/gui/delaycodes.py
r840 r919 3 3 #------------------------------------------------------------------------------ 4 4 5 from dcdata import CAPTION, DELAYCODE, getTable5 from .dcdata import CAPTION, DELAYCODE, getTable 6 6 7 7 from mlx.gui.common import * -
src/mlx/gui/faultexplain.py
r842 r919 247 247 def reset(self): 248 248 """Reset the widget by removing all faults.""" 249 for (alignment, faultFrame) in self._faultWidgets. itervalues():249 for (alignment, faultFrame) in self._faultWidgets.values(): 250 250 self._faults.remove(alignment) 251 251 self._faults.show_all() -
src/mlx/gui/flight.py
r872 r919 405 405 def _offlineClicked(self, button): 406 406 """Called when the offline button was clicked.""" 407 print "mlx.flight.LoginPage: offline flight selected"407 print("mlx.flight.LoginPage: offline flight selected") 408 408 self._wizard.nextPage() 409 409 410 410 def _loginClicked(self, button): 411 411 """Called when the login button was clicked.""" 412 print "mlx.flight.LoginPage: logging in"412 print("mlx.flight.LoginPage: logging in") 413 413 self._wizard.login(self._handleLoginResult, 414 414 self._pilotID.get_text(), … … 649 649 if response==RESPONSETYPE_OK: 650 650 fileName = text2unicode(dialog.get_filename()) 651 print "Saving", fileName651 print("Saving", fileName) 652 652 try: 653 653 with open(fileName, "wt") as f: 654 654 flight.writeIntoFile(f) 655 except Exception ,e:656 print "Failed to save flight:", util.utf2unicode(str(e))655 except Exception as e: 656 print("Failed to save flight:", util.utf2unicode(str(e))) 657 657 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, 658 658 type = MESSAGETYPE_ERROR, … … 706 706 flight=self._getSelectedFlight() 707 707 708 print "DPI", context.get_dpi_x(), context.get_dpi_y()708 print("DPI", context.get_dpi_x(), context.get_dpi_y()) 709 709 710 710 scale = context.get_dpi_x() / 72.0 … … 719 719 720 720 layout = cr.create_layout() 721 layout.set_text( u"Malév VA official briefing")721 layout.set_text("Malév VA official briefing") 722 722 font = pango.FontDescription("sans") 723 723 font.set_size(int(32 * scale * pango.SCALE)) … … 740 740 741 741 layout = cr.create_layout() 742 layout.set_text( u"%s (%s) részére" %742 layout.set_text("%s (%s) részére" % 743 743 (loginResult.pilotName, loginResult.pilotID)) 744 744 font = pango.FontDescription("sans") … … 940 940 if response==RESPONSETYPE_OK: 941 941 fileName = text2unicode(dialog.get_filename()) 942 print "Loading", fileName942 print("Loading", fileName) 943 943 bookedFlight = web.BookedFlight() 944 944 try: … … 946 946 bookedFlight.readFromFile(f) 947 947 self.addFlight(bookedFlight) 948 except Exception ,e:949 print "Failed to load flight:", util.utf2unicode(str(e))948 except Exception as e: 949 print("Failed to load flight:", util.utf2unicode(str(e))) 950 950 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, 951 951 type = MESSAGETYPE_ERROR, … … 1629 1629 self.phoneNumber, self.nationality, 1630 1630 self.password) 1631 print "Registering with data:"1632 print " name:", self.name1, self.name2, registrationData.firstName, registrationData.surName, requestedNameOrder1633 print " yearOfBirth:", self.yearOfBirth, registrationData.yearOfBirth1634 print " emailAddress:", self.emailAddress, registrationData.emailAddress1635 print " emailAddressPublic:", self.emailAddressPublic, registrationData.emailAddressPublic1636 print " vatsimID:", self.vatsimID, registrationData.vatsimID1637 print " ivaoID:", self.ivaoID, registrationData.ivaoID1638 print " phoneNumber:", self.phoneNumber, registrationData.phoneNumber1639 print " nationality:", self.nationality, registrationData.nationality1631 print("Registering with data:") 1632 print(" name:", self.name1, self.name2, registrationData.firstName, registrationData.surName, requestedNameOrder) 1633 print(" yearOfBirth:", self.yearOfBirth, registrationData.yearOfBirth) 1634 print(" emailAddress:", self.emailAddress, registrationData.emailAddress) 1635 print(" emailAddressPublic:", self.emailAddressPublic, registrationData.emailAddressPublic) 1636 print(" vatsimID:", self.vatsimID, registrationData.vatsimID) 1637 print(" ivaoID:", self.ivaoID, registrationData.ivaoID) 1638 print(" phoneNumber:", self.phoneNumber, registrationData.phoneNumber) 1639 print(" nationality:", self.nationality, registrationData.nationality) 1640 1640 1641 1641 gui = self._wizard.gui … … 1653 1653 gui.endBusy() 1654 1654 1655 print "Registration result:"1656 print " returned:", returned1655 print("Registration result:") 1656 print(" returned:", returned) 1657 1657 if returned: 1658 print " registered:", result.registered1658 print(" registered:", result.registered) 1659 1659 if result.registered: 1660 print " pilotID", result.pilotID1661 print " loggedIn", result.loggedIn1662 print " emailAlreadyRegistered:", result.emailAlreadyRegistered1663 print " invalidData:", result.invalidData1660 print(" pilotID", result.pilotID) 1661 print(" loggedIn", result.loggedIn) 1662 print(" emailAlreadyRegistered:", result.emailAlreadyRegistered) 1663 print(" invalidData:", result.invalidData) 1664 1664 1665 1665 registrationOK = returned and result.registered … … 1830 1830 def activate(self): 1831 1831 """Activate the student page.""" 1832 print "StudentPage.activate"1832 print("StudentPage.activate") 1833 1833 self._getEntryExamStatusCancelled = False 1834 1834 … … 1844 1844 def finalize(self): 1845 1845 """Finalize the page.""" 1846 print "StudentPage.finalize"1846 print("StudentPage.finalize") 1847 1847 self._getEntryExamStatusCancelled = True 1848 1848 … … 1864 1864 def _handleEntryExamStatus(self, returned, result): 1865 1865 """Called when the entry exam status is availabe.""" 1866 print "_handleEntryExamStatus", returned, result1866 print("_handleEntryExamStatus", returned, result) 1867 1867 if returned and not self._getEntryExamStatusCancelled: 1868 1868 self._entryExamLink = result.entryExamLink … … 2991 2991 2992 2992 plan = self._getPlan() 2993 print "plan:", plan2993 print("plan:", plan) 2994 2994 2995 2995 takeoffRunway = self._takeoffRunway.get_text() … … 3027 3027 are returned. Otherwise a dialog box is displayed informing the user of 3028 3028 invalid credentials and requesting another set of them.""" 3029 print "_getCredentials", count3029 print("_getCredentials", count) 3030 3030 if count==0: 3031 3031 return (self._userName.get_text(), self._password.get_text()) … … 3061 3061 def _simBriefProgress(self, progress, result, flightInfo): 3062 3062 """The real SimBrief progress handler.""" 3063 print "_simBriefProgress", progress, result, flightInfo3063 print("_simBriefProgress", progress, result, flightInfo) 3064 3064 if result==cef.SIMBRIEF_RESULT_NONE: 3065 3065 message = SimBriefSetupPage.progress2Message.get(progress, … … 3758 3758 def _metarChanged(self, buffer): 3759 3759 """Called when the METAR has changed.""" 3760 print "BriefingPage.metarChanged", self._updatingMETAR3760 print("BriefingPage.metarChanged", self._updatingMETAR) 3761 3761 if not self._updatingMETAR: 3762 3762 self.metarEdited = True … … 3770 3770 3771 3771 It uppercases all characters.""" 3772 print "BriefingPage.metarInserted", self._updatingMETAR3772 print("BriefingPage.metarInserted", self._updatingMETAR) 3773 3773 if not self._updatingMETAR: 3774 3774 self._updatingMETAR = True … … 4025 4025 def activate(self): 4026 4026 """Activate the page.""" 4027 print "TakeoffPage.activate"4027 print("TakeoffPage.activate") 4028 4028 4029 4029 self._updatingMETAR = True … … 4069 4069 def allowForward(self): 4070 4070 """Allow going to the next page.""" 4071 print "TakeoffPage.allowForward"4071 print("TakeoffPage.allowForward") 4072 4072 self._forwardAllowed = True 4073 4073 self._updateForwardButton() … … 4075 4075 def reset(self): 4076 4076 """Reset the page if the wizard is reset.""" 4077 print "TakeoffPage.reset"4077 print("TakeoffPage.reset") 4078 4078 4079 4079 super(TakeoffPage, self).reset() … … 4095 4095 pages.""" 4096 4096 if self._active: 4097 print "TakeoffPage.changeMETAR"4097 print("TakeoffPage.changeMETAR") 4098 4098 self._updatingMETAR = True 4099 4099 self._metar.get_buffer().set_text(metar, -1) … … 4116 4116 self.derate is not None) 4117 4117 4118 print "TakeoffPage._updateForwardButton: forwardAllowed:", self._forwardAllowed, ", sensitive:", sensitive4118 print("TakeoffPage._updateForwardButton: forwardAllowed:", self._forwardAllowed, ", sensitive:", sensitive) 4119 4119 if self._forwardAllowed: 4120 print " METAR: ", self._metar.get_text()4121 print " runway: ", self._runway.get_text()4122 print " SID:", self.sid4123 print " V1:", self.v14124 print " VR:", self.vr4125 print " V2:", self.v24126 print " derateType:", self._derateType4127 print " derate:", self.derate4120 print(" METAR: ", self._metar.get_text()) 4121 print(" runway: ", self._runway.get_text()) 4122 print(" SID:", self.sid) 4123 print(" V1:", self.v1) 4124 print(" VR:", self.vr) 4125 print(" V2:", self.v2) 4126 print(" derateType:", self._derateType) 4127 print(" derate:", self.derate) 4128 4128 4129 4129 self._button.set_sensitive(sensitive) … … 4131 4131 def _valueChanged(self, widget, arg = None): 4132 4132 """Called when the value of some widget has changed.""" 4133 print "TakeoffPage._valueChanged"4133 print("TakeoffPage._valueChanged") 4134 4134 4135 4135 self._updateForwardButton() … … 4138 4138 """Called when the value of some entry widget has changed and the value 4139 4139 should be converted to uppercase.""" 4140 print "TakeoffPage._upperChanged"4140 print("TakeoffPage._upperChanged") 4141 4141 entry.set_text(entry.get_text().upper()) 4142 4142 self._valueChanged(entry, arg) … … 4151 4151 def _derateChanged(self, entry): 4152 4152 """Called when the value of the derate is changed.""" 4153 print "TakeoffPage._derateChanged"4153 print("TakeoffPage._derateChanged") 4154 4154 self._updateForwardButton() 4155 4155 … … 4262 4262 def _metarChanged(self, entry): 4263 4263 """Called when the METAR has changed.""" 4264 print "TakeoffPage.metarChanged", self._updatingMETAR4264 print("TakeoffPage.metarChanged", self._updatingMETAR) 4265 4265 if not self._updatingMETAR: 4266 4266 self._updateForwardButton() … … 4271 4271 4272 4272 It uppercases all characters.""" 4273 print "TakeoffPage.metarInserted", self._updatingMETAR4273 print("TakeoffPage.metarInserted", self._updatingMETAR) 4274 4274 if not self._updatingMETAR: 4275 4275 self._updatingMETAR = True … … 4628 4628 pages.""" 4629 4629 if self._active: 4630 print "LandingPage.changeMETAR"4630 print("LandingPage.changeMETAR") 4631 4631 self._updatingMETAR = True 4632 4632 self._metar.get_buffer().set_text(metar, -1) … … 4689 4689 def _metarChanged(self, entry): 4690 4690 """Called when the METAR has changed.""" 4691 print "LandingPage.metarChanged", self._updatingMETAR4691 print("LandingPage.metarChanged", self._updatingMETAR) 4692 4692 if not self._updatingMETAR: 4693 4693 self._updateForwardButton() … … 4698 4698 4699 4699 It uppercases all characters.""" 4700 print "LandingPage.metarInserted", self._updatingMETAR4700 print("LandingPage.metarInserted", self._updatingMETAR) 4701 4701 if not self._updatingMETAR: 4702 4702 self._updatingMETAR = True … … 5217 5217 pass 5218 5218 5219 def _formatTime(self, scheduledTime, realTimestamp, (warning, error)):5219 def _formatTime(self, scheduledTime, realTimestamp, xxx_todo_changeme): 5220 5220 """Format the departure or arrival time based on the given data as a 5221 5221 markup for a label.""" 5222 (warning, error) = xxx_todo_changeme 5222 5223 realTime = time.gmtime(realTimestamp) 5223 5224 … … 5752 5753 elif stage==const.STAGE_LANDING: 5753 5754 if not self._arrivalBriefingPage.metarEdited: 5754 print "Downloading arrival METAR again"5755 print("Downloading arrival METAR again") 5755 5756 self.gui.webHandler.getMETARs(self._arrivalMETARCallback, 5756 5757 [self._bookedFlight.arrivalICAO]) -
src/mlx/gui/flightlist.py
r868 r919 61 61 62 62 if self._extraColumnAttributes is not None: 63 for (key, value) in self._extraColumnAttributes.ite ritems():63 for (key, value) in self._extraColumnAttributes.items(): 64 64 if key=="alignment": 65 65 self._renderer.set_alignment(value, 0.5) … … 401 401 gui.endBusy() 402 402 403 print "PendingFlightsFrame._handleReflyResult", returned, result403 print("PendingFlightsFrame._handleReflyResult", returned, result) 404 404 405 405 if returned: … … 444 444 gui.endBusy() 445 445 446 print "PendingFlightsFrame._handleDeleteResult", returned, result446 print("PendingFlightsFrame._handleDeleteResult", returned, result) 447 447 448 448 if returned: -
src/mlx/gui/gates.py
r619 r919 143 143 self._fleetStore.clear() 144 144 if fleet is None: 145 for (gateNumber, label) in self._gateLabels.ite ritems():145 for (gateNumber, label) in self._gateLabels.items(): 146 146 label.set_markup("<b>" + gateNumber + "</b>") 147 147 else: -
src/mlx/gui/gui.py
r869 r919 1 1 # -*- coding: utf-8 -*- 2 2 3 from statusicon import StatusIcon4 from statusbar import Statusbar5 from info import FlightInfo6 from update import Updater3 from .statusicon import StatusIcon 4 from .statusbar import Statusbar 5 from .info import FlightInfo 6 from .update import Updater 7 7 from mlx.gui.common import * 8 8 from mlx.gui.flight import Wizard … … 18 18 from mlx.gui.acars import ACARS 19 19 from mlx.gui.timetable import TimetableWindow 20 import cef20 from . import cef 21 21 22 22 import mlx.const as const … … 51 51 class GUI(fs.ConnectionListener): 52 52 """The main GUI class.""" 53 _authors = [ ( u"Váradi", u"István", "prog_test"),54 ( u"Galyassy", u"Tamás", "negotiation"),55 ( u"Kurják", u"Ákos", "test"),56 ( u"Nagy", u"Dániel", "test"),57 ( u"Radó", u"Iván", "test"),58 ( u"Petrovszki", u"Gábor", "test"),59 ( u"Serfőző", u"Tamás", "test"),60 ( u"Szebenyi", u"Bálint", "test"),61 ( u"Zsebényi-Loksa", u"Gergely", "test") ]53 _authors = [ ("Váradi", "István", "prog_test"), 54 ("Galyassy", "Tamás", "negotiation"), 55 ("Kurják", "Ákos", "test"), 56 ("Nagy", "Dániel", "test"), 57 ("Radó", "Iván", "test"), 58 ("Petrovszki", "Gábor", "test"), 59 ("Serfőző", "Tamás", "test"), 60 ("Szebenyi", "Bálint", "test"), 61 ("Zsebényi-Loksa", "Gergely", "test") ] 62 62 63 63 def __init__(self, programDirectory, config): … … 1462 1462 secondaryMarkup = xstr("sendPIREP_unknown_sec") 1463 1463 else: 1464 print "PIREP sending failed", result1464 print("PIREP sending failed", result) 1465 1465 messageFormat = xstr("sendPIREP_failed") 1466 1466 secondaryMarkup = xstr("sendPIREP_failed_sec") … … 1686 1686 secondaryMarkup = xstr("sendPIREP_unknown_sec") 1687 1687 else: 1688 print "PIREP sending failed", result1688 print("PIREP sending failed", result) 1689 1689 messageFormat = xstr("sendPIREP_failed") 1690 1690 secondaryMarkup = xstr("sendPIREP_failed_sec") … … 1711 1711 1712 1712 for (timestampString, text) in self._logger.lines: 1713 description += unicode(formatFlightLogLine(timestampString, text))1713 description += str(formatFlightLogLine(timestampString, text)) 1714 1714 1715 1715 description += "\n\n" + ("=" * 40) … … 1798 1798 for index in hotkeys: 1799 1799 if index==self._pilotHotkeyIndex: 1800 print "gui.GUI._handleHotkeys: pilot hotkey pressed"1800 print("gui.GUI._handleHotkeys: pilot hotkey pressed") 1801 1801 self._flight.pilotHotkeyPressed() 1802 1802 elif index==self._checklistHotkeyIndex: 1803 print "gui.GUI._handleHotkeys: checklist hotkey pressed"1803 print("gui.GUI._handleHotkeys: checklist hotkey pressed") 1804 1804 self._flight.checklistHotkeyPressed() 1805 1805 else: 1806 print "gui.GUI._handleHotkeys: unhandled hotkey index:", index1806 print("gui.GUI._handleHotkeys: unhandled hotkey index:", index) 1807 1807 1808 1808 def _showManual(self, menuitem): -
src/mlx/gui/info.py
r846 r919 1 1 2 from common import *2 from .common import * 3 3 4 4 from mlx.gui.delaycodes import DelayCodeTable -
src/mlx/gui/pirep.py
r855 r919 1 1 2 from common import *3 from dcdata import getTable4 from info import FlightInfo5 from flight import comboModel2 from .common import * 3 from .dcdata import getTable 4 from .info import FlightInfo 5 from .flight import comboModel 6 6 7 7 from mlx.pirep import PIREP -
src/mlx/gui/prefs.py
r738 r919 1 1 2 from common import *2 from .common import * 3 3 4 4 from mlx.i18n import xstr … … 6 6 import mlx.config as config 7 7 8 import url parse8 import urllib.parse 9 9 10 10 #------------------------------------------------------------------------------ … … 63 63 64 64 self._hotkeyModel = gtk.ListStore(str) 65 for keyCode in range(ord("0"), ord("9")+1) + range(ord("A"), ord("Z")+1):65 for keyCode in list(range(ord("0"), ord("9")+1)) + list(range(ord("A"), ord("Z")+1)): 66 66 self._hotkeyModel.append([chr(keyCode)]) 67 67 … … 829 829 sensitive = False 830 830 try: 831 result = url parse.urlparse(self._updateURL.get_text())831 result = urllib.parse.urlparse(self._updateURL.get_text()) 832 832 sensitive = result.scheme!="" and (result.netloc + result.path)!="" 833 833 except: -
src/mlx/gui/statusbar.py
r679 r919 1 1 2 from common import *2 from .common import * 3 3 4 4 import mlx.const as const -
src/mlx/gui/statusicon.py
r544 r919 1 1 2 from common import *2 from .common import * 3 3 4 4 import mlx.const as const … … 154 154 def _updateFlightStatus(self): 155 155 """Update the flight status.""" 156 stage = u"-" if self._stage is None \156 stage = "-" if self._stage is None \ 157 157 else xstr("flight_stage_" + const.stage2string(self._stage)) 158 158 … … 172 172 if self._noGoReason is not None: 173 173 rating = '<span foreground="red">' + rating + '</span>' 174 markup = u"MAVA Logger X %s\n\n%s: %s\n%s: %s" %\174 markup = "MAVA Logger X %s\n\n%s: %s\n%s: %s" %\ 175 175 (const.VERSION, xstr("statusicon_stage"), stage, 176 176 xstr("statusicon_rating"), rating) -
src/mlx/gui/timetable.py
r879 r919 4 4 5 5 from mlx.gui.common import * 6 from flightlist import ColumnDescriptor6 from .flightlist import ColumnDescriptor 7 7 from mlx.rpc import ScheduledFlight 8 8 … … 249 249 self._tooltips.set_tip(widget, "") 250 250 self._tooltips.disable() 251 except Exception ,e:252 print e251 except Exception as e: 252 print(e) 253 253 self._tooltips.set_tip(widget, "") 254 254 self._tooltips.disable() … … 656 656 typeFamilies.add(const.aircraftType2Family(aircraftType)) 657 657 658 for (typeFamily, checkButton) in self._typeFamilyButtons.ite ritems():658 for (typeFamily, checkButton) in self._typeFamilyButtons.items(): 659 659 checkButton.set_sensitive(typeFamily in typeFamilies) 660 660 … … 712 712 """Update the timetable list.""" 713 713 aircraftTypes = [] 714 for (aircraftFamily, button) in self._typeFamilyButtons.ite ritems():714 for (aircraftFamily, button) in self._typeFamilyButtons.items(): 715 715 if button.get_active(): 716 716 aircraftTypes += const.aircraftFamily2Types[aircraftFamily] -
src/mlx/i18n.py
r298 r919 24 24 def setLanguage(programDirectory, language): 25 25 """Setup the internationalization support for the given language.""" 26 print "i18n.setLanguage", language26 print("i18n.setLanguage", language) 27 27 translation = _getTranslation(programDirectory, language) 28 28 fallback = _getFallbackFor(programDirectory, language) -
src/mlx/logger.py
r634 r919 1 1 2 from fs import sendMessage3 import const4 import util2 from .fs import sendMessage 3 from . import const 4 from . import util 5 5 6 6 import sys … … 235 235 def debug(self, msg): 236 236 """Log a debug message.""" 237 print "[DEBUG]", msg237 print("[DEBUG]", msg) 238 238 239 239 def stage(self, timestamp, stage): … … 326 326 """Get the rating of the flight so far.""" 327 327 totalScore = 100 328 for fault in self._faults. itervalues():328 for fault in self._faults.values(): 329 329 score = fault.score 330 330 if score==Logger.NO_GO_SCORE: -
src/mlx/mlx.py
r800 r919 1 1 2 from config import Config3 from i18n import setLanguage4 from sound import preInitializeSound, initializeSound, finalizeSound5 from util import secondaryInstallation6 from const import VERSION7 from watchdog import Watchdog2 from .config import Config 3 from .i18n import setLanguage 4 from .sound import preInitializeSound, initializeSound, finalizeSound 5 from .util import secondaryInstallation 6 from .const import VERSION 7 from .watchdog import Watchdog 8 8 9 9 import os … … 60 60 def main(): 61 61 """The main operation of the program.""" 62 from singleton import SingleInstance, raiseCallbackWrapper62 from .singleton import SingleInstance, raiseCallbackWrapper 63 63 64 64 global instance … … 86 86 sys.stderr = StdIOHandler(gui) 87 87 88 print "MAVA Logger X " + VERSION + " debug log"89 print "The initial configuration:"88 print("MAVA Logger X " + VERSION + " debug log") 89 print("The initial configuration:") 90 90 config.log() 91 91 -
src/mlx/pirep.py
r856 r919 1 1 2 from util import utf2unicode3 from flight import Flight4 5 import const6 import cPickle as pickle2 from .util import utf2unicode 3 from .flight import Flight 4 5 from . import const 6 import pickle as pickle 7 7 import calendar 8 8 import datetime … … 65 65 def decodeFlightTypeText(s): 66 66 """Decode the given flight type text.""" 67 for (flighType, text) in PIREP._flightTypes.ite ritems():67 for (flighType, text) in PIREP._flightTypes.items(): 68 68 if s==text: 69 69 return flighType … … 124 124 pirep.mailWeight = pirep.bookedFlight.mailWeight 125 125 return pirep 126 except Exception ,e:127 print 128 utf2unicode(str(e))) 126 except Exception as e: 127 print("Failed loading PIREP from %s: %s" % (path, 128 utf2unicode(str(e)))) 129 129 return None 130 130 … … 367 367 pickle.dump(self, f) 368 368 return None 369 except Exception ,e:369 except Exception as e: 370 370 error = utf2unicode(str(e)) 371 print u"Failed saving PIREP to %s: %s" % (path, error)371 print("Failed saving PIREP to %s: %s" % (path, error)) 372 372 return error 373 373 -
src/mlx/pyuipc_emu.py
r298 r919 217 217 results.append(int(vs / 60.0 * 0.3048 * 256)) 218 218 elif offset==0x0560: # Latitude 219 results.append( long(latitude*10001750.0*65536.0*65536.0/90.0))219 results.append(int(latitude*10001750.0*65536.0*65536.0/90.0)) 220 220 elif offset==0x0568: # Longitude 221 results.append( long(longitude*65536.9*65536.0*65536.0*65536.0/360.0))221 results.append(int(longitude*65536.9*65536.0*65536.0*65536.0/360.0)) 222 222 elif offset==0x0570: # Aircraft altitude in metres (fractional part) 223 results.append( long( (altitude*0.3048*65536*65536)%(65536*65536)))223 results.append(int( (altitude*0.3048*65536*65536)%(65536*65536))) 224 224 elif offset==0x0574: # Aircraft altitude in metres (whole part) 225 225 results.append(int(altitude*.3048)) … … 237 237 centre_fuel = fuel_remaining - 2*side_tank_capacity 238 238 if centre_fuel<0: centre_fuel = 0.0 239 results.append( long(round(centre_fuel/centre_tank_capacity*128.0*65536.0)))239 results.append(int(round(centre_fuel/centre_tank_capacity*128.0*65536.0))) 240 240 elif offset==0x0b78: # Centre tank capacity (gallons) 241 results.append( long(round(centre_tank_capacity*KGTOLBS/fuel_weight)))241 results.append(int(round(centre_tank_capacity*KGTOLBS/fuel_weight))) 242 242 elif offset==0x0b7c or \ 243 243 offset==0x0b94: # Left and right main tank level (%*128*65536) 244 244 fuel = fuel_remaining/2 245 245 if fuel>side_tank_capacity: fuel = side_tank_capacity 246 results.append( long(round(fuel/side_tank_capacity*128.0*65536.0)))246 results.append(int(round(fuel/side_tank_capacity*128.0*65536.0))) 247 247 elif offset==0x0b80 or \ 248 248 offset==0x0b98: # Left and right main tank capacity (gallons) 249 results.append( long(round(side_tank_capacity*KGTOLBS/fuel_weight)))249 results.append(int(round(side_tank_capacity*KGTOLBS/fuel_weight))) 250 250 elif offset in [0x0b84, 0x0b88, 0x0b8c, 0x0b90, 251 251 0x0b9c, 0x0ba0, 0x0ba4, 0x0ba8, … … 253 253 0x1254, 0x1258, 0x125c, 0x1260]: 254 254 # Other tank capacities and levels 255 results.append( long(0))255 results.append(int(0)) 256 256 elif offset==0x023a: # Second of time 257 257 results.append(int(tm[5])) -
src/mlx/pyuipc_sim.py
r877 r919 1 1 2 import const2 from . import const 3 3 4 4 import cmd … … 9 9 import sys 10 10 import struct 11 import cPickle11 import pickle 12 12 import math 13 13 … … 342 342 try: 343 343 return self._read(offset, type) 344 except Exception ,e:345 print "failed to read offset %04x: %s" % (offset, str(e))344 except Exception as e: 345 print("failed to read offset %04x: %s" % (offset, str(e))) 346 346 raise FSUIPCException(ERR_DATA) 347 347 … … 414 414 return 1 if self.overspeed else 0 415 415 elif offset==0x0560: # Latitude 416 return long(self.latitude * 10001750.0 * 65536.0 * 65536.0 / 90.0)416 return int(self.latitude * 10001750.0 * 65536.0 * 65536.0 / 90.0) 417 417 elif offset==0x0568: # Longitude 418 return long(self.longitude * 65536.0 * 65536.0 * 65536.0 * 65536.0 / 360.0)418 return int(self.longitude * 65536.0 * 65536.0 * 65536.0 * 65536.0 / 360.0) 419 419 elif offset==0x0570: # Altitude 420 return long(self.altitude * const.FEETTOMETRES * 65536.0 * 65536.0)420 return int(self.altitude * const.FEETTOMETRES * 65536.0 * 65536.0) 421 421 elif offset==0x0578: # Pitch 422 422 return int(self.pitch * 65536.0 * 65536.0 / 360.0) … … 584 584 return value 585 585 else: 586 print "Unhandled offset: %04x" % (offset,)586 print("Unhandled offset: %04x" % (offset,)) 587 587 raise FSUIPCException(ERR_DATA) 588 588 else: 589 print "Unhandled offset: %04x" % (offset,)589 print("Unhandled offset: %04x" % (offset,)) 590 590 raise FSUIPCException(ERR_DATA) 591 591 elif offset==0x32fa: # Message duration … … 616 616 return 0 if self.xpdrC else 1 617 617 else: 618 print "Unhandled offset: %04x" % (offset,)618 print("Unhandled offset: %04x" % (offset,)) 619 619 raise FSUIPCException(ERR_DATA) 620 620 … … 623 623 try: 624 624 return self._write(offset, value, type) 625 except TypeError ,e:625 except TypeError as e: 626 626 raise e 627 except Exception ,e:628 print "failed to write offset %04x: %s" % (offset, str(e))627 except Exception as e: 628 print("failed to write offset %04x: %s" % (offset, str(e))) 629 629 raise FSUIPCException(ERR_DATA) 630 630 … … 852 852 hotkey[3] = (value>>24) & 0xff 853 853 else: 854 print "Unhandled offset: %04x for type '%s'" % (offset, type)854 print("Unhandled offset: %04x for type '%s'" % (offset, type)) 855 855 raise FSUIPCException(ERR_DATA) 856 856 else: 857 print "Unhandled offset: %04x for type '%s'" % (offset, type)857 print("Unhandled offset: %04x for type '%s'" % (offset, type)) 858 858 raise FSUIPCException(ERR_DATA) 859 859 elif offset==0x32fa: # Message duration … … 882 882 self.xpdrC = value==0 883 883 else: 884 print "Unhandled offset: %04x" % (offset,)884 print("Unhandled offset: %04x" % (offset,)) 885 885 raise FSUIPCException(ERR_DATA) 886 886 … … 1039 1039 (length,) = struct.unpack("I", clientSocket.recv(4)) 1040 1040 data = clientSocket.recv(length) 1041 (call, args) = cPickle.loads(data)1041 (call, args) = pickle.loads(data) 1042 1042 exception = None 1043 1043 … … 1061 1061 else: 1062 1062 break 1063 except Exception ,e:1063 except Exception as e: 1064 1064 exception = e 1065 1065 1066 1066 if exception is None: 1067 data = cPickle.dumps((RESULT_RETURNED, result))1067 data = pickle.dumps((RESULT_RETURNED, result)) 1068 1068 else: 1069 data = cPickle.dumps((RESULT_EXCEPTION, str(exception)))1069 data = pickle.dumps((RESULT_EXCEPTION, str(exception))) 1070 1070 clientSocket.send(struct.pack("I", len(data)) + data) 1071 except Exception ,e:1072 print >> sys.stderr, "pyuipc_sim.Server._process: failed with exception:", str(e)1071 except Exception as e: 1072 print("pyuipc_sim.Server._process: failed with exception:", str(e), file=sys.stderr) 1073 1073 finally: 1074 1074 try: … … 1112 1112 def quit(self): 1113 1113 """Quit from the simulator.""" 1114 data = cPickle.dumps((CALL_QUIT, None))1114 data = pickle.dumps((CALL_QUIT, None)) 1115 1115 self._socket.send(struct.pack("I", len(data)) + data) 1116 1116 1117 1117 def _call(self, command, data): 1118 1118 """Perform a call with the given command and data.""" 1119 data = cPickle.dumps((command, [data]))1119 data = pickle.dumps((command, [data])) 1120 1120 self._socket.send(struct.pack("I", len(data)) + data) 1121 1121 (length,) = struct.unpack("I", self._socket.recv(4)) 1122 1122 data = self._socket.recv(length) 1123 (resultCode, result) = cPickle.loads(data)1123 (resultCode, result) = pickle.loads(data) 1124 1124 if resultCode==RESULT_RETURNED: 1125 1125 return result … … 1234 1234 lambda value: value * 90.0 / 1235 1235 10001750.0 / 65536.0 / 65536.0, 1236 lambda word: long(float(word) *1236 lambda word: int(float(word) * 1237 1237 10001750.0 * 1238 1238 65536.0 * 65536.0 / 90.0)) … … 1240 1240 lambda value: value * 360.0 / 1241 1241 65536.0 / 65536.0 / 65536.0 / 65536.0, 1242 lambda word: long(float(word) *1242 lambda word: int(float(word) * 1243 1243 65536.0 * 65536.0 * 1244 1244 65536.0 * 65536.0 / … … 1300 1300 const.FEETTOMETRES / 65536.0 / 1301 1301 65536.0, 1302 lambda word: long(float(word) *1302 lambda word: int(float(word) * 1303 1303 const.FEETTOMETRES * 1304 1304 65536.0 * 65536.0)) … … 1487 1487 self._valueHandlers["hotkey%d" % (i,)] = ([(0x3210 + i*4, "u")], 1488 1488 lambda value: "0x%08x" % (value,), 1489 lambda word: long(word, 16))1489 lambda word: int(word, 16)) 1490 1490 1491 1491 self._valueHandlers["cog"] = ([(0x2ef8, "f")], lambda value: value, … … 1537 1537 """Handle unhandle commands.""" 1538 1538 if line=="EOF": 1539 print 1539 print() 1540 1540 return self.do_quit("") 1541 1541 else: … … 1548 1548 for name in names: 1549 1549 if name not in self._valueHandlers: 1550 print >> sys.stderr, "Unknown variable: " + name1550 print("Unknown variable: " + name, file=sys.stderr) 1551 1551 return False 1552 1552 valueHandler = self._valueHandlers[name] … … 1565 1565 else thisResults) 1566 1566 1567 print name + "=" + str(value)1567 print(name + "=" + str(value)) 1568 1568 1569 1569 index += numResults 1570 1570 i+=1 1571 except Exception ,e:1572 print >> sys.stderr, "Failed to read data: " + str(e)1571 except Exception as e: 1572 print("Failed to read data: " + str(e), file=sys.stderr) 1573 1573 1574 1574 return False … … 1576 1576 def help_get(self): 1577 1577 """Print help for the get command.""" 1578 print "get <variable> [<variable>...]"1578 print("get <variable> [<variable>...]") 1579 1579 1580 1580 def complete_get(self, text, line, begidx, endidx): … … 1608 1608 words = argument.split("=") 1609 1609 if len(words)!=2: 1610 print >> sys.stderr, "Invalid argument: " + argument1610 print("Invalid argument: " + argument, file=sys.stderr) 1611 1611 return False 1612 1612 1613 1613 (name, value) = words 1614 1614 if name not in self._valueHandlers: 1615 print >> sys.stderr, "Unknown variable: " + name1615 print("Unknown variable: " + name, file=sys.stderr) 1616 1616 return False 1617 1617 … … 1625 1625 data.append((offset, type, values[index])) 1626 1626 index += 1 1627 except Exception ,e:1628 print >> sys.stderr,"Invalid value '%s' for variable %s: %s" % \1629 (value, name, str(e)) 1627 except Exception as e: 1628 print("Invalid value '%s' for variable %s: %s" % \ 1629 (value, name, str(e)), file=sys.stderr) 1630 1630 return False 1631 1631 1632 1632 try: 1633 1633 self._client.write(data) 1634 print "Data written"1635 except Exception ,e:1636 print >> sys.stderr, "Failed to write data: " + str(e)1634 print("Data written") 1635 except Exception as e: 1636 print("Failed to write data: " + str(e), file=sys.stderr) 1637 1637 1638 1638 return False … … 1640 1640 def help_set(self): 1641 1641 """Print help for the set command.""" 1642 print "set <variable>=<value> [<variable>=<value>...]"1642 print("set <variable>=<value> [<variable>=<value>...]") 1643 1643 1644 1644 def complete_set(self, text, line, begidx, endidx): … … 1654 1654 value = int(args) 1655 1655 self._client.setVersion(value) 1656 print "Emulating version %d" % (value,)1657 except Exception ,e:1658 print >> sys.stderr, "Failed to set the version: " + str(e)1656 print("Emulating version %d" % (value,)) 1657 except Exception as e: 1658 print("Failed to set the version: " + str(e), file=sys.stderr) 1659 1659 1660 1660 def help_setversion(self, usage = False): 1661 1661 """Help for the setversion command""" 1662 if usage: print "Usage:",1663 print "setversion <number>"1662 if usage: print("Usage:", end=' ') 1663 print("setversion <number>") 1664 1664 1665 1665 def do_close(self, args): … … 1667 1667 try: 1668 1668 self._client.close() 1669 print "Connection closed"1670 except Exception ,e:1671 print >> sys.stderr, "Failed to close the connection: " + str(e)1669 print("Connection closed") 1670 except Exception as e: 1671 print("Failed to close the connection: " + str(e), file=sys.stderr) 1672 1672 1673 1673 def do_failopen(self, args): … … 1676 1676 value = self.str2bool(args) 1677 1677 self._client.failOpen(value) 1678 print "Opening will%s fail" % ("" if value else " not",)1679 except Exception ,e:1680 print >> sys.stderr, "Failed to set open failure: " + str(e)1678 print("Opening will%s fail" % ("" if value else " not",)) 1679 except Exception as e: 1680 print("Failed to set open failure: " + str(e), file=sys.stderr) 1681 1681 1682 1682 def help_failopen(self, usage = False): 1683 1683 """Help for the failopen command""" 1684 if usage: print "Usage:",1685 print "failopen yes|no"1684 if usage: print("Usage:", end=' ') 1685 print("failopen yes|no") 1686 1686 1687 1687 def complete_failopen(self, text, line, begidx, endidx): -
src/mlx/rpc.py
r889 r919 1 import const2 import rpccommon3 4 from common import MAVA_BASE_URL1 from . import const 2 from . import rpccommon 3 4 from .common import MAVA_BASE_URL 5 5 6 6 import jsonrpclib … … 28 28 For all other names, the value will be stored as the same-named 29 29 attribute.""" 30 for (key, value) in value.ite ritems():30 for (key, value) in value.items(): 31 31 if key in instructions: 32 32 instruction = instructions[key] … … 37 37 value = instruction(value) 38 38 except: 39 print >> sys.stderr,"Failed to convert value '%s' of attribute '%s':" % \40 (value, key) 39 print("Failed to convert value '%s' of attribute '%s':" % \ 40 (value, key), file=sys.stderr) 41 41 import traceback 42 42 traceback.print_exc() … … 297 297 def writeIntoFile(self, f): 298 298 """Write the flight into a file.""" 299 print >> f, "callsign=%s" % (self.callsign,)299 print("callsign=%s" % (self.callsign,), file=f) 300 300 date = self.departureTime.date() 301 print >> f, "date=%04d-%02d-%0d" % (date.year, date.month, date.day)302 print >> f, "dep_airport=%s" % (self.departureICAO,)303 print >> f, "dest_airport=%s" % (self.arrivalICAO,)304 print >> f,"planecode=%s" % \305 (BookedFlight.TYPE2TYPECODE[self.aircraftType],) 306 print >> f, "planetype=%s" % (self.aircraftTypeName,)307 print >> f, "tail_nr=%s" % (self.tailNumber,)308 print >> f, "passenger=%d" % (self.numPassengers,)309 print >> f, "crew=%d" % (self.numCrew,)310 print >> f, "bag=%d" % (self.bagWeight,)311 print >> f, "cargo=%d" % (self.cargoWeight,)312 print >> f, "mail=%d" % (self.mailWeight,)313 print >> f, "flight_route=%s" % (self.route,)301 print("date=%04d-%02d-%0d" % (date.year, date.month, date.day), file=f) 302 print("dep_airport=%s" % (self.departureICAO,), file=f) 303 print("dest_airport=%s" % (self.arrivalICAO,), file=f) 304 print("planecode=%s" % \ 305 (BookedFlight.TYPE2TYPECODE[self.aircraftType],), file=f) 306 print("planetype=%s" % (self.aircraftTypeName,), file=f) 307 print("tail_nr=%s" % (self.tailNumber,), file=f) 308 print("passenger=%d" % (self.numPassengers,), file=f) 309 print("crew=%d" % (self.numCrew,), file=f) 310 print("bag=%d" % (self.bagWeight,), file=f) 311 print("cargo=%d" % (self.cargoWeight,), file=f) 312 print("mail=%d" % (self.mailWeight,), file=f) 313 print("flight_route=%s" % (self.route,), file=f) 314 314 departureTime = self.departureTime 315 print >> f,"departure_time=%02d\\:%02d\\:%02d" % \316 (departureTime.hour, departureTime.minute, departureTime.second) 315 print("departure_time=%02d\\:%02d\\:%02d" % \ 316 (departureTime.hour, departureTime.minute, departureTime.second), file=f) 317 317 arrivalTime = self.arrivalTime 318 print >> f,"arrival_time=%02d\\:%02d\\:%02d" % \319 (arrivalTime.hour, arrivalTime.minute, arrivalTime.second) 320 print >> f, "foglalas_id=%s" % ("0" if self.id is None else self.id,)318 print("arrival_time=%02d\\:%02d\\:%02d" % \ 319 (arrivalTime.hour, arrivalTime.minute, arrivalTime.second), file=f) 320 print("foglalas_id=%s" % ("0" if self.id is None else self.id,), file=f) 321 321 322 322 #--------------------------------------------------------------------------------------- -
src/mlx/rpccommon.py
r742 r919 3 3 #------------------------------------------------------------------------------ 4 4 5 import const5 from . import const 6 6 7 7 #------------------------------------------------------------------------------ … … 51 51 """Check if the gate of the given plane conflicts with another plane's 52 52 position.""" 53 for p in self._planes. itervalues():53 for p in self._planes.values(): 54 54 if p.tailNumber!=plane.tailNumber and \ 55 55 p.status==const.PLANE_HOME and \ … … 62 62 """Get a set containing the numbers of the gates occupied by planes.""" 63 63 gateNumbers = set() 64 for p in self._planes. itervalues():64 for p in self._planes.values(): 65 65 if p.status==const.PLANE_HOME and p.gateNumber: 66 66 gateNumbers.add(p.gateNumber) … … 80 80 def __iter__(self): 81 81 """Get an iterator over the planes.""" 82 for plane in self._planes. itervalues():82 for plane in self._planes.values(): 83 83 yield plane 84 84 -
src/mlx/singleton.py
r401 r919 1 1 2 from util import utf2unicode2 from .util import utf2unicode 3 3 4 4 import os … … 59 59 break 60 60 61 print "singleton._PipeServer.run: created the pipe"61 print("singleton._PipeServer.run: created the pipe") 62 62 try: 63 63 if win32pipe.ConnectNamedPipe(handle)==0: 64 print "singleton._PipeServer.run: client connection received"64 print("singleton._PipeServer.run: client connection received") 65 65 (code, message) = \ 66 66 win32file.ReadFile(handle, … … 69 69 70 70 if code==0: 71 print "singleton._PipeServer.run: message received from client"71 print("singleton._PipeServer.run: message received from client") 72 72 self._raiseCallback() 73 73 else: 74 print "singleton._PipeServer.run: failed to read from the pipe"75 except Exception ,e:76 print "singleton._PipeServer.run: exception:",77 print utf2unicode(str(e))74 print("singleton._PipeServer.run: failed to read from the pipe") 75 except Exception as e: 76 print("singleton._PipeServer.run: exception:", end=' ') 77 print(utf2unicode(str(e))) 78 78 finally: 79 79 win32pipe.DisconnectNamedPipe(handle) 80 80 win32file.CloseHandle(handle) 81 except Exception ,e:82 print "singleton._PipeServer.run: fatal exception:",83 print utf2unicode(str(e))81 except Exception as e: 82 print("singleton._PipeServer.run: fatal exception:", end=' ') 83 print(utf2unicode(str(e))) 84 84 85 85 def _createPipe(self): … … 96 96 None) 97 97 if handle==win32file.INVALID_HANDLE_VALUE: 98 print "singleton._PipeServer.run: could not create the handle"98 print("singleton._PipeServer.run: could not create the handle") 99 99 return None 100 100 else: … … 144 144 f.close() 145 145 return 146 except Exception ,e:147 print "SingleInstance._notifySingleton: failed:",148 print utf2unicode(str(e))146 except Exception as e: 147 print("SingleInstance._notifySingleton: failed:", end=' ') 148 print(utf2unicode(str(e))) 149 149 time.sleep(0.5) 150 150 151 def __ nonzero__(self):151 def __bool__(self): 152 152 """Return a boolean representation of the object. 153 153 … … 194 194 s.recv(64) 195 195 self._raiseCallback() 196 except Exception ,e:197 print "singleton._SocketServer.run: fatal exception:",198 print utf2unicode(str(e))196 except Exception as e: 197 print("singleton._SocketServer.run: fatal exception:", end=' ') 198 print(utf2unicode(str(e))) 199 199 200 200 class SingleInstance(object): … … 218 218 fcntl.lockf(self._lockFile, fcntl.LOCK_EX | fcntl.LOCK_NB) 219 219 self._isSingle = True 220 except Exception ,e:220 except Exception as e: 221 221 self._lockFile.close() 222 222 self._lockFile = None … … 259 259 s.close() 260 260 return 261 except Exception ,e:262 print "singleton.SingleInstance._notifySingleton: failed:",263 print utf2unicode(str(e))261 except Exception as e: 262 print("singleton.SingleInstance._notifySingleton: failed:", end=' ') 263 print(utf2unicode(str(e))) 264 264 time.sleep(0.5) 265 265 266 def __ nonzero__(self):266 def __bool__(self): 267 267 """Return a boolean representation of the object. 268 268 … … 299 299 if __name__=="__main__": 300 300 def raiseCallback(): 301 print "Raise the window!"301 print("Raise the window!") 302 302 303 303 instance = SingleInstance("mlx", raiseCallback) 304 304 if instance: 305 print "The first instance"305 print("The first instance") 306 306 time.sleep(10) 307 307 else: 308 print "The program is already running."309 308 print("The program is already running.") 309 -
src/mlx/sound.py
r800 r919 1 1 2 from util import utf2unicode2 from .util import utf2unicode 3 3 4 4 import os … … 113 113 success = True 114 114 try: 115 print "Closing", alias115 print("Closing", alias) 116 116 self._mci.send("close " + alias) 117 print "Closed", alias118 except Exception ,e:119 print "Failed closing " + alias + ":",120 print utf2unicode(str(e))117 print("Closed", alias) 118 except Exception as e: 119 print("Failed closing " + alias + ":", end=' ') 120 print(utf2unicode(str(e))) 121 121 success = False 122 122 … … 130 130 try: 131 131 alias = "mlxsound%d" % (counter,) 132 print "Starting to play", path, "as", alias132 print("Starting to play", path, "as", alias) 133 133 self._mci.send("open \"%s\" alias %s" % \ 134 134 (path, alias)) … … 144 144 self._pending.append((timeout, (alias, finishData))) 145 145 self._pending.sort() 146 print "Started to play", path147 except Exception ,e:148 print "Failed to start playing " + path + ":",149 print utf2unicode(str(e))146 print("Started to play", path) 147 except Exception as e: 148 print("Failed to start playing " + path + ":", end=' ') 149 print(utf2unicode(str(e))) 150 150 (finishCallback, extra) = finishData 151 151 if finishCallback is not None: … … 220 220 221 221 Gst.init(None) 222 except Exception ,e:222 except Exception as e: 223 223 outQueue.put(False) 224 224 outQueue.put(e) … … 351 351 else: 352 352 exception = _inQueue.get() 353 print "The Gst library is missing from your system. It is needed for sound playback on Linux:"354 print exception353 print("The Gst library is missing from your system. It is needed for sound playback on Linux:") 354 print(exception) 355 355 356 356 def startSound(name, finishCallback = None, extra = None): … … 387 387 388 388 def callback(result, extra): 389 print "callback", result, extra389 print("callback", result, extra) 390 390 391 391 preInitializeSound() … … 393 393 soundsPath = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 394 394 "..", "..", "sounds")) 395 print "soundsPath:", soundsPath395 print("soundsPath:", soundsPath) 396 396 initializeSound(soundsPath) 397 397 startSound("notam.mp3", finishCallback = callback, extra= "notam.mp3") -
src/mlx/soundsched.py
r352 r919 1 1 2 from sound import startSound3 import const4 import fs2 from .sound import startSound 3 from . import const 4 from . import fs 5 5 6 6 import threading … … 64 64 """Called when the playback of thee sound has finished (or failed).""" 65 65 if success is None: 66 print "Failed to start sound", self._name66 print("Failed to start sound", self._name) 67 67 elif not success: 68 print "Failed to finish sound", self._name68 print("Failed to finish sound", self._name) 69 69 with Sound._lock: 70 70 self._playing -= 1 -
src/mlx/test.py
r27 r919 1 1 # Test module 2 2 3 import fs4 import flight5 import logger6 import acft7 import const3 from . import fs 4 from . import flight 5 from . import logger 6 from . import acft 7 from . import const 8 8 9 9 import time … … 11 11 12 12 def callback(data, extra): 13 print data13 print(data) 14 14 15 15 def main(): -
src/mlx/update.py
r788 r919 1 1 2 from config import Config3 from util import utf2unicode2 from .config import Config 3 from .util import utf2unicode 4 4 5 5 import os 6 6 import sys 7 import urllib 27 import urllib.request, urllib.error, urllib.parse 8 8 import tempfile 9 9 import socket … … 57 57 58 58 Each file is returned as a 3-tuple with items as in the file.""" 59 for (path, (size, sum)) in self._files.ite ritems():59 for (path, (size, sum)) in self._files.items(): 60 60 yield (path, size, sum) 61 61 … … 99 99 def writeInto(self, file): 100 100 """Write the manifest into the file at the given path.""" 101 for (path, (size, sum)) in self._files.ite ritems():101 for (path, (size, sum)) in self._files.items(): 102 102 file.write("%s\t%d\t%s\n" % (path, size, sum)) 103 103 … … 207 207 with open(manifestPath, "rt") as f: 208 208 manifest.readFrom(f) 209 except Exception ,e:210 print "Error reading the manifest, ignoring:", utf2unicode(str(e))209 except Exception as e: 210 print("Error reading the manifest, ignoring:", utf2unicode(str(e))) 211 211 manifest = Manifest() 212 212 … … 226 226 try: 227 227 updateManifest = Manifest() 228 f= urllib 2.urlopen(updateURL + "/" + manifestName)228 f= urllib.request.urlopen(updateURL + "/" + manifestName) 229 229 updateManifest.readFrom(f) 230 230 231 except Exception ,e:231 except Exception as e: 232 232 error = utf2unicode(str(e)) 233 print >> sys.stderr, "Error downloading manifest:", error233 print("Error downloading manifest:", error, file=sys.stderr) 234 234 listener.failed(error) 235 235 return None … … 298 298 pass 299 299 os.rename(path, targetPath) 300 except Exception ,e:301 print "Cannot remove file " + path + ": " + utf2unicode(str(e))300 except Exception as e: 301 print("Cannot remove file " + path + ": " + utf2unicode(str(e))) 302 302 303 303 #------------------------------------------------------------------------------ … … 359 359 360 360 with open(targetFile, "wb") as fout: 361 fin = urllib 2.urlopen(updateURL + "/" + path)361 fin = urllib.request.urlopen(updateURL + "/" + path) 362 362 while True: 363 363 data = fin.read(4096) … … 391 391 392 392 listener.done() 393 except Exception ,e:393 except Exception as e: 394 394 exc = traceback.format_exc() 395 print >> sys.stderr, utf2unicode(exc)395 print(utf2unicode(exc), file=sys.stderr) 396 396 397 397 error = utf2unicode(str(e)) 398 print >> sys.stderr, "Error:", error398 print("Error:", error, file=sys.stderr) 399 399 400 400 listener.failed(error) … … 409 409 f.close() 410 410 return True 411 except Exception ,e:411 except Exception as e: 412 412 return False 413 413 finally: … … 439 439 listener.downloadedManifest() 440 440 elif command=="setTotalSize": 441 listener.setTotalSize(int(words[1]), long(words[2]),441 listener.setTotalSize(int(words[1]), int(words[2]), 442 442 int(words[3]), int(words[4])) 443 443 elif command=="setDownloaded": 444 listener.setDownloaded( long(words[1]))444 listener.setDownloaded(int(words[1])) 445 445 elif command=="startRenaming": 446 446 listener.startRenaming() … … 457 457 elif command=="failed": 458 458 listener.failed(words[1]) 459 except Exception ,e:460 print >> sys.stderr,"Failed to parse line '%s': %s" % \461 (line, utf2unicode(str(e))) 459 except Exception as e: 460 print("Failed to parse line '%s': %s" % \ 461 (line, utf2unicode(str(e))), file=sys.stderr) 462 462 463 463 return buffer … … 514 514 process.wait() 515 515 516 except Exception ,e:516 except Exception as e: 517 517 error = utf2unicode(str(e)) 518 print >> sys.stderr, "Failed updating:", error518 print("Failed updating:", error, file=sys.stderr) 519 519 listener.failed(error) 520 520 finally: … … 563 563 updateFiles(directory, updateURL, listener, updateManifest, 564 564 modifiedAndNew, removed, localRemoved) 565 except Exception ,e:565 except Exception as e: 566 566 exc = traceback.format_exc() 567 print >> sys.stderr, utf2unicode(exc)567 print(utf2unicode(exc), file=sys.stderr) 568 568 569 569 error = utf2unicode(str(e)) 570 print >> sys.stderr, "Update error:", error570 print("Update error:", error, file=sys.stderr) 571 571 572 572 listener.failed(error) … … 596 596 except: 597 597 exc = traceback.format_exc() 598 print >> sys.stderr, utf2unicode(exc)598 print(utf2unicode(exc), file=sys.stderr) 599 599 600 600 #------------------------------------------------------------------------------ -
src/mlx/util.py
r784 r919 43 43 #------------------------------------------------------------------------------ 44 44 45 def getCoordinateString( (latitude, longitude)):45 def getCoordinateString(xxx_todo_changeme): 46 46 """Get the string representation of the given coordinate pair.""" 47 47 (latitude, longitude) = xxx_todo_changeme 48 48 latitude_str = getLatitudeString(latitude) 49 49 longitude_str = getLongitudeString(longitude) … … 79 79 (deg, min, sec, _sign) = getDegMinSec(degree) 80 80 81 return u"%s%d\u00b0%02d\u2032%02d\u2033" % (prefix, deg, min, sec)81 return "%s%d\u00b0%02d\u2032%02d\u2033" % (prefix, deg, min, sec) 82 82 83 83 #------------------------------------------------------------------------------ … … 175 175 """Convert the given text from UTF-8 encoding to unicode.""" 176 176 try: 177 return unicode(_utf8decoder(text)[0])177 return str(_utf8decoder(text)[0]) 178 178 except: 179 179 try: 180 return unicode(_latin2decoder(text)[0])180 return str(_latin2decoder(text)[0]) 181 181 except: 182 return unicode(list(text))182 return str(list(text)) -
src/mlx/watchdog.py
r535 r919 60 60 61 61 if logTimeout: 62 print "Watchdog client %s has timed out!" % (self._name)62 print("Watchdog client %s has timed out!" % (self._name)) 63 63 elif logCleared: 64 print "Watchdog client %s has been cleared." % (self._name)64 print("Watchdog client %s has been cleared." % (self._name)) 65 65 66 66 #----------------------------------------------------------------------------- … … 115 115 116 116 if t>=nextLogTime: 117 print "Watchdog.run: running"117 print("Watchdog.run: running") 118 118 while t>=nextLogTime: 119 119 nextLogTime += self.LOG_INTERVAL -
src/mlx/web.py
r859 r919 1 1 2 import const3 import util4 from rpc import Registration5 import rpc6 import rpccommon7 8 from common import MAVA_BASE_URL9 from pirep import PIREP2 from . import const 3 from . import util 4 from .rpc import Registration 5 from . import rpc 6 from . import rpccommon 7 8 from .common import MAVA_BASE_URL 9 from .pirep import PIREP 10 10 11 11 import threading 12 12 import sys 13 import urllib 14 import urllib 213 import urllib.request, urllib.parse, urllib.error 14 import urllib.request, urllib.error, urllib.parse 15 15 import hashlib 16 16 import time … … 19 19 import traceback 20 20 import xml.sax 21 import xmlrpc lib22 import HTMLParser21 import xmlrpc.client 22 import html.parser 23 23 24 24 #--------------------------------------------------------------------------------------- … … 160 160 161 161 date = readline(f) 162 print "web.BookedFlight.readFromWeb: date:", date162 print("web.BookedFlight.readFromWeb: date:", date) 163 163 if date=="0000-00-00": date = "0001-01-01" 164 164 … … 233 233 234 234 if not lineOK: 235 print 236 (lineNumber,) 235 print("web.BookedFlight.readFromFile: line %d is invalid" % \ 236 (lineNumber,)) 237 237 238 238 line = f.readline() … … 290 290 def writeIntoFile(self, f): 291 291 """Write the flight into a file.""" 292 print >> f, "callsign=%s" % (self.callsign,)292 print("callsign=%s" % (self.callsign,), file=f) 293 293 date = self.departureTime.date() 294 print >> f, "date=%04d-%02d-%0d" % (date.year, date.month, date.day)295 print >> f, "dep_airport=%s" % (self.departureICAO,)296 print >> f, "dest_airport=%s" % (self.arrivalICAO,)297 print >> f,"planecode=%s" % \298 (BookedFlight.TYPE2TYPECODE[self.aircraftType],) 299 print >> f, "planetype=%s" % (self.aircraftTypeName,)300 print >> f, "tail_nr=%s" % (self.tailNumber,)301 print >> f, "passenger=%d" % (self.numPassengers,)302 print >> f, "crew=%d" % (self.numCrew,)303 print >> f, "bag=%d" % (self.bagWeight,)304 print >> f, "cargo=%d" % (self.cargoWeight,)305 print >> f, "mail=%d" % (self.mailWeight,)306 print >> f, "flight_route=%s" % (self.route,)294 print("date=%04d-%02d-%0d" % (date.year, date.month, date.day), file=f) 295 print("dep_airport=%s" % (self.departureICAO,), file=f) 296 print("dest_airport=%s" % (self.arrivalICAO,), file=f) 297 print("planecode=%s" % \ 298 (BookedFlight.TYPE2TYPECODE[self.aircraftType],), file=f) 299 print("planetype=%s" % (self.aircraftTypeName,), file=f) 300 print("tail_nr=%s" % (self.tailNumber,), file=f) 301 print("passenger=%d" % (self.numPassengers,), file=f) 302 print("crew=%d" % (self.numCrew,), file=f) 303 print("bag=%d" % (self.bagWeight,), file=f) 304 print("cargo=%d" % (self.cargoWeight,), file=f) 305 print("mail=%d" % (self.mailWeight,), file=f) 306 print("flight_route=%s" % (self.route,), file=f) 307 307 departureTime = self.departureTime 308 print >> f,"departure_time=%02d\\:%02d\\:%02d" % \309 (departureTime.hour, departureTime.minute, departureTime.second) 308 print("departure_time=%02d\\:%02d\\:%02d" % \ 309 (departureTime.hour, departureTime.minute, departureTime.second), file=f) 310 310 arrivalTime = self.arrivalTime 311 print >> f,"arrival_time=%02d\\:%02d\\:%02d" % \312 (arrivalTime.hour, arrivalTime.minute, arrivalTime.second) 313 print >> f, "foglalas_id=%s" % ("0" if self.id is None else self.id,)311 print("arrival_time=%02d\\:%02d\\:%02d" % \ 312 (arrivalTime.hour, arrivalTime.minute, arrivalTime.second), file=f) 313 print("foglalas_id=%s" % ("0" if self.id is None else self.id,), file=f) 314 314 315 315 def _readAircraftType(self, f): … … 364 364 365 365 except: 366 print >> sys.stderr, "Plane string is invalid: '" + s + "'"366 print("Plane string is invalid: '" + s + "'", file=sys.stderr) 367 367 self.tailNumber = None 368 368 … … 470 470 #------------------------------------------------------------------------------ 471 471 472 class PilotsWebNOTAMsParser( HTMLParser.HTMLParser):472 class PilotsWebNOTAMsParser(html.parser.HTMLParser): 473 473 """XML handler for the NOTAM query results on the PilotsWeb website.""" 474 474 def __init__(self): 475 475 """Construct the handler.""" 476 HTMLParser.HTMLParser.__init__(self)476 html.parser.HTMLParser.__init__(self) 477 477 478 478 self._notams = [] … … 513 513 try: 514 514 notam = self._parseCurrentNOTAM2() 515 except Exception ,e:516 print "Error parsing current NOTAM: " + str(e)515 except Exception as e: 516 print("Error parsing current NOTAM: " + str(e)) 517 517 518 518 if notam is None: 519 print "Could not parse NOTAM: " + self._currentNOTAM519 print("Could not parse NOTAM: " + self._currentNOTAM) 520 520 if self._currentNOTAM: 521 521 self._notams.append(self._currentNOTAM + "\n") … … 526 526 """Parse the current NOTAM, if possible, and return a NOTAM object.""" 527 527 lines = self._currentNOTAM.splitlines() 528 lines = map(lambda line: line.strip(), lines)528 lines = [line.strip() for line in lines] 529 529 530 530 if len(lines)<4: … … 579 579 """Parse the current NOTAM with a second, more flexible method.""" 580 580 lines = self._currentNOTAM.splitlines() 581 lines = map(lambda line: line.strip(), lines)581 lines = [line.strip() for line in lines] 582 582 583 583 if not lines: … … 592 592 lines = lines[:-1] 593 593 594 lines = map(lambda line: line.strip(), lines)594 lines = [line.strip() for line in lines] 595 595 contents = " ".join(lines).split() 596 596 … … 653 653 """Get a representation of the result.""" 654 654 s = "<Result:" 655 for (key, value) in self.__dict__.ite ritems():656 s += " " + key + "=" + unicode(value)655 for (key, value) in self.__dict__.items(): 656 s += " " + key + "=" + str(value) 657 657 s += ">" 658 658 return s … … 688 688 result = self.run() 689 689 returned = True 690 except Exception ,e:690 except Exception as e: 691 691 traceback.print_exc() 692 692 result = e … … 695 695 try: 696 696 self._callback(returned, result) 697 except Exception ,e:698 print >> sys.stderr, "web.Handler.Request.perform: callback throwed an exception: " + util.utf2unicode(str(e))697 except Exception as e: 698 print("web.Handler.Request.perform: callback throwed an exception: " + util.utf2unicode(str(e)), file=sys.stderr) 699 699 #traceback.print_exc() 700 700 … … 769 769 result = Result() 770 770 771 f = urllib 2.urlopen(url, timeout = 10.0)771 f = urllib.request.urlopen(url, timeout = 10.0) 772 772 773 773 status = readline(f) … … 880 880 url = MAVA_BASE_URL + "/onlinegates_get.php" 881 881 882 f = urllib 2.urlopen(url, timeout = 10.0)882 f = urllib.request.urlopen(url, timeout = 10.0) 883 883 result = Result() 884 884 result.fleet = Fleet(f) … … 922 922 gateNumber = self._gateNumber if self._gateNumber else "" 923 923 924 data = urllib. urlencode([("lajstrom", self._tailNumber),924 data = urllib.parse.urlencode([("lajstrom", self._tailNumber), 925 925 ("status", status), 926 926 ("kapu", gateNumber)]) 927 927 928 f = urllib 2.urlopen(url, data, timeout = 10.0)928 f = urllib.request.urlopen(url, data, timeout = 10.0) 929 929 line = readline(f) 930 930 … … 983 983 url = "http://notams.euroutepro.com/notams.xml" 984 984 985 f = urllib 2.urlopen(url, timeout = 10.0)985 f = urllib.request.urlopen(url, timeout = 10.0) 986 986 try: 987 987 xmlParser.parse(f) … … 1012 1012 (icao.upper(),) 1013 1013 1014 f = urllib 2.urlopen(url, timeout = 10.0)1014 f = urllib.request.urlopen(url, timeout = 10.0) 1015 1015 try: 1016 1016 data = f.read(16384) … … 1023 1023 return parser.getNOTAMs() 1024 1024 1025 except Exception ,e:1025 except Exception as e: 1026 1026 traceback.print_exc() 1027 print 1028 (icao, str(e)) 1027 print("mlx.web.GetNOTAMs.getPilotsWebNOTAMs: failed to get NOTAMs for '%s': %s" % \ 1028 (icao, str(e))) 1029 1029 return None 1030 1030 … … 1042 1042 """Perform the retrieval opf the METARs.""" 1043 1043 url = "http://www.aviationweather.gov/adds/dataserver_current/httpparam?" 1044 data = urllib. urlencode([ ("dataSource" , "metars"),1044 data = urllib.parse.urlencode([ ("dataSource" , "metars"), 1045 1045 ("requestType", "retrieve"), 1046 1046 ("format", "csv"), … … 1049 1049 ("mostRecentForEachStation", "constraint")]) 1050 1050 url += data 1051 f = urllib 2.urlopen(url, timeout = 10.0)1051 f = urllib.request.urlopen(url, timeout = 10.0) 1052 1052 try: 1053 1053 result = Result() … … 1128 1128 data["insdate"] = datetime.date.today().strftime("%Y-%m-%d") 1129 1129 1130 postData = urllib. urlencode(data)1131 f = urllib 2.urlopen(url, postData, timeout = 10.0)1130 postData = urllib.parse.urlencode(data) 1131 f = urllib.request.urlopen(url, postData, timeout = 10.0) 1132 1132 try: 1133 1133 result = Result() 1134 1134 line = f.readline().strip() 1135 print "PIREP result from website:", line1135 print("PIREP result from website:", line) 1136 1136 result.success = line=="OK" 1137 1137 result.alreadyFlown = line=="MARVOLT" … … 1178 1178 def run(self): 1179 1179 """Perform the sending of the ACARS.""" 1180 print "Sending the online ACARS"1180 print("Sending the online ACARS") 1181 1181 1182 1182 url = MAVA_BASE_URL + "/acars2/acarsonline.php" … … 1204 1204 data["event"] = acars.getEventText() 1205 1205 1206 f = urllib 2.urlopen(url, urllib.urlencode(data), timeout = 10.0)1206 f = urllib.request.urlopen(url, urllib.parse.urlencode(data), timeout = 10.0) 1207 1207 try: 1208 1208 result = Result() … … 1223 1223 def run(self): 1224 1224 """Perform the sending of the ACARS.""" 1225 print "Sending the online ACARS via JSON-RPC"1225 print("Sending the online ACARS via JSON-RPC") 1226 1226 1227 1227 self._client.updateOnlineACARS(self._acars) … … 1243 1243 def run(self): 1244 1244 """Perform the sending of the bug report.""" 1245 serverProxy = xmlrpc lib.ServerProxy("http://mlx.varadiistvan.hu/rpc")1245 serverProxy = xmlrpc.client.ServerProxy("http://mlx.varadiistvan.hu/rpc") 1246 1246 1247 1247 result = Result() … … 1254 1254 result.ticketID = serverProxy.ticket.create(self._summary, self._description, 1255 1255 attributes, True) 1256 print "Created ticket with ID:", result.ticketID1256 print("Created ticket with ID:", result.ticketID) 1257 1257 result.success = True 1258 1258 … … 1288 1288 1289 1289 pirepData = self._client.getPIREP(self._flightID) 1290 print "pirepData:", pirepData1290 print("pirepData:", pirepData) 1291 1291 1292 1292 bookedFlight = BookedFlight(self._flightID) … … 1512 1512 1513 1513 def callback(returned, result): 1514 print returned, unicode(result)1514 print(returned, str(result)) 1515 1515 1516 1516 handler = Handler() -
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.