Changeset 373:cf2b6b8a3973 for src/mlx
- Timestamp:
- 12/18/12 10:08:43 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/config.py
r298 r373 2 2 3 3 import const 4 from util import secondaryInstallation 4 5 5 6 import os 6 7 import sys 8 import traceback 7 9 import ConfigParser 8 10 9 11 ## @package mlx.config 10 # 12 # 11 13 # The handling of the configuration. 12 14 # … … 22 24 23 25 configPath = os.path.join(os.path.expanduser("~"), 24 "mlx.config" if os.name=="nt" else ".mlxrc") 26 "mlx.config" if os.name=="nt" else ".mlxrc") + \ 27 ("-secondary" if secondaryInstallation else "") 25 28 26 29 #------------------------------------------------------------------------------- … … 54 57 """Check if the given hotkey is not equal to the other one.""" 55 58 return not self==other 56 59 57 60 def __str__(self): 58 61 """Construct the hotkey to a string.""" … … 69 72 # The name of the section of the checklists 70 73 SECTION="checklists" 71 74 72 75 @staticmethod 73 76 def fromConfig(config, aircraftType): … … 108 111 """Determine if the checklist is not equal to the given other one.""" 109 112 return not self==other 110 113 111 114 def __len__(self): 112 115 """Get the length of the file list.""" … … 127 130 # The name of the section of the approach callouts 128 131 SECTION="callouts" 129 132 130 133 @staticmethod 131 134 def fromConfig(config, aircraftType): … … 145 148 break 146 149 147 return ApproachCallouts(mapping) 150 return ApproachCallouts(mapping) 148 151 149 152 def __init__(self, mapping = None): … … 211 214 212 215 _messageTypesSection = "messageTypes" 213 216 214 217 def __init__(self): 215 218 """Construct the configuration with default values.""" … … 222 225 self._hideMinimizedWindow = True 223 226 self._quitOnClose = False 224 self._onlineGateSystem = True225 self._onlineACARS = True227 self._onlineGateSystem = not secondaryInstallation 228 self._onlineACARS = not secondaryInstallation 226 229 self._flareTimeFromFS = False 227 230 self._syncFSTime = False … … 232 235 self._pirepDirectory = None 233 236 234 self._enableSounds = True237 self._enableSounds = not secondaryInstallation 235 238 236 239 self._pilotControlsSounds = True … … 242 245 self._enableChecklists = False 243 246 self._checklistHotkey = Hotkey(ctrl = True, shift = True, key = "0") 244 245 self._autoUpdate = True 247 248 self._autoUpdate = True 246 249 self._updateURL = Config.DEFAULT_UPDATE_URL 250 if secondaryInstallation: 251 self._updateURL += "/exp" 247 252 248 253 self._messageTypeLevels = {} … … 253 258 self._checklists[aircraftType] = Checklist() 254 259 self._approachCallouts[aircraftType] = ApproachCallouts() 255 260 256 261 self._modified = False 257 262 … … 315 320 self._hideMinimizedWindow = hideMinimizedWindow 316 321 self._modified = True 317 322 318 323 @property 319 324 def quitOnClose(self): … … 329 334 self._quitOnClose = quitOnClose 330 335 self._modified = True 331 336 332 337 @property 333 338 def onlineGateSystem(self): … … 462 467 return level==const.MESSAGELEVEL_FS or \ 463 468 level==const.MESSAGELEVEL_BOTH 464 469 465 470 def setMessageTypeLevel(self, messageType, level): 466 471 """Set the level of the given message type.""" … … 482 487 self._modified = True 483 488 484 @property 489 @property 485 490 def pilotControlsSounds(self): 486 491 """Get whether the pilot controls the background sounds.""" … … 529 534 self._speedbrakeAtTD = speedbrakeAtTD 530 535 self._modified = True 531 536 532 537 @property 533 538 def enableChecklists(self): … … 600 605 def load(self): 601 606 """Load the configuration from its default location.""" 602 config = ConfigParser.RawConfigParser() 603 config.read(configPath) 607 try: 608 config = ConfigParser.RawConfigParser() 609 config.read(configPath) 610 except: 611 traceback.print_exc() 612 return 604 613 605 614 self._pilotID = self._get(config, "login", "id", "") … … 615 624 self._quitOnClose = self._getBoolean(config, "general", 616 625 "quitOnClose", False) 617 626 618 627 self._onlineGateSystem = self._getBoolean(config, "general", 619 628 "onlineGateSystem", 620 True)629 not secondaryInstallation) 621 630 self._onlineACARS = self._getBoolean(config, "general", 622 "onlineACARS", True) 631 "onlineACARS", 632 not secondaryInstallation) 623 633 self._flareTimeFromFS = self._getBoolean(config, "general", 624 634 "flareTimeFromFS", … … 644 654 self._getMessageTypeLevel(config, messageType) 645 655 646 self._enableSounds = self._getBoolean(config, "sounds", 647 "enable", True)656 self._enableSounds = self._getBoolean(config, "sounds", "enable", 657 not secondaryInstallation) 648 658 self._pilotControlsSounds = self._getBoolean(config, "sounds", 649 659 "pilotControls", True) … … 659 669 self._checklistHotkey.set(self._get(config, "sounds", 660 670 "checklistHotkey", "CS0")) 661 671 662 672 self._autoUpdate = self._getBoolean(config, "update", "auto", True) 663 673 self._updateURL = self._get(config, "update", "url", 664 Config.DEFAULT_UPDATE_URL) 674 Config.DEFAULT_UPDATE_URL + 675 ("/exp" if secondaryInstallation else "")) 665 676 666 677 for aircraftType in const.aircraftTypes: … … 714 725 if messageType in self._messageTypeLevels: 715 726 option = self._getMessageTypeLevelOptionName(messageType) 716 level = self._messageTypeLevels[messageType] 727 level = self._messageTypeLevels[messageType] 717 728 config.set(Config._messageTypesSection, option, 718 729 const.messageLevel2string(level)) … … 733 744 config.set("sounds", "checklistHotkey", 734 745 str(self._checklistHotkey)) 735 746 736 747 config.add_section("update") 737 748 config.set("update", "auto", … … 760 771 if config.has_option(section, option) \ 761 772 else default 762 773 763 774 def _get(self, config, section, option, default): 764 775 """Get the given option as a string, if found in the given config, … … 774 785 value = config.get(Config._messageTypesSection, option) 775 786 return const.string2messageLevel(value) 787 elif secondaryInstallation: 788 return const.MESSAGELEVEL_NONE 776 789 elif messageType in [const.MESSAGETYPE_LOGGER_ERROR, 777 790 const.MESSAGETYPE_FAULT, 778 791 const.MESSAGETYPE_NOGO, 779 792 const.MESSAGETYPE_GATE_SYSTEM, 780 const.MESSAGETYPE_HELP]: 793 const.MESSAGETYPE_HELP]: 781 794 return const.MESSAGELEVEL_BOTH 782 795 else: -
src/mlx/gui/common.py
r362 r373 2 2 import mlx.const as _const 3 3 from mlx.i18n import xstr 4 5 from mlx.util import secondaryInstallation 4 6 5 7 import os … … 262 264 263 265 WINDOW_TITLE_BASE = PROGRAM_NAME + " " + _const.VERSION 266 if secondaryInstallation: 267 WINDOW_TITLE_BASE += " (" + xstr("secondary") + ")" 264 268 265 269 #------------------------------------------------------------------------------ -
src/mlx/mlx.py
r298 r373 3 3 from i18n import setLanguage 4 4 from sound import initializeSound 5 from util import secondaryInstallation 5 6 6 7 import os … … 51 52 52 53 instance.close() 53 os.execv(programPath, args) 54 os.execv(programPath, args) 54 55 55 56 #-------------------------------------------------------------------------------------- … … 60 61 61 62 global instance 62 instance = SingleInstance("mlx", raiseCallbackWrapper) 63 instance = SingleInstance("mlx" + ("-secondary" if secondaryInstallation 64 else ""), raiseCallbackWrapper) 63 65 if not instance: return 64 66 … … 69 71 70 72 if (len(sys.argv)<=1 or sys.argv[1]!="usedeflang") and config.setupLocale(): 71 restart(["usedeflang"] )73 restart(["usedeflang"] + (["secondary"] if secondaryInstallation else [])) 72 74 73 75 setLanguage(programDirectory, config.getLanguage()) 74 76 75 77 from .gui.gui import GUI 76 78 gui = GUI(programDirectory, config) 77 79 78 80 sys.stdout = StdIOHandler(gui) 79 81 sys.stderr = StdIOHandler(gui) -
src/mlx/util.py
r298 r373 2 2 import math 3 3 import time 4 import sys 4 5 5 6 #------------------------------------------------------------------------------ … … 26 27 - the seconds as an integer 27 28 - 1.0 if the value was non-negative, -1.0 if it was negative.""" 28 29 29 30 if degrees<0: 30 31 degrees = -degrees … … 32 33 else: 33 34 mul = 1.0 34 35 35 36 deg = int(degrees) 36 37 min = int((degrees*60.0)%60.0) … … 125 126 126 127 This function calculates the rhumb distance.""" 127 128 128 129 latitude1 = math.radians(latitude1) 129 130 longitude1 = math.radians(longitude1) … … 160 161 return "%.0f metres" % (visibility,) if visibility<10000 \ 161 162 else "%.1f kilometres" % (visibility/1000.0,) 163 164 #------------------------------------------------------------------------------ 165 166 secondaryInstallation="secondary" in sys.argv
Note:
See TracChangeset
for help on using the changeset viewer.