Changeset 919:2ce8ca39525b for src


Ignore:
Timestamp:
03/24/19 08:15:59 (6 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Message:

Ran 2to3

Location:
src/mlx
Files:
45 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acars.py

    r743 r919  
    11
    2 import const
     2from . import const
    33
    44#------------------------------------------------------------------------------
  • src/mlx/acft.py

    r905 r919  
    11
    2 import const
    3 import gates
    4 import checks
    5 import fs
    6 from i18n import xstr
    7 import util
     2from . import const
     3from . import gates
     4from . import checks
     5from . import fs
     6from .i18n import xstr
     7from . import util
    88
    99import sys
     
    308308              ("-" if value is None else "enabled" if value else "disabled",)
    309309        elif dt!=DERATE_NONE:
    310             print "mlx.acft.getDerateLine: invalid derate type: " + dt
     310            print("mlx.acft.getDerateLine: invalid derate type: " + dt)
    311311
    312312        return None
     
    343343                                  self._aircraftState, aircraftState)
    344344                except:
    345                     print >> sys.stderr, "Checker", checker, "failed"
     345                    print("Checker", checker, "failed", file=sys.stderr)
    346346                    traceback.print_exc()
    347347
     
    351351            self._minVS = min(self._minVS, aircraftState.vs)
    352352        except:
    353             print >> sys.stderr, "Failed to handle the state"
     353            print("Failed to handle the state", file=sys.stderr)
    354354            traceback.print_exc()
    355355        finally:
     
    403403                    self._logQNH(aircraftState)
    404404            elif newStage==const.STAGE_GOAROUND:
    405                 from logger import Logger
     405                from .logger import Logger
    406406                self._flight.handleFault("goaround",
    407407                                         aircraftState.timestamp,
     
    12841284    value = SmoothedValue()
    12851285
    1286     print "Adding 1, 12.0"
     1286    print("Adding 1, 12.0")
    12871287    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")
    12911291    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")
    12951295    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")
    12991299    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")
    13031303    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")
    13071307    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")
    13111311    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")
    13151315    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")
    13191319    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")
    13231323    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")
    13271327    value.add(2, 55.0)
    1328     print value.get()
    1329 
    1330 #---------------------------------------------------------------------------------------
     1328    print(value.get())
     1329
     1330#---------------------------------------------------------------------------------------
  • src/mlx/airports.py

    r325 r919  
    8888
    8989if __name__ == "__main__":
    90     for (town, airport) in airportNames.itervalues():
    91         print town, airport
    92     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"))
    9797
    9898#-----------------------------------------------------------------------------
  • src/mlx/checks.py

    r912 r919  
    11
    2 import fs
    3 import const
    4 import util
    5 from acars import ACARS
    6 from sound import startSound
     2from . import fs
     3from . import const
     4from . import util
     5from .acars import ACARS
     6from .sound import startSound
    77
    88import time
     
    129129        """Callback for ACARS sending."""
    130130        if returned:
    131             print "Sent online ACARS"
     131            print("Sent online ACARS")
    132132            self._lastSent = time.time() if self._lastSent is None \
    133133                             else self._lastSent + ACARSSender.INTERVAL
    134134        else:
    135             print "Failed to send the ACARS"
     135            print("Failed to send the ACARS")
    136136        self._sending = False
    137137
     
    517517    def getMessage(logName, frequency, obs):
    518518        """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,)
    521521        return message
    522522
     
    747747        message = what
    748748        if value is None:
    749             message += u" cannot be detected, will not log"
     749            message += " cannot be detected, will not log"
    750750        else:
    751             message += u": " + format % (value,)
     751            message += ": " + format % (value,)
    752752        logger.message(timestamp, message)
    753753
     
    767767    def _logAPHeading(logger, timestamp, state):
    768768        """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)
    771771
    772772    @staticmethod
     
    779779    def _logAPAltitude(logger, timestamp, state):
    780780        """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)
    783783
    784784    def __init__(self):
  • src/mlx/common.py

    r800 r919  
    2424# Due to CEF, PyGTK is the default
    2525if "FORCE_PYGOBJECT" not in os.environ:
    26     print "Using PyGTK"
     26    print("Using PyGTK")
    2727    pygobject = False
    2828    import gobject
    2929else:
    30     print "Using PyGObject"
     30    print("Using PyGObject")
    3131    pygobject = True
    3232
  • src/mlx/config.py

    r738 r919  
    11# -*- encoding: utf-8 -*-
    22
    3 import const
    4 from util import secondaryInstallation, utf2unicode
     3from . import const
     4from .util import secondaryInstallation, utf2unicode
    55
    66import os
    77import sys
    88import traceback
    9 import ConfigParser
     9import configparser
    1010
    1111## @package mlx.config
     
    163163        baseName = "callouts." + const.icaoCodes[aircraftType] + "."
    164164        index = 0
    165         for (altitude, path) in self._mapping.iteritems():
     165        for (altitude, path) in self._mapping.items():
    166166            option = baseName + str(index)
    167167            config.set(ApproachCallouts.SECTION, option,
     
    171171    def getAltitudes(self, descending = True):
    172172        """Get the altitudes in decreasing order by default."""
    173         altitudes = self._mapping.keys()
     173        altitudes = list(self._mapping.keys())
    174174        altitudes.sort(reverse = descending)
    175175        return altitudes
    176176
    177     def __nonzero__(self):
     177    def __bool__(self):
    178178        """Return if there is anything in the mapping."""
    179179        return not not self._mapping
     
    704704        """Load the configuration from its default location."""
    705705        try:
    706             config = ConfigParser.RawConfigParser()
     706            config = configparser.RawConfigParser()
    707707            config.read(configPath)
    708708        except:
     
    806806            return
    807807
    808         config = ConfigParser.RawConfigParser()
     808        config = configparser.RawConfigParser()
    809809
    810810        config.add_section("login")
     
    892892        try:
    893893            fd = os.open(configPath, os.O_CREAT|os.O_TRUNC|os.O_WRONLY,
    894                          0600)
     894                         0o600)
    895895            with os.fdopen(fd, "wt") as f:
    896896                config.write(f)
    897897            self._modified = False
    898898
    899             print "Configuration saved:"
     899            print("Configuration saved:")
    900900            self.log()
    901901
    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)
    905905
    906906    def _getBoolean(self, config, section, option, default):
     
    945945        import locale
    946946        if self._language:
    947             print "Setting up locale for", self._language
     947            print("Setting up locale for", self._language)
    948948            os.environ["LANGUAGE"] = self._language
    949949            langAndEncoding = self._language + "." + locale.getpreferredencoding()
     
    978978    def log(self):
    979979        """Log the configuration by printing the values"""
    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.iteritems():
    1024             print "    %s: %s" % (const.messageType2string(type),
    1025                                   const.messageLevel2string(level))
    1026 
    1027         print "  checklists:"
    1028         for (type, checklist) in self._checklists.iteritems():
    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],))
    10301030            for path in checklist:
    1031                 print "      " + path
    1032 
    1033         print "  approachCallouts:"
    1034         for (type, approachCallouts) in self._approachCallouts.iteritems():
    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],))
    10361036            for (altitude, path) in approachCallouts:
    1037                 print "      %d: %s" % (altitude, path)
     1037                print("      %d: %s" % (altitude, path))
    10381038
    10391039#-------------------------------------------------------------------------------
  • src/mlx/const.py

    r911 r919  
    193193def aircraftType2Family(aircraftType):
    194194    """Get the family for the given aircraft type."""
    195     for (family, types) in aircraftFamily2Types.iteritems():
     195    for (family, types) in aircraftFamily2Types.items():
    196196        if aircraftType in types:
    197197            return family
     
    424424def string2messageLevel(str):
    425425    """Get the message level for the given string."""
    426     for (value, s) in _messageLevelStrings.iteritems():
     426    for (value, s) in _messageLevelStrings.items():
    427427        if str==s:
    428428            return value
  • src/mlx/flight.py

    r846 r919  
    11
    2 from soundsched import SoundScheduler, ChecklistScheduler
    3 from checks import SpeedChecker
    4 
    5 import const
    6 import util
     2from .soundsched import SoundScheduler, ChecklistScheduler
     3from .checks import SpeedChecker
     4
     5from . import const
     6from . import util
    77import time
    88
  • src/mlx/fs.py

    r909 r919  
    11
    2 import const
    3 from sound import startSound
     2from . import const
     3from .sound import startSound
    44
    55import os
    66
    7 import fsuipc
    8 import xplane
     7from . import fsuipc
     8from . import xplane
    99
    1010import threading
     
    3636        """Called when a connection has been established to the flight
    3737        simulator of the given type."""
    38         print "fs.ConnectionListener.connected, fsType:", fsType, ", descriptor:", descriptor
     38        print("fs.ConnectionListener.connected, fsType:", fsType, ", descriptor:", descriptor)
    3939
    4040    def connectionFailed(self):
    4141        """Called when the connection could not be established."""
    42         print "fs.ConnectionListener.connectionFailed"
     42        print("fs.ConnectionListener.connectionFailed")
    4343
    4444    def disconnected(self):
    4545        """Called when a connection to the flight simulator has been broken."""
    46         print "fs.ConnectionListener.disconnected"
     46        print("fs.ConnectionListener.disconnected")
    4747
    4848#-------------------------------------------------------------------------------
  • src/mlx/fsuipc.py

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

    r747 r919  
    11
    2 from common import *
     2from .common import *
    33
    44from mlx.i18n import xstr
    55import mlx.const as const
    66
    7 import cef
     7from . import cef
    88
    99#------------------------------------------------------------------------------
  • src/mlx/gui/bugreport.py

    r492 r919  
    11
    2 from common import *
     2from .common import *
    33
    44from mlx.i18n import xstr
     
    105105        response = super(BugReportDialog, self).run()
    106106
    107         print "response", response, RESPONSETYPE_ACCEPT
     107        print("response", response, RESPONSETYPE_ACCEPT)
    108108        if response==RESPONSETYPE_ACCEPT:
    109109            self._send()
  • src/mlx/gui/callouts.py

    r300 r919  
    11
    2 from common import *
     2from .common import *
    33
    44from mlx.i18n import xstr
     
    208208            config = self._gui.config
    209209            for (aircraftType, approachCallouts) in \
    210                     self._approachCallouts.iteritems():
     210                    self._approachCallouts.items():
    211211                config.setApproachCallouts(aircraftType, approachCallouts)
    212212            config.save()
  • src/mlx/gui/cef.py

    r915 r919  
    1 from common import *
     1from .common import *
    22
    33from mlx.util import secondaryInstallation
     
    1010import os
    1111import re
    12 import thread
     12import _thread
    1313import threading
    1414import tempfile
    1515import traceback
    16 import urllib2
     16import urllib.request, urllib.error, urllib.parse
    1717from lxml import etree
    18 from StringIO import StringIO
     18from io import StringIO
    1919import lxml.html
    2020
     
    115115        """Called when a page has been loaded in the SimBrief browser."""
    116116        url = frame.GetUrl()
    117         print "gui.cef.SimBriefHandler._onLoadEnd", httpCode, url
     117        print("gui.cef.SimBriefHandler._onLoadEnd", httpCode, url)
    118118        if httpCode>=300:
    119119            self._updateProgress(self._lastProgress,
     
    127127
    128128            js = "form=document.getElementById(\"sbapiform\");"
    129             for (name, value) in self._plan.iteritems():
     129            for (name, value) in self._plan.items():
    130130                js += "form." + name + ".value=\"" + value + "\";"
    131             for (name, value) in SimBriefHandler._querySettings.iteritems():
     131            for (name, value) in SimBriefHandler._querySettings.items():
    132132                if isinstance(value, bool):
    133133                    js += "form." + name + ".checked=" + \
     
    175175
    176176            thread = threading.Thread(target = self._getResults, args = (link,))
    177             thread.daemon = True
    178             thread.start()
     177            _thread.daemon = True
     178            _thread.start()
    179179        else:
    180180            self._updateProgress(SIMBRIEF_PROGRESS_RETRIEVING_BRIEFING,
     
    219219
    220220        # Obtaining the xml
    221         response = urllib2.urlopen(link)
     221        response = urllib.request.urlopen(link)
    222222        xmlContent = response.read()
    223223        # Processing xml
     
    242242                    imageLinks.append(imageLink[2])
    243243        flightInfo["image_links"] = imageLinks
    244         print(sorted(availableInfo.keys()))
     244        print((sorted(availableInfo.keys())))
    245245        htmlFilePath = "simbrief_plan.html" if self._htmlFilePath is None \
    246246          else self._htmlFilePath
     
    266266def _initializeCEF(args, initializedCallback):
    267267    """Perform the actual initialization of CEF using the given arguments."""
    268     print "Initializing CEF with args:", args
     268    print("Initializing CEF with args:", args)
    269269
    270270    settings = {
     
    290290                    switches[arg[2:assignIndex]] = arg[assignIndex+1:]
    291291        else:
    292             print "Unhandled switch", arg
     292            print("Unhandled switch", arg)
    293293
    294294    cefpython.Initialize(settings, switches)
     
    296296    gobject.timeout_add(10, _handleTimeout)
    297297
    298     print "Initialized, executing callback..."
     298    print("Initialized, executing callback...")
    299299    initializedCallback()
    300300
     
    322322        window = container.get_window()
    323323        if window is None:
    324             print "mlx.gui.cef.startInContainer: no window found!"
     324            print("mlx.gui.cef.startInContainer: no window found!")
    325325            windowID = None
    326326        else:
  • src/mlx/gui/checklist.py

    r300 r919  
    11
    2 from common import *
     2from .common import *
    33
    44from mlx.i18n import xstr
     
    190190            self._saveChecklist()
    191191            config = self._gui.config
    192             for (aircraftType, checklist) in self._checklists.iteritems():
     192            for (aircraftType, checklist) in self._checklists.items():
    193193                config.setChecklist(aircraftType, checklist)
    194194            config.save()
  • src/mlx/gui/common.py

    r863 r919  
    3131
    3232if not pygobject:
    33     print "Using PyGTK"
     33    print("Using PyGTK")
    3434    pygobject = False
    3535    import pygtk
     
    4242        import appindicator
    4343        appIndicator = True
    44     except Exception, e:
     44    except Exception as e:
    4545        pass
    4646
     
    113113    def text2unicode(text):
    114114        """Convert the given text, returned by a Gtk widget, to Unicode."""
    115         return unicode(text)
     115        return str(text)
    116116
    117117    def text2str(text):
  • src/mlx/gui/delaycodes.py

    r840 r919  
    33#------------------------------------------------------------------------------
    44
    5 from dcdata import CAPTION, DELAYCODE, getTable
     5from .dcdata import CAPTION, DELAYCODE, getTable
    66
    77from mlx.gui.common import *
  • src/mlx/gui/faultexplain.py

    r842 r919  
    247247    def reset(self):
    248248        """Reset the widget by removing all faults."""
    249         for (alignment, faultFrame) in self._faultWidgets.itervalues():
     249        for (alignment, faultFrame) in self._faultWidgets.values():
    250250            self._faults.remove(alignment)
    251251        self._faults.show_all()
  • src/mlx/gui/flight.py

    r872 r919  
    405405    def _offlineClicked(self, button):
    406406        """Called when the offline button was clicked."""
    407         print "mlx.flight.LoginPage: offline flight selected"
     407        print("mlx.flight.LoginPage: offline flight selected")
    408408        self._wizard.nextPage()
    409409
    410410    def _loginClicked(self, button):
    411411        """Called when the login button was clicked."""
    412         print "mlx.flight.LoginPage: logging in"
     412        print("mlx.flight.LoginPage: logging in")
    413413        self._wizard.login(self._handleLoginResult,
    414414                           self._pilotID.get_text(),
     
    649649        if response==RESPONSETYPE_OK:
    650650            fileName = text2unicode(dialog.get_filename())
    651             print "Saving", fileName
     651            print("Saving", fileName)
    652652            try:
    653653                with open(fileName, "wt") as f:
    654654                    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)))
    657657                dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
    658658                                           type = MESSAGETYPE_ERROR,
     
    706706        flight=self._getSelectedFlight()
    707707
    708         print "DPI", context.get_dpi_x(), context.get_dpi_y()
     708        print("DPI", context.get_dpi_x(), context.get_dpi_y())
    709709
    710710        scale = context.get_dpi_x() / 72.0
     
    719719
    720720        layout = cr.create_layout()
    721         layout.set_text(u"Malév VA official briefing")
     721        layout.set_text("Malév VA official briefing")
    722722        font = pango.FontDescription("sans")
    723723        font.set_size(int(32 * scale * pango.SCALE))
     
    740740
    741741        layout = cr.create_layout()
    742         layout.set_text(u"%s (%s) részére" %
     742        layout.set_text("%s (%s) részére" %
    743743                        (loginResult.pilotName, loginResult.pilotID))
    744744        font = pango.FontDescription("sans")
     
    940940        if response==RESPONSETYPE_OK:
    941941            fileName = text2unicode(dialog.get_filename())
    942             print "Loading", fileName
     942            print("Loading", fileName)
    943943            bookedFlight = web.BookedFlight()
    944944            try:
     
    946946                    bookedFlight.readFromFile(f)
    947947                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)))
    950950                dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
    951951                                           type = MESSAGETYPE_ERROR,
     
    16291629                                            self.phoneNumber, self.nationality,
    16301630                                            self.password)
    1631         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
     1631        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)
    16401640
    16411641        gui = self._wizard.gui
     
    16531653        gui.endBusy()
    16541654
    1655         print "Registration result:"
    1656         print "  returned:", returned
     1655        print("Registration result:")
     1656        print("  returned:", returned)
    16571657        if returned:
    1658             print "  registered:", result.registered
     1658            print("  registered:", result.registered)
    16591659            if result.registered:
    1660                 print "  pilotID", result.pilotID
    1661                 print "  loggedIn", result.loggedIn
    1662             print "  emailAlreadyRegistered:", result.emailAlreadyRegistered
    1663             print "  invalidData:", result.invalidData
     1660                print("  pilotID", result.pilotID)
     1661                print("  loggedIn", result.loggedIn)
     1662            print("  emailAlreadyRegistered:", result.emailAlreadyRegistered)
     1663            print("  invalidData:", result.invalidData)
    16641664
    16651665        registrationOK = returned and result.registered
     
    18301830    def activate(self):
    18311831        """Activate the student page."""
    1832         print "StudentPage.activate"
     1832        print("StudentPage.activate")
    18331833        self._getEntryExamStatusCancelled = False
    18341834
     
    18441844    def finalize(self):
    18451845        """Finalize the page."""
    1846         print "StudentPage.finalize"
     1846        print("StudentPage.finalize")
    18471847        self._getEntryExamStatusCancelled = True
    18481848
     
    18641864    def _handleEntryExamStatus(self, returned, result):
    18651865        """Called when the entry exam status is availabe."""
    1866         print "_handleEntryExamStatus", returned, result
     1866        print("_handleEntryExamStatus", returned, result)
    18671867        if returned and not self._getEntryExamStatusCancelled:
    18681868            self._entryExamLink = result.entryExamLink
     
    29912991
    29922992            plan = self._getPlan()
    2993             print "plan:", plan
     2993            print("plan:", plan)
    29942994
    29952995            takeoffRunway = self._takeoffRunway.get_text()
     
    30273027        are returned. Otherwise a dialog box is displayed informing the user of
    30283028        invalid credentials and requesting another set of them."""
    3029         print "_getCredentials", count
     3029        print("_getCredentials", count)
    30303030        if count==0:
    30313031            return (self._userName.get_text(), self._password.get_text())
     
    30613061    def _simBriefProgress(self, progress, result, flightInfo):
    30623062        """The real SimBrief progress handler."""
    3063         print "_simBriefProgress", progress, result, flightInfo
     3063        print("_simBriefProgress", progress, result, flightInfo)
    30643064        if result==cef.SIMBRIEF_RESULT_NONE:
    30653065            message = SimBriefSetupPage.progress2Message.get(progress,
     
    37583758    def _metarChanged(self, buffer):
    37593759        """Called when the METAR has changed."""
    3760         print "BriefingPage.metarChanged", self._updatingMETAR
     3760        print("BriefingPage.metarChanged", self._updatingMETAR)
    37613761        if not self._updatingMETAR:
    37623762            self.metarEdited = True
     
    37703770
    37713771        It uppercases all characters."""
    3772         print "BriefingPage.metarInserted", self._updatingMETAR
     3772        print("BriefingPage.metarInserted", self._updatingMETAR)
    37733773        if not self._updatingMETAR:
    37743774            self._updatingMETAR = True
     
    40254025    def activate(self):
    40264026        """Activate the page."""
    4027         print "TakeoffPage.activate"
     4027        print("TakeoffPage.activate")
    40284028
    40294029        self._updatingMETAR = True
     
    40694069    def allowForward(self):
    40704070        """Allow going to the next page."""
    4071         print "TakeoffPage.allowForward"
     4071        print("TakeoffPage.allowForward")
    40724072        self._forwardAllowed = True
    40734073        self._updateForwardButton()
     
    40754075    def reset(self):
    40764076        """Reset the page if the wizard is reset."""
    4077         print "TakeoffPage.reset"
     4077        print("TakeoffPage.reset")
    40784078
    40794079        super(TakeoffPage, self).reset()
     
    40954095        pages."""
    40964096        if self._active:
    4097             print "TakeoffPage.changeMETAR"
     4097            print("TakeoffPage.changeMETAR")
    40984098            self._updatingMETAR = True
    40994099            self._metar.get_buffer().set_text(metar, -1)
     
    41164116                     self.derate is not None)
    41174117
    4118         print "TakeoffPage._updateForwardButton: forwardAllowed:", self._forwardAllowed, ", sensitive:", sensitive
     4118        print("TakeoffPage._updateForwardButton: forwardAllowed:", self._forwardAllowed, ", sensitive:", sensitive)
    41194119        if self._forwardAllowed:
    4120             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
     4120            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)
    41284128
    41294129        self._button.set_sensitive(sensitive)
     
    41314131    def _valueChanged(self, widget, arg = None):
    41324132        """Called when the value of some widget has changed."""
    4133         print "TakeoffPage._valueChanged"
     4133        print("TakeoffPage._valueChanged")
    41344134
    41354135        self._updateForwardButton()
     
    41384138        """Called when the value of some entry widget has changed and the value
    41394139        should be converted to uppercase."""
    4140         print "TakeoffPage._upperChanged"
     4140        print("TakeoffPage._upperChanged")
    41414141        entry.set_text(entry.get_text().upper())
    41424142        self._valueChanged(entry, arg)
     
    41514151    def _derateChanged(self, entry):
    41524152        """Called when the value of the derate is changed."""
    4153         print "TakeoffPage._derateChanged"
     4153        print("TakeoffPage._derateChanged")
    41544154        self._updateForwardButton()
    41554155
     
    42624262    def _metarChanged(self, entry):
    42634263        """Called when the METAR has changed."""
    4264         print "TakeoffPage.metarChanged", self._updatingMETAR
     4264        print("TakeoffPage.metarChanged", self._updatingMETAR)
    42654265        if not self._updatingMETAR:
    42664266            self._updateForwardButton()
     
    42714271
    42724272        It uppercases all characters."""
    4273         print "TakeoffPage.metarInserted", self._updatingMETAR
     4273        print("TakeoffPage.metarInserted", self._updatingMETAR)
    42744274        if not self._updatingMETAR:
    42754275            self._updatingMETAR = True
     
    46284628        pages."""
    46294629        if self._active:
    4630             print "LandingPage.changeMETAR"
     4630            print("LandingPage.changeMETAR")
    46314631            self._updatingMETAR = True
    46324632            self._metar.get_buffer().set_text(metar, -1)
     
    46894689    def _metarChanged(self, entry):
    46904690        """Called when the METAR has changed."""
    4691         print "LandingPage.metarChanged", self._updatingMETAR
     4691        print("LandingPage.metarChanged", self._updatingMETAR)
    46924692        if not self._updatingMETAR:
    46934693            self._updateForwardButton()
     
    46984698
    46994699        It uppercases all characters."""
    4700         print "LandingPage.metarInserted", self._updatingMETAR
     4700        print("LandingPage.metarInserted", self._updatingMETAR)
    47014701        if not self._updatingMETAR:
    47024702            self._updatingMETAR = True
     
    52175217        pass
    52185218
    5219     def _formatTime(self, scheduledTime, realTimestamp, (warning, error)):
     5219    def _formatTime(self, scheduledTime, realTimestamp, xxx_todo_changeme):
    52205220        """Format the departure or arrival time based on the given data as a
    52215221        markup for a label."""
     5222        (warning, error) = xxx_todo_changeme
    52225223        realTime = time.gmtime(realTimestamp)
    52235224
     
    57525753        elif stage==const.STAGE_LANDING:
    57535754            if not self._arrivalBriefingPage.metarEdited:
    5754                 print "Downloading arrival METAR again"
     5755                print("Downloading arrival METAR again")
    57555756                self.gui.webHandler.getMETARs(self._arrivalMETARCallback,
    57565757                                              [self._bookedFlight.arrivalICAO])
  • src/mlx/gui/flightlist.py

    r868 r919  
    6161
    6262        if self._extraColumnAttributes is not None:
    63             for (key, value) in self._extraColumnAttributes.iteritems():
     63            for (key, value) in self._extraColumnAttributes.items():
    6464                if key=="alignment":
    6565                    self._renderer.set_alignment(value, 0.5)
     
    401401        gui.endBusy()
    402402
    403         print "PendingFlightsFrame._handleReflyResult", returned, result
     403        print("PendingFlightsFrame._handleReflyResult", returned, result)
    404404
    405405        if returned:
     
    444444        gui.endBusy()
    445445
    446         print "PendingFlightsFrame._handleDeleteResult", returned, result
     446        print("PendingFlightsFrame._handleDeleteResult", returned, result)
    447447
    448448        if returned:
  • src/mlx/gui/gates.py

    r619 r919  
    143143        self._fleetStore.clear()
    144144        if fleet is None:
    145             for (gateNumber, label) in self._gateLabels.iteritems():
     145            for (gateNumber, label) in self._gateLabels.items():
    146146                label.set_markup("<b>" + gateNumber + "</b>")
    147147        else:       
  • src/mlx/gui/gui.py

    r869 r919  
    11# -*- coding: utf-8 -*-
    22
    3 from statusicon import StatusIcon
    4 from statusbar import Statusbar
    5 from info import FlightInfo
    6 from update import Updater
     3from .statusicon import StatusIcon
     4from .statusbar import Statusbar
     5from .info import FlightInfo
     6from .update import Updater
    77from mlx.gui.common import *
    88from mlx.gui.flight import Wizard
     
    1818from mlx.gui.acars import ACARS
    1919from mlx.gui.timetable import TimetableWindow
    20 import cef
     20from . import cef
    2121
    2222import mlx.const as const
     
    5151class GUI(fs.ConnectionListener):
    5252    """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") ]
    6262
    6363    def __init__(self, programDirectory, config):
     
    14621462                secondaryMarkup = xstr("sendPIREP_unknown_sec")
    14631463        else:
    1464             print "PIREP sending failed", result
     1464            print("PIREP sending failed", result)
    14651465            messageFormat = xstr("sendPIREP_failed")
    14661466            secondaryMarkup = xstr("sendPIREP_failed_sec")
     
    16861686                secondaryMarkup = xstr("sendPIREP_unknown_sec")
    16871687        else:
    1688             print "PIREP sending failed", result
     1688            print("PIREP sending failed", result)
    16891689            messageFormat = xstr("sendPIREP_failed")
    16901690            secondaryMarkup = xstr("sendPIREP_failed_sec")
     
    17111711
    17121712        for (timestampString, text) in self._logger.lines:
    1713             description += unicode(formatFlightLogLine(timestampString, text))
     1713            description += str(formatFlightLogLine(timestampString, text))
    17141714
    17151715        description += "\n\n" + ("=" * 40)
     
    17981798            for index in hotkeys:
    17991799                if index==self._pilotHotkeyIndex:
    1800                     print "gui.GUI._handleHotkeys: pilot hotkey pressed"
     1800                    print("gui.GUI._handleHotkeys: pilot hotkey pressed")
    18011801                    self._flight.pilotHotkeyPressed()
    18021802                elif index==self._checklistHotkeyIndex:
    1803                     print "gui.GUI._handleHotkeys: checklist hotkey pressed"
     1803                    print("gui.GUI._handleHotkeys: checklist hotkey pressed")
    18041804                    self._flight.checklistHotkeyPressed()
    18051805                else:
    1806                     print "gui.GUI._handleHotkeys: unhandled hotkey index:", index
     1806                    print("gui.GUI._handleHotkeys: unhandled hotkey index:", index)
    18071807
    18081808    def _showManual(self, menuitem):
  • src/mlx/gui/info.py

    r846 r919  
    11
    2 from common import *
     2from .common import *
    33
    44from mlx.gui.delaycodes import DelayCodeTable
  • src/mlx/gui/pirep.py

    r855 r919  
    11
    2 from common import *
    3 from dcdata import getTable
    4 from info import FlightInfo
    5 from flight import comboModel
     2from .common import *
     3from .dcdata import getTable
     4from .info import FlightInfo
     5from .flight import comboModel
    66
    77from mlx.pirep import PIREP
  • src/mlx/gui/prefs.py

    r738 r919  
    11
    2 from common import *
     2from .common import *
    33
    44from mlx.i18n import xstr
     
    66import mlx.config as config
    77
    8 import urlparse
     8import urllib.parse
    99
    1010#------------------------------------------------------------------------------
     
    6363
    6464        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)):
    6666            self._hotkeyModel.append([chr(keyCode)])
    6767
     
    829829        sensitive = False
    830830        try:
    831             result = urlparse.urlparse(self._updateURL.get_text())
     831            result = urllib.parse.urlparse(self._updateURL.get_text())
    832832            sensitive = result.scheme!="" and (result.netloc + result.path)!=""
    833833        except:
  • src/mlx/gui/statusbar.py

    r679 r919  
    11
    2 from common import *
     2from .common import *
    33
    44import mlx.const as const
  • src/mlx/gui/statusicon.py

    r544 r919  
    11
    2 from common import *
     2from .common import *
    33
    44import mlx.const as const
     
    154154    def _updateFlightStatus(self):
    155155        """Update the flight status."""
    156         stage = u"-" if self._stage is None \
     156        stage = "-" if self._stage is None \
    157157                else xstr("flight_stage_" + const.stage2string(self._stage))
    158158
     
    172172            if self._noGoReason is not None:
    173173                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" %\
    175175                     (const.VERSION, xstr("statusicon_stage"), stage,
    176176                      xstr("statusicon_rating"), rating)
  • src/mlx/gui/timetable.py

    r879 r919  
    44
    55from mlx.gui.common import *
    6 from flightlist import ColumnDescriptor
     6from .flightlist import ColumnDescriptor
    77from mlx.rpc import ScheduledFlight
    88
     
    249249                    self._tooltips.set_tip(widget, "")
    250250                    self._tooltips.disable()
    251         except Exception, e:
    252             print e
     251        except Exception as e:
     252            print(e)
    253253            self._tooltips.set_tip(widget, "")
    254254            self._tooltips.disable()
     
    656656            typeFamilies.add(const.aircraftType2Family(aircraftType))
    657657
    658         for (typeFamily, checkButton) in self._typeFamilyButtons.iteritems():
     658        for (typeFamily, checkButton) in self._typeFamilyButtons.items():
    659659            checkButton.set_sensitive(typeFamily in typeFamilies)
    660660
     
    712712        """Update the timetable list."""
    713713        aircraftTypes = []
    714         for (aircraftFamily, button) in self._typeFamilyButtons.iteritems():
     714        for (aircraftFamily, button) in self._typeFamilyButtons.items():
    715715            if button.get_active():
    716716                aircraftTypes += const.aircraftFamily2Types[aircraftFamily]
  • src/mlx/i18n.py

    r298 r919  
    2424def setLanguage(programDirectory, language):
    2525    """Setup the internationalization support for the given language."""
    26     print "i18n.setLanguage", language
     26    print("i18n.setLanguage", language)
    2727    translation = _getTranslation(programDirectory, language)
    2828    fallback = _getFallbackFor(programDirectory, language)
  • src/mlx/logger.py

    r634 r919  
    11
    2 from fs import sendMessage
    3 import const
    4 import util
     2from .fs import sendMessage
     3from . import const
     4from . import util
    55
    66import sys
     
    235235    def debug(self, msg):
    236236        """Log a debug message."""
    237         print "[DEBUG]", msg
     237        print("[DEBUG]", msg)
    238238
    239239    def stage(self, timestamp, stage):
     
    326326        """Get the rating of the flight so far."""
    327327        totalScore = 100
    328         for fault in self._faults.itervalues():
     328        for fault in self._faults.values():
    329329            score = fault.score
    330330            if score==Logger.NO_GO_SCORE:
  • src/mlx/mlx.py

    r800 r919  
    11
    2 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
     2from .config import Config
     3from .i18n import setLanguage
     4from .sound import preInitializeSound, initializeSound, finalizeSound
     5from .util import secondaryInstallation
     6from .const import VERSION
     7from .watchdog import Watchdog
    88
    99import os
     
    6060def main():
    6161    """The main operation of the program."""
    62     from singleton import SingleInstance, raiseCallbackWrapper
     62    from .singleton import SingleInstance, raiseCallbackWrapper
    6363
    6464    global instance
     
    8686    sys.stderr = StdIOHandler(gui)
    8787
    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:")
    9090    config.log()
    9191
  • src/mlx/pirep.py

    r856 r919  
    11
    2 from util import utf2unicode
    3 from flight import Flight
    4 
    5 import const
    6 import cPickle as pickle
     2from .util import utf2unicode
     3from .flight import Flight
     4
     5from . import const
     6import pickle as pickle
    77import calendar
    88import datetime
     
    6565    def decodeFlightTypeText(s):
    6666        """Decode the given flight type text."""
    67         for (flighType, text) in PIREP._flightTypes.iteritems():
     67        for (flighType, text) in PIREP._flightTypes.items():
    6868            if s==text:
    6969                return flighType
     
    124124                    pirep.mailWeight = pirep.bookedFlight.mailWeight
    125125                return pirep
    126         except Exception, e:
    127             print "Failed loading PIREP from %s: %s" % (path,
    128                                                         utf2unicode(str(e)))
     126        except Exception as e:
     127            print("Failed loading PIREP from %s: %s" % (path,
     128                                                        utf2unicode(str(e))))
    129129            return None
    130130
     
    367367                pickle.dump(self, f)
    368368            return None
    369         except Exception, e:
     369        except Exception as e:
    370370            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))
    372372            return error
    373373
  • src/mlx/pyuipc_emu.py

    r298 r919  
    217217            results.append(int(vs / 60.0 * 0.3048 * 256))
    218218        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))
    220220        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))
    222222        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)))
    224224        elif offset==0x0574:  # Aircraft altitude in metres (whole part)
    225225            results.append(int(altitude*.3048))
     
    237237            centre_fuel = fuel_remaining - 2*side_tank_capacity
    238238            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)))
    240240        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)))
    242242        elif offset==0x0b7c or \
    243243             offset==0x0b94:  # Left and right main tank level (%*128*65536)
    244244            fuel = fuel_remaining/2
    245245            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)))
    247247        elif offset==0x0b80 or \
    248248             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)))
    250250        elif offset in [0x0b84, 0x0b88, 0x0b8c, 0x0b90,
    251251                        0x0b9c, 0x0ba0, 0x0ba4, 0x0ba8,
     
    253253                        0x1254, 0x1258, 0x125c, 0x1260]:
    254254                              # Other tank capacities and levels
    255             results.append(long(0))
     255            results.append(int(0))
    256256        elif offset==0x023a:  # Second of time
    257257            results.append(int(tm[5]))
  • src/mlx/pyuipc_sim.py

    r877 r919  
    11
    2 import const
     2from . import const
    33
    44import cmd
     
    99import sys
    1010import struct
    11 import cPickle
     11import pickle
    1212import math
    1313
     
    342342        try:
    343343            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)))
    346346            raise FSUIPCException(ERR_DATA)
    347347
     
    414414            return 1 if self.overspeed else 0
    415415        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)
    417417        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)
    419419        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)
    421421        elif offset==0x0578:       # Pitch
    422422            return int(self.pitch * 65536.0 * 65536.0 / 360.0)
     
    584584                    return value
    585585                else:
    586                     print "Unhandled offset: %04x" % (offset,)
     586                    print("Unhandled offset: %04x" % (offset,))
    587587                    raise FSUIPCException(ERR_DATA)
    588588            else:
    589                 print "Unhandled offset: %04x" % (offset,)
     589                print("Unhandled offset: %04x" % (offset,))
    590590                raise FSUIPCException(ERR_DATA)
    591591        elif offset==0x32fa:       # Message duration
     
    616616            return 0 if self.xpdrC else 1
    617617        else:
    618             print "Unhandled offset: %04x" % (offset,)
     618            print("Unhandled offset: %04x" % (offset,))
    619619            raise FSUIPCException(ERR_DATA)
    620620
     
    623623        try:
    624624            return self._write(offset, value, type)
    625         except TypeError, e:
     625        except TypeError as e:
    626626            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)))
    629629            raise FSUIPCException(ERR_DATA)
    630630
     
    852852                    hotkey[3] = (value>>24) & 0xff
    853853                else:
    854                     print "Unhandled offset: %04x for type '%s'" % (offset, type)
     854                    print("Unhandled offset: %04x for type '%s'" % (offset, type))
    855855                    raise FSUIPCException(ERR_DATA)
    856856            else:
    857                 print "Unhandled offset: %04x for type '%s'" % (offset, type)
     857                print("Unhandled offset: %04x for type '%s'" % (offset, type))
    858858                raise FSUIPCException(ERR_DATA)
    859859        elif offset==0x32fa:       # Message duration
     
    882882            self.xpdrC = value==0
    883883        else:
    884             print "Unhandled offset: %04x" % (offset,)
     884            print("Unhandled offset: %04x" % (offset,))
    885885            raise FSUIPCException(ERR_DATA)
    886886
     
    10391039                (length,) = struct.unpack("I", clientSocket.recv(4))
    10401040                data = clientSocket.recv(length)
    1041                 (call, args) = cPickle.loads(data)
     1041                (call, args) = pickle.loads(data)
    10421042                exception = None
    10431043
     
    10611061                    else:
    10621062                        break
    1063                 except Exception, e:
     1063                except Exception as e:
    10641064                    exception = e
    10651065
    10661066                if exception is None:
    1067                     data = cPickle.dumps((RESULT_RETURNED, result))
     1067                    data = pickle.dumps((RESULT_RETURNED, result))
    10681068                else:
    1069                     data = cPickle.dumps((RESULT_EXCEPTION, str(exception)))
     1069                    data = pickle.dumps((RESULT_EXCEPTION, str(exception)))
    10701070                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)
    10731073        finally:
    10741074            try:
     
    11121112    def quit(self):
    11131113        """Quit from the simulator."""
    1114         data = cPickle.dumps((CALL_QUIT, None))
     1114        data = pickle.dumps((CALL_QUIT, None))
    11151115        self._socket.send(struct.pack("I", len(data)) + data)
    11161116
    11171117    def _call(self, command, data):
    11181118        """Perform a call with the given command and data."""
    1119         data = cPickle.dumps((command, [data]))
     1119        data = pickle.dumps((command, [data]))
    11201120        self._socket.send(struct.pack("I", len(data)) + data)
    11211121        (length,) = struct.unpack("I", self._socket.recv(4))
    11221122        data = self._socket.recv(length)
    1123         (resultCode, result) = cPickle.loads(data)
     1123        (resultCode, result) = pickle.loads(data)
    11241124        if resultCode==RESULT_RETURNED:
    11251125            return result
     
    12341234                                           lambda value: value * 90.0 /
    12351235                                           10001750.0 / 65536.0 / 65536.0,
    1236                                            lambda word: long(float(word) *
     1236                                           lambda word: int(float(word) *
    12371237                                                             10001750.0 *
    12381238                                                             65536.0 * 65536.0 / 90.0))
     
    12401240                                            lambda value: value * 360.0 /
    12411241                                            65536.0 / 65536.0 / 65536.0 / 65536.0,
    1242                                             lambda word: long(float(word) *
     1242                                            lambda word: int(float(word) *
    12431243                                                              65536.0 * 65536.0 *
    12441244                                                              65536.0 * 65536.0 /
     
    13001300                                           const.FEETTOMETRES / 65536.0 /
    13011301                                           65536.0,
    1302                                            lambda word: long(float(word) *
     1302                                           lambda word: int(float(word) *
    13031303                                                             const.FEETTOMETRES *
    13041304                                                             65536.0 * 65536.0))
     
    14871487            self._valueHandlers["hotkey%d" % (i,)] = ([(0x3210 + i*4, "u")],
    14881488                                                      lambda value: "0x%08x" % (value,),
    1489                                                       lambda word: long(word, 16))
     1489                                                      lambda word: int(word, 16))
    14901490
    14911491        self._valueHandlers["cog"] = ([(0x2ef8, "f")], lambda value: value,
     
    15371537        """Handle unhandle commands."""
    15381538        if line=="EOF":
    1539             print
     1539            print()
    15401540            return self.do_quit("")
    15411541        else:
     
    15481548        for name in names:
    15491549            if name not in self._valueHandlers:
    1550                 print >> sys.stderr, "Unknown variable: " + name
     1550                print("Unknown variable: " + name, file=sys.stderr)
    15511551                return False
    15521552            valueHandler = self._valueHandlers[name]
     
    15651565                                        else thisResults)
    15661566
    1567                 print name + "=" + str(value)
     1567                print(name + "=" + str(value))
    15681568
    15691569                index += numResults
    15701570                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)
    15731573
    15741574        return False
     
    15761576    def help_get(self):
    15771577        """Print help for the get command."""
    1578         print "get <variable> [<variable>...]"
     1578        print("get <variable> [<variable>...]")
    15791579
    15801580    def complete_get(self, text, line, begidx, endidx):
     
    16081608            words = argument.split("=")
    16091609            if len(words)!=2:
    1610                 print >> sys.stderr, "Invalid argument: " + argument
     1610                print("Invalid argument: " + argument, file=sys.stderr)
    16111611                return False
    16121612
    16131613            (name, value) = words
    16141614            if name not in self._valueHandlers:
    1615                 print >> sys.stderr, "Unknown variable: " + name
     1615                print("Unknown variable: " + name, file=sys.stderr)
    16161616                return False
    16171617
     
    16251625                    data.append((offset, type, values[index]))
    16261626                    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)
    16301630                return False
    16311631
    16321632        try:
    16331633            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)
    16371637
    16381638        return False
     
    16401640    def help_set(self):
    16411641        """Print help for the set command."""
    1642         print "set <variable>=<value> [<variable>=<value>...]"
     1642        print("set <variable>=<value> [<variable>=<value>...]")
    16431643
    16441644    def complete_set(self, text, line, begidx, endidx):
     
    16541654            value = int(args)
    16551655            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)
    16591659
    16601660    def help_setversion(self, usage = False):
    16611661        """Help for the setversion command"""
    1662         if usage: print "Usage:",
    1663         print "setversion <number>"
     1662        if usage: print("Usage:", end=' ')
     1663        print("setversion <number>")
    16641664
    16651665    def do_close(self, args):
     
    16671667        try:
    16681668            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)
    16721672
    16731673    def do_failopen(self, args):
     
    16761676            value = self.str2bool(args)
    16771677            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)
    16811681
    16821682    def help_failopen(self, usage = False):
    16831683        """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")
    16861686
    16871687    def complete_failopen(self, text, line, begidx, endidx):
  • src/mlx/rpc.py

    r889 r919  
    1 import const
    2 import rpccommon
    3 
    4 from common import MAVA_BASE_URL
     1from . import const
     2from . import rpccommon
     3
     4from .common import MAVA_BASE_URL
    55
    66import jsonrpclib
     
    2828        For all other names, the value will be stored as the same-named
    2929        attribute."""
    30         for (key, value) in value.iteritems():
     30        for (key, value) in value.items():
    3131            if key in instructions:
    3232                instruction = instructions[key]
     
    3737                    value = instruction(value)
    3838                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)
    4141                    import traceback
    4242                    traceback.print_exc()
     
    297297    def writeIntoFile(self, f):
    298298        """Write the flight into a file."""
    299         print >> f, "callsign=%s" % (self.callsign,)
     299        print("callsign=%s" % (self.callsign,), file=f)
    300300        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)
    314314        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)
    317317        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)
    321321
    322322#---------------------------------------------------------------------------------------
  • src/mlx/rpccommon.py

    r742 r919  
    33#------------------------------------------------------------------------------
    44
    5 import const
     5from . import const
    66
    77#------------------------------------------------------------------------------
     
    5151        """Check if the gate of the given plane conflicts with another plane's
    5252        position."""
    53         for p in self._planes.itervalues():
     53        for p in self._planes.values():
    5454            if p.tailNumber!=plane.tailNumber and \
    5555               p.status==const.PLANE_HOME and \
     
    6262        """Get a set containing the numbers of the gates occupied by planes."""
    6363        gateNumbers = set()
    64         for p in self._planes.itervalues():
     64        for p in self._planes.values():
    6565            if p.status==const.PLANE_HOME and p.gateNumber:
    6666                gateNumbers.add(p.gateNumber)
     
    8080    def __iter__(self):
    8181        """Get an iterator over the planes."""
    82         for plane in self._planes.itervalues():
     82        for plane in self._planes.values():
    8383            yield plane
    8484
  • src/mlx/singleton.py

    r401 r919  
    11
    2 from util import utf2unicode
     2from .util import utf2unicode
    33
    44import os
     
    5959                        break
    6060
    61                     print "singleton._PipeServer.run: created the pipe"
     61                    print("singleton._PipeServer.run: created the pipe")
    6262                    try:
    6363                        if win32pipe.ConnectNamedPipe(handle)==0:
    64                             print "singleton._PipeServer.run: client connection received"
     64                            print("singleton._PipeServer.run: client connection received")
    6565                            (code, message) = \
    6666                                win32file.ReadFile(handle,
     
    6969
    7070                            if code==0:
    71                                 print "singleton._PipeServer.run: message received from client"
     71                                print("singleton._PipeServer.run: message received from client")
    7272                                self._raiseCallback()
    7373                            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)))
    7878                    finally:
    7979                        win32pipe.DisconnectNamedPipe(handle)
    8080                        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)))
    8484                           
    8585        def _createPipe(self):
     
    9696                                               None)
    9797            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")
    9999                return None
    100100            else:
     
    144144                    f.close()
    145145                    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)))
    149149                    time.sleep(0.5)
    150150       
    151         def __nonzero__(self):
     151        def __bool__(self):
    152152            """Return a boolean representation of the object.
    153153
     
    194194                    s.recv(64)
    195195                    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)))
    199199   
    200200    class SingleInstance(object):
     
    218218                fcntl.lockf(self._lockFile, fcntl.LOCK_EX | fcntl.LOCK_NB)
    219219                self._isSingle = True
    220             except Exception, e:
     220            except Exception as e:
    221221                self._lockFile.close()
    222222                self._lockFile = None
     
    259259                    s.close()
    260260                    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)))
    264264                    time.sleep(0.5)
    265265
    266         def __nonzero__(self):
     266        def __bool__(self):
    267267            """Return a boolean representation of the object.
    268268
     
    299299if __name__=="__main__":
    300300    def raiseCallback():
    301         print "Raise the window!"
     301        print("Raise the window!")
    302302
    303303    instance = SingleInstance("mlx", raiseCallback)
    304304    if instance:
    305         print "The first instance"
     305        print("The first instance")
    306306        time.sleep(10)
    307307    else:
    308         print "The program is already running."
    309 
     308        print("The program is already running.")
     309
  • src/mlx/sound.py

    r800 r919  
    11
    2 from util import utf2unicode
     2from .util import utf2unicode
    33
    44import os
     
    113113                    success = True
    114114                    try:
    115                         print "Closing", alias
     115                        print("Closing", alias)
    116116                        self._mci.send("close " + alias)
    117                         print "Closed", alias
    118                     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)))
    121121                        success = False
    122122
     
    130130                    try:
    131131                        alias = "mlxsound%d" % (counter,)
    132                         print "Starting to play", path, "as", alias
     132                        print("Starting to play", path, "as", alias)
    133133                        self._mci.send("open \"%s\" alias %s" % \
    134134                                       (path, alias))
     
    144144                            self._pending.append((timeout, (alias, finishData)))
    145145                            self._pending.sort()
    146                         print "Started to play", path
    147                     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)))
    150150                        (finishCallback, extra) = finishData
    151151                        if finishCallback is not None:
     
    220220
    221221            Gst.init(None)
    222         except Exception, e:
     222        except Exception as e:
    223223            outQueue.put(False)
    224224            outQueue.put(e)
     
    351351        else:
    352352            exception = _inQueue.get()
    353             print "The Gst library is missing from your system. It is needed for sound playback on Linux:"
    354             print exception
     353            print("The Gst library is missing from your system. It is needed for sound playback on Linux:")
     354            print(exception)
    355355
    356356    def startSound(name, finishCallback = None, extra = None):
     
    387387
    388388    def callback(result, extra):
    389         print "callback", result, extra
     389        print("callback", result, extra)
    390390
    391391    preInitializeSound()
     
    393393    soundsPath = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
    394394                                              "..", "..", "sounds"))
    395     print "soundsPath:", soundsPath
     395    print("soundsPath:", soundsPath)
    396396    initializeSound(soundsPath)
    397397    startSound("notam.mp3", finishCallback = callback, extra= "notam.mp3")
  • src/mlx/soundsched.py

    r352 r919  
    11
    2 from sound import startSound
    3 import const
    4 import fs
     2from .sound import startSound
     3from . import const
     4from . import fs
    55
    66import threading
     
    6464        """Called when the playback of thee sound has finished (or failed)."""
    6565        if success is None:
    66             print "Failed to start sound", self._name
     66            print("Failed to start sound", self._name)
    6767        elif not success:
    68             print "Failed to finish sound", self._name
     68            print("Failed to finish sound", self._name)
    6969        with Sound._lock:           
    7070            self._playing -= 1
  • src/mlx/test.py

    r27 r919  
    11# Test module
    22
    3 import fs
    4 import flight
    5 import logger
    6 import acft
    7 import const
     3from . import fs
     4from . import flight
     5from . import logger
     6from . import acft
     7from . import const
    88
    99import time
     
    1111
    1212def callback(data, extra):
    13     print data
     13    print(data)
    1414
    1515def main():
  • src/mlx/update.py

    r788 r919  
    11
    2 from config import Config
    3 from util import utf2unicode
     2from .config import Config
     3from .util import utf2unicode
    44
    55import os
    66import sys
    7 import urllib2
     7import urllib.request, urllib.error, urllib.parse
    88import tempfile
    99import socket
     
    5757
    5858        Each file is returned as a 3-tuple with items as in the file."""
    59         for (path, (size, sum)) in self._files.iteritems():
     59        for (path, (size, sum)) in self._files.items():
    6060            yield (path, size, sum)
    6161
     
    9999    def writeInto(self, file):
    100100        """Write the manifest into the file at the given path."""
    101         for (path, (size, sum)) in self._files.iteritems():
     101        for (path, (size, sum)) in self._files.items():
    102102            file.write("%s\t%d\t%s\n" % (path, size, sum))
    103103
     
    207207        with open(manifestPath, "rt") as f:
    208208            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)))
    211211        manifest = Manifest()
    212212
     
    226226    try:
    227227        updateManifest = Manifest()
    228         f= urllib2.urlopen(updateURL + "/" + manifestName)
     228        f= urllib.request.urlopen(updateURL + "/" + manifestName)
    229229        updateManifest.readFrom(f)
    230230
    231     except Exception, e:
     231    except Exception as e:
    232232        error = utf2unicode(str(e))
    233         print >> sys.stderr, "Error downloading manifest:", error
     233        print("Error downloading manifest:", error, file=sys.stderr)
    234234        listener.failed(error)
    235235        return None
     
    298298                pass
    299299            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)))
    302302
    303303#------------------------------------------------------------------------------
     
    359359               
    360360            with open(targetFile, "wb") as fout:
    361                 fin = urllib2.urlopen(updateURL + "/" + path)
     361                fin = urllib.request.urlopen(updateURL + "/" + path)
    362362                while True:
    363363                    data = fin.read(4096)
     
    391391       
    392392        listener.done()
    393     except Exception, e:
     393    except Exception as e:
    394394        exc = traceback.format_exc()
    395         print >> sys.stderr, utf2unicode(exc)
     395        print(utf2unicode(exc), file=sys.stderr)
    396396       
    397397        error = utf2unicode(str(e))
    398         print >> sys.stderr, "Error:", error
     398        print("Error:", error, file=sys.stderr)
    399399
    400400        listener.failed(error)
     
    409409        f.close()
    410410        return True
    411     except Exception, e:
     411    except Exception as e:
    412412        return False
    413413    finally:
     
    439439                listener.downloadedManifest()
    440440            elif command=="setTotalSize":
    441                 listener.setTotalSize(int(words[1]), long(words[2]),
     441                listener.setTotalSize(int(words[1]), int(words[2]),
    442442                                      int(words[3]), int(words[4]))
    443443            elif command=="setDownloaded":
    444                 listener.setDownloaded(long(words[1]))
     444                listener.setDownloaded(int(words[1]))
    445445            elif command=="startRenaming":
    446446                listener.startRenaming()
     
    457457            elif command=="failed":
    458458                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)
    462462
    463463    return buffer
     
    514514            process.wait()
    515515       
    516     except Exception, e:
     516    except Exception as e:
    517517        error = utf2unicode(str(e))
    518         print >> sys.stderr, "Failed updating:", error
     518        print("Failed updating:", error, file=sys.stderr)
    519519        listener.failed(error)
    520520    finally:
     
    563563            updateFiles(directory, updateURL, listener, updateManifest,
    564564                        modifiedAndNew, removed, localRemoved)
    565     except Exception, e:
     565    except Exception as e:
    566566        exc = traceback.format_exc()
    567         print >> sys.stderr, utf2unicode(exc)
     567        print(utf2unicode(exc), file=sys.stderr)
    568568       
    569569        error = utf2unicode(str(e))
    570         print >> sys.stderr, "Update error:", error
     570        print("Update error:", error, file=sys.stderr)
    571571       
    572572        listener.failed(error)
     
    596596    except:
    597597        exc = traceback.format_exc()
    598         print >> sys.stderr, utf2unicode(exc)
     598        print(utf2unicode(exc), file=sys.stderr)
    599599
    600600#------------------------------------------------------------------------------
  • src/mlx/util.py

    r784 r919  
    4343#------------------------------------------------------------------------------
    4444
    45 def getCoordinateString((latitude, longitude)):
     45def getCoordinateString(xxx_todo_changeme):
    4646    """Get the string representation of the given coordinate pair."""
    47 
     47    (latitude, longitude) = xxx_todo_changeme
    4848    latitude_str = getLatitudeString(latitude)
    4949    longitude_str = getLongitudeString(longitude)
     
    7979    (deg, min, sec, _sign) = getDegMinSec(degree)
    8080
    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)
    8282
    8383#------------------------------------------------------------------------------
     
    175175    """Convert the given text from UTF-8 encoding to unicode."""
    176176    try:
    177         return unicode(_utf8decoder(text)[0])
     177        return str(_utf8decoder(text)[0])
    178178    except:
    179179        try:
    180             return unicode(_latin2decoder(text)[0])
     180            return str(_latin2decoder(text)[0])
    181181        except:
    182             return unicode(list(text))
     182            return str(list(text))
  • src/mlx/watchdog.py

    r535 r919  
    6060
    6161        if logTimeout:
    62             print "Watchdog client %s has timed out!" % (self._name)
     62            print("Watchdog client %s has timed out!" % (self._name))
    6363        elif logCleared:
    64             print "Watchdog client %s has been cleared." % (self._name)
     64            print("Watchdog client %s has been cleared." % (self._name))
    6565
    6666#-----------------------------------------------------------------------------
     
    115115
    116116            if t>=nextLogTime:
    117                 print "Watchdog.run: running"
     117                print("Watchdog.run: running")
    118118                while t>=nextLogTime:
    119119                    nextLogTime += self.LOG_INTERVAL
  • src/mlx/web.py

    r859 r919  
    11
    2 import const
    3 import util
    4 from rpc import Registration
    5 import rpc
    6 import rpccommon
    7 
    8 from common import MAVA_BASE_URL
    9 from pirep import PIREP
     2from . import const
     3from . import util
     4from .rpc import Registration
     5from . import rpc
     6from . import rpccommon
     7
     8from .common import MAVA_BASE_URL
     9from .pirep import PIREP
    1010
    1111import threading
    1212import sys
    13 import urllib
    14 import urllib2
     13import urllib.request, urllib.parse, urllib.error
     14import urllib.request, urllib.error, urllib.parse
    1515import hashlib
    1616import time
     
    1919import traceback
    2020import xml.sax
    21 import xmlrpclib
    22 import HTMLParser
     21import xmlrpc.client
     22import html.parser
    2323
    2424#---------------------------------------------------------------------------------------
     
    160160
    161161        date = readline(f)
    162         print "web.BookedFlight.readFromWeb: date:", date
     162        print("web.BookedFlight.readFromWeb: date:", date)
    163163        if date=="0000-00-00": date = "0001-01-01"
    164164
     
    233233
    234234                if not lineOK:
    235                     print "web.BookedFlight.readFromFile: line %d is invalid" % \
    236                           (lineNumber,)
     235                    print("web.BookedFlight.readFromFile: line %d is invalid" % \
     236                          (lineNumber,))
    237237
    238238            line = f.readline()
     
    290290    def writeIntoFile(self, f):
    291291        """Write the flight into a file."""
    292         print >> f, "callsign=%s" % (self.callsign,)
     292        print("callsign=%s" % (self.callsign,), file=f)
    293293        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)
    307307        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)
    310310        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)
    314314
    315315    def _readAircraftType(self, f):
     
    364364
    365365        except:
    366             print >> sys.stderr, "Plane string is invalid: '" + s + "'"
     366            print("Plane string is invalid: '" + s + "'", file=sys.stderr)
    367367            self.tailNumber = None
    368368
     
    470470#------------------------------------------------------------------------------
    471471
    472 class PilotsWebNOTAMsParser(HTMLParser.HTMLParser):
     472class PilotsWebNOTAMsParser(html.parser.HTMLParser):
    473473    """XML handler for the NOTAM query results on the PilotsWeb website."""
    474474    def __init__(self):
    475475        """Construct the handler."""
    476         HTMLParser.HTMLParser.__init__(self)
     476        html.parser.HTMLParser.__init__(self)
    477477
    478478        self._notams = []
     
    513513        try:
    514514            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))
    517517
    518518        if notam is None:
    519             print "Could not parse NOTAM: " + self._currentNOTAM
     519            print("Could not parse NOTAM: " + self._currentNOTAM)
    520520            if self._currentNOTAM:
    521521                self._notams.append(self._currentNOTAM + "\n")
     
    526526        """Parse the current NOTAM, if possible, and return a NOTAM object."""
    527527        lines = self._currentNOTAM.splitlines()
    528         lines = map(lambda line: line.strip(), lines)
     528        lines = [line.strip() for line in lines]
    529529
    530530        if len(lines)<4:
     
    579579        """Parse the current NOTAM with a second, more flexible method."""
    580580        lines = self._currentNOTAM.splitlines()
    581         lines = map(lambda line: line.strip(), lines)
     581        lines = [line.strip() for line in lines]
    582582
    583583        if not lines:
     
    592592                lines = lines[:-1]
    593593
    594         lines = map(lambda line: line.strip(), lines)
     594        lines = [line.strip() for line in lines]
    595595        contents = " ".join(lines).split()
    596596
     
    653653        """Get a representation of the result."""
    654654        s = "<Result:"
    655         for (key, value) in self.__dict__.iteritems():
    656             s += " " + key + "=" + unicode(value)
     655        for (key, value) in self.__dict__.items():
     656            s += " " + key + "=" + str(value)
    657657        s += ">"
    658658        return s
     
    688688            result = self.run()
    689689            returned = True
    690         except Exception, e:
     690        except Exception as e:
    691691            traceback.print_exc()
    692692            result = e
     
    695695        try:
    696696            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)
    699699            #traceback.print_exc()
    700700
     
    769769        result = Result()
    770770
    771         f = urllib2.urlopen(url, timeout = 10.0)
     771        f = urllib.request.urlopen(url, timeout = 10.0)
    772772
    773773        status = readline(f)
     
    880880        url = MAVA_BASE_URL + "/onlinegates_get.php"
    881881
    882         f = urllib2.urlopen(url, timeout = 10.0)
     882        f = urllib.request.urlopen(url, timeout = 10.0)
    883883        result = Result()
    884884        result.fleet = Fleet(f)
     
    922922        gateNumber = self._gateNumber if self._gateNumber else ""
    923923
    924         data = urllib.urlencode([("lajstrom", self._tailNumber),
     924        data = urllib.parse.urlencode([("lajstrom", self._tailNumber),
    925925                                 ("status", status),
    926926                                 ("kapu", gateNumber)])
    927927
    928         f = urllib2.urlopen(url, data, timeout = 10.0)
     928        f = urllib.request.urlopen(url, data, timeout = 10.0)
    929929        line = readline(f)
    930930
     
    983983            url = "http://notams.euroutepro.com/notams.xml"
    984984
    985             f = urllib2.urlopen(url, timeout = 10.0)
     985            f = urllib.request.urlopen(url, timeout = 10.0)
    986986            try:
    987987                xmlParser.parse(f)
     
    10121012              (icao.upper(),)
    10131013
    1014             f = urllib2.urlopen(url, timeout = 10.0)
     1014            f = urllib.request.urlopen(url, timeout = 10.0)
    10151015            try:
    10161016                data = f.read(16384)
     
    10231023            return parser.getNOTAMs()
    10241024
    1025         except Exception, e:
     1025        except Exception as e:
    10261026            traceback.print_exc()
    1027             print "mlx.web.GetNOTAMs.getPilotsWebNOTAMs: failed to get NOTAMs for '%s': %s" % \
    1028                   (icao, str(e))
     1027            print("mlx.web.GetNOTAMs.getPilotsWebNOTAMs: failed to get NOTAMs for '%s': %s" % \
     1028                  (icao, str(e)))
    10291029            return None
    10301030
     
    10421042        """Perform the retrieval opf the METARs."""
    10431043        url = "http://www.aviationweather.gov/adds/dataserver_current/httpparam?"
    1044         data = urllib.urlencode([ ("dataSource" , "metars"),
     1044        data = urllib.parse.urlencode([ ("dataSource" , "metars"),
    10451045                                  ("requestType",  "retrieve"),
    10461046                                  ("format", "csv"),
     
    10491049                                  ("mostRecentForEachStation", "constraint")])
    10501050        url += data
    1051         f = urllib2.urlopen(url, timeout = 10.0)
     1051        f = urllib.request.urlopen(url, timeout = 10.0)
    10521052        try:
    10531053            result = Result()
     
    11281128        data["insdate"] = datetime.date.today().strftime("%Y-%m-%d")
    11291129
    1130         postData = urllib.urlencode(data)
    1131         f = urllib2.urlopen(url, postData, timeout = 10.0)
     1130        postData = urllib.parse.urlencode(data)
     1131        f = urllib.request.urlopen(url, postData, timeout = 10.0)
    11321132        try:
    11331133            result = Result()
    11341134            line = f.readline().strip()
    1135             print "PIREP result from website:", line
     1135            print("PIREP result from website:", line)
    11361136            result.success = line=="OK"
    11371137            result.alreadyFlown = line=="MARVOLT"
     
    11781178    def run(self):
    11791179        """Perform the sending of the ACARS."""
    1180         print "Sending the online ACARS"
     1180        print("Sending the online ACARS")
    11811181
    11821182        url = MAVA_BASE_URL  + "/acars2/acarsonline.php"
     
    12041204        data["event"] = acars.getEventText()
    12051205
    1206         f = urllib2.urlopen(url, urllib.urlencode(data), timeout = 10.0)
     1206        f = urllib.request.urlopen(url, urllib.parse.urlencode(data), timeout = 10.0)
    12071207        try:
    12081208            result = Result()
     
    12231223    def run(self):
    12241224        """Perform the sending of the ACARS."""
    1225         print "Sending the online ACARS via JSON-RPC"
     1225        print("Sending the online ACARS via JSON-RPC")
    12261226
    12271227        self._client.updateOnlineACARS(self._acars)
     
    12431243    def run(self):
    12441244        """Perform the sending of the bug report."""
    1245         serverProxy = xmlrpclib.ServerProxy("http://mlx.varadiistvan.hu/rpc")
     1245        serverProxy = xmlrpc.client.ServerProxy("http://mlx.varadiistvan.hu/rpc")
    12461246
    12471247        result = Result()
     
    12541254        result.ticketID = serverProxy.ticket.create(self._summary, self._description,
    12551255                                                    attributes, True)
    1256         print "Created ticket with ID:", result.ticketID
     1256        print("Created ticket with ID:", result.ticketID)
    12571257        result.success = True
    12581258
     
    12881288
    12891289        pirepData = self._client.getPIREP(self._flightID)
    1290         print "pirepData:", pirepData
     1290        print("pirepData:", pirepData)
    12911291
    12921292        bookedFlight = BookedFlight(self._flightID)
     
    15121512
    15131513    def callback(returned, result):
    1514         print returned, unicode(result)
     1514        print(returned, str(result))
    15151515
    15161516    handler = Handler()
  • src/mlx/xplane.py

    r909 r919  
    11
    2 import fs
    3 import const
    4 import util
    5 from watchdog import Watchdog
     2from . import fs
     3from . import const
     4from . import util
     5from .watchdog import Watchdog
    66
    77import threading
     
    106106            else:
    107107                return False
    108         except ProtocolException, e:
     108        except ProtocolException as e:
    109109            self._result = None
    110110            return True
     
    241241        try:
    242242            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)
    245245            return None
    246246
     
    312312            try:
    313313                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))
    316316                raise
    317317
     
    514514                self._connected = True
    515515                return attempts
    516             except Exception, e:
    517                 print "xplane.Handler._connect: connection failed: " + \
     516            except Exception as e:
     517                print("xplane.Handler._connect: connection failed: " + \
    518518                      util.utf2unicode(str(e)) + \
    519                       " (attempts: %d)" % (attempts,)
     519                      " (attempts: %d)" % (attempts,))
    520520                if attempts<self.NUM_CONNECTATTEMPTS:
    521521                    time.sleep(self.CONNECT_INTERVAL)
     
    549549    def _disconnect(self):
    550550        """Disconnect from the flight simulator."""
    551         print "xplane.Handler._disconnect"
     551        print("xplane.Handler._disconnect")
    552552        if self._connected:
    553553            try:
     
    578578            try:
    579579                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")
    581581                    needReconnect = True
    582582            except Exception as e:
    583                 print "xplane.Handler._processRequest: X-Plane connection failed (" + \
     583                print("xplane.Handler._processRequest: X-Plane connection failed (" + \
    584584                      util.utf2unicode(str(e)) + \
    585                       "), reconnecting (attempts=%d)." % (attempts,)
     585                      "), reconnecting (attempts=%d)." % (attempts,))
    586586                needReconnect = True
    587587
     
    804804
    805805        duration is the number of seconds to keep the message displayed."""
    806         print "xplra.Simulator.sendMessage:", message
     806        print("xplra.Simulator.sendMessage:", message)
    807807        self._handler.requestShowMessage(message, duration,
    808808                                         self._handleMessageSent,
     
    887887        assert not self._monitoringRequested
    888888
    889         print "xplra.Simulator.disconnect", closingMessage, duration
     889        print("xplra.Simulator.disconnect", closingMessage, duration)
    890890
    891891        self._stopNormal()
     
    938938        if self._lastZuluSeconds is not None and \
    939939           zuluSeconds<self._lastZuluSeconds:
    940             print "xplane.Simulator._getTimestamp: Zulu seconds have gone backwards (%f -> %f), increasing day offset" % \
    941               (self._lastZuluSeconds, zuluSeconds)
     940            print("xplane.Simulator._getTimestamp: Zulu seconds have gone backwards (%f -> %f), increasing day offset" % \
     941              (self._lastZuluSeconds, zuluSeconds))
    942942            self._timestampDaysOffset += 1
    943943
     
    10161016            return False
    10171017
    1018         print "xplane.Simulator: new data: %s, %s, %s, %s, %s, %s" % \
    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))
    10201020
    10211021        self._aircraftInfo = aircraftInfo
     
    11401140            self._handler.disconnect()
    11411141
    1142     def _handleHotkeysRegistered(self, success, (id, generation)):
     1142    def _handleHotkeysRegistered(self, success, xxx_todo_changeme2):
    11431143        """Handle the result of the hotkeys having been written."""
     1144        (id, generation) = xxx_todo_changeme2
    11441145        with self._hotkeyLock:
    11451146            if success and id==self._hotkeySetID and \
     
    11501151                                                    (id, generation))
    11511152
    1152     def _handleHotkeys(self, data, (id, generation)):
     1153    def _handleHotkeys(self, data, xxx_todo_changeme3):
    11531154        """Handle the hotkeys."""
     1155        (id, generation) = xxx_todo_changeme3
    11541156        with self._hotkeyLock:
    11551157            if id!=self._hotkeySetID or generation!=self._hotkeySetGeneration:
     
    16171619                              [level * self._fuelTankCapacities[index]]) )
    16181620            except:
    1619                 print "xplane.Simulator.setFuelLevel: invalid tank constant: %d" % \
    1620                   (tank,)
     1621                print("xplane.Simulator.setFuelLevel: invalid tank constant: %d" % \
     1622                  (tank,))
    16211623
    16221624        handler.requestWrite(data, self._handleFuelWritten)
     
    17481750    """Model handler for the FlyJSim Dash 8-Q400."""
    17491751    @staticmethod
    1750     def doesHandle(aircraft, (tailnum, author, description, notes,
    1751                               icao, liveryPath)):
     1752    def doesHandle(aircraft, xxx_todo_changeme):
    17521753        """Determine if this model handler handles the aircraft with the given
    17531754        name."""
     1755        (tailnum, author, description, notes,
     1756                              icao, liveryPath) = xxx_todo_changeme
    17541757        return aircraft.type==const.AIRCRAFT_DH8D and \
    17551758          description.find("Dash 8 Q400")!=-1 and \
     
    19091912    """Model for Felis' Tupolev Tu-154-M aircraft."""
    19101913    @staticmethod
    1911     def doesHandle(aircraft, (tailnum, author, description, notes,
    1912                               icao, liveryPath)):
     1914    def doesHandle(aircraft, xxx_todo_changeme1):
    19131915        """Determine if this model handler handles the aircraft with the given
    19141916        name."""
     1917        (tailnum, author, description, notes,
     1918                              icao, liveryPath) = xxx_todo_changeme1
    19151919        return aircraft.type==const.AIRCRAFT_T154 and \
    19161920          author.find("Felis")!=-1 and \
Note: See TracChangeset for help on using the changeset viewer.