Changeset 36:f79362793664


Ignore:
Timestamp:
03/04/12 06:27:05 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Update seems to work

Files:
5 added
7 edited

Legend:

Unmodified
Added
Removed
  • MANIFEST.in

    r28 r36  
    33include license.txt
    44include runmlx.py
     5include mlxupdate.py
    56include logo.ico
    67include logo_uninst.ico
  • runmlx.py

    r33 r36  
    11# Script to run the logger
    2 
    3 import os
    4 import sys
    52
    63if __name__ == "__main__":
    74    import mlx.mlx
    8     mlx.mlx.main(os.path.dirname(sys.argv[0]))
     5    mlx.mlx.main()
  • runmlx.sh

    r29 r36  
    33scriptdir=`dirname $0`
    44
    5 PYTHONPATH="${scriptdir}/src:${PYTHONPATH}"
     5PYTHONPATH="${scriptdir}/src:${scriptdir}:${PYTHONPATH}"
    66export PYTHONPATH
    77
  • setup.py

    r28 r36  
    4949      requires = ["pyuipc"],
    5050      windows = [{ "script" : "runmlx.py",
    51                    "icon_resources" : [(1, "logo.ico")]}],
     51                   "icon_resources" : [(1, "logo.ico")]},
     52                 { "script" : "mlxupdate.py",
     53                   "uac_info" : "requireAdministrator"}],
    5254      options = { "py2exe" : { "includes": "gio, pango, atk, pangocairo"} },
    5355      data_files = data_files,
  • src/mlx/const.py

    r34 r36  
    44
    55# The version of the program
    6 VERSION="0.003"
     6VERSION="0.004"
    77
    88#-------------------------------------------------------------------------------
  • src/mlx/gui/gui.py

    r35 r36  
    33from statusicon import StatusIcon
    44from statusbar import Statusbar
     5from update import Updater
    56from mlx.gui.common import *
    67
     
    3132class GUI(fs.ConnectionListener):
    3233    """The main GUI class."""
    33     def __init__(self):
     34    def __init__(self, programDirectory, config):
    3435        """Construct the GUI."""
    3536        gobject.threads_init()
    3637
     38        self._programDirectory = programDirectory
     39        self._config = config
    3740        self._connecting = False
    3841        self._connected = False
     
    4043        self._flight = None
    4144        self._simulator = None
     45        self._stdioAfterNewLine = True
    4246
    4347    def build(self, iconDirectory):
    4448        """Build the GUI."""
    4549       
    46         win = gtk.Window()
    47         win.set_title("MAVA Logger X " + const.VERSION)
    48         win.set_icon_from_file("logo.ico")
    49         win.connect("delete-event",
    50                     lambda a, b: self.hideMainWindow())
    51         win.connect("window-state-event", self._handleMainWindowState)
     50        window = gtk.Window()
     51        window.set_title("MAVA Logger X " + const.VERSION)
     52        window.set_icon_from_file(os.path.join(iconDirectory, "logo.ico"))
     53        window.connect("delete-event",
     54                       lambda a, b: self.hideMainWindow())
     55        window.connect("window-state-event", self._handleMainWindowState)
    5256
    5357        mainVBox = gtk.VBox()
    54         win.add(mainVBox)
     58        window.add(mainVBox)
    5559
    5660        setupFrame = self._buildSetupFrame()
     
    7175        mainVBox.pack_start(self._statusbar, False, False, 0)
    7276
    73         win.show_all()       
    74 
    75         self._mainWindow = win
     77        window.show_all()       
     78
     79        self._mainWindow = window
    7680
    7781        self._statusIcon = StatusIcon(iconDirectory, self)
     
    7983    def run(self):
    8084        """Run the GUI."""
     85        if self._config.autoUpdate:
     86            self._updater = Updater(self._programDirectory,
     87                                    self._config.updateURL,
     88                                    self._mainWindow)
     89            self._updater.start()
     90
    8191        gtk.main()
     92
    8293        if self._flight is not None:
    8394            simulator = self._flight.simulator
     
    173184        else:
    174185            self.showMainWindow()
     186
     187    def writeStdIO(self, text):
     188        """Write the given text into standard I/O log."""
     189        gobject.idle_add(self._writeStdIO, text)
     190
     191    def _writeStdIO(self, text):
     192        """Perform the real writing."""
     193        lines = text.splitlines()
     194        if text[-1]=="\n":
     195            text = ""
     196        else:
     197            text = lines[-1]
     198            lines = lines[:-1]
     199           
     200        for line in lines:
     201            if self._stdioAfterNewLine:
     202                line = "[STDIO] " + line
     203            self._writeLog(line + "\n")
     204            self._stdioAfterNewLine = True
     205
     206        if text:
     207            if self._stdioAfterNewLine:
     208                text = "[STDIO] " + text
     209            self._writeLog(text)
     210            self._stdioAfterNewLine = False
    175211           
    176212    def _connectToggled(self, button):
  • src/mlx/mlx.py

    r29 r36  
    22
    33from .gui.gui import GUI
    4 from .gui.common import *
     4
     5from config import Config
    56
    67import os
     8import sys
    79
    8 def main(iconDirectory):
     10#--------------------------------------------------------------------------------------
     11
     12class StdIOHandler(object):
     13    """Handler for the standard I/O messages."""
     14    def __init__(self, gui):
     15        """Construct the handler."""
     16        self._gui = gui
     17
     18    def write(self, text):
     19        """Write the given text into the log."""
     20        self._gui.writeStdIO(text)
     21
     22#--------------------------------------------------------------------------------------
     23
     24def main():
    925    """The main operation of the program."""
    10     gui = GUI()
     26    programDirectory = os.path.dirname(sys.argv[0])
    1127
    12     gui.build(iconDirectory)
     28    config = Config()
     29    gui = GUI(programDirectory, config)
     30
     31    sys.stdout = StdIOHandler(gui)
     32    sys.stderr = StdIOHandler(gui)
     33
     34    gui.build(programDirectory)
    1335
    1436    gui.run()
    1537
     38#--------------------------------------------------------------------------------------
     39
    1640if __name__ == "__main__":
    17     main(os.path.dirname(__file__))
    18 
    19 
     41    main()
Note: See TracChangeset for help on using the changeset viewer.