Changeset 919:2ce8ca39525b for src/mlx/config.py
- Timestamp:
- 03/24/19 08:15:59 (5 years ago)
- Branch:
- python3
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/config.py
r738 r919 1 1 # -*- encoding: utf-8 -*- 2 2 3 import const4 from util import secondaryInstallation, utf2unicode3 from . import const 4 from .util import secondaryInstallation, utf2unicode 5 5 6 6 import os 7 7 import sys 8 8 import traceback 9 import ConfigParser9 import configparser 10 10 11 11 ## @package mlx.config … … 163 163 baseName = "callouts." + const.icaoCodes[aircraftType] + "." 164 164 index = 0 165 for (altitude, path) in self._mapping.ite ritems():165 for (altitude, path) in self._mapping.items(): 166 166 option = baseName + str(index) 167 167 config.set(ApproachCallouts.SECTION, option, … … 171 171 def getAltitudes(self, descending = True): 172 172 """Get the altitudes in decreasing order by default.""" 173 altitudes = self._mapping.keys()173 altitudes = list(self._mapping.keys()) 174 174 altitudes.sort(reverse = descending) 175 175 return altitudes 176 176 177 def __ nonzero__(self):177 def __bool__(self): 178 178 """Return if there is anything in the mapping.""" 179 179 return not not self._mapping … … 704 704 """Load the configuration from its default location.""" 705 705 try: 706 config = ConfigParser.RawConfigParser()706 config = configparser.RawConfigParser() 707 707 config.read(configPath) 708 708 except: … … 806 806 return 807 807 808 config = ConfigParser.RawConfigParser()808 config = configparser.RawConfigParser() 809 809 810 810 config.add_section("login") … … 892 892 try: 893 893 fd = os.open(configPath, os.O_CREAT|os.O_TRUNC|os.O_WRONLY, 894 0 600)894 0o600) 895 895 with os.fdopen(fd, "wt") as f: 896 896 config.write(f) 897 897 self._modified = False 898 898 899 print "Configuration saved:"899 print("Configuration saved:") 900 900 self.log() 901 901 902 except Exception ,e:903 print >> sys.stderr,"Failed to update config: " + \904 utf2unicode(str(e)) 902 except Exception as e: 903 print("Failed to update config: " + \ 904 utf2unicode(str(e)), file=sys.stderr) 905 905 906 906 def _getBoolean(self, config, section, option, default): … … 945 945 import locale 946 946 if self._language: 947 print "Setting up locale for", self._language947 print("Setting up locale for", self._language) 948 948 os.environ["LANGUAGE"] = self._language 949 949 langAndEncoding = self._language + "." + locale.getpreferredencoding() … … 978 978 def log(self): 979 979 """Log the configuration by printing the values""" 980 print " pilot ID:", self._pilotID981 print " rememberPassword:", self._rememberPassword982 983 print " language:", self._language984 985 print " hideMinimizedWindow:", self._hideMinimizedWindow986 print " quitOnClose:", self._quitOnClose987 988 print " onlineGateSystem:", self._onlineGateSystem989 print " onlineACARS:", self._onlineACARS990 991 print " flareTimeFromFS:", self._flareTimeFromFS992 print " syncFSTime:", self._syncFSTime993 print " usingFS2Crew:", self._usingFS2Crew994 995 print " iasSmoothingLength:", self._iasSmoothingLength996 print " vsSmoothingLength:", self._vsSmoothingLength997 998 print " useSimBrief:", self._useSimBrief999 print " simBriefUserName:", self._simBriefUserName1000 print " rememberSimBriefPassword:", self._rememberSimBriefPassword1001 1002 print " pirepDirectory:", self._pirepDirectory1003 print " pirepAutoSave:", self._pirepAutoSave1004 1005 print " defaultMSFS:", self._defaultMSFS1006 1007 print " enableSounds:", self._enableSounds1008 1009 print " pilotControlsSounds:", self._pilotControlsSounds1010 print " pilotHotkey:", str(self._pilotHotkey)1011 1012 print " enableApproachCallouts:", self._enableApproachCallouts1013 print " speedbrakeAtTD:", self._speedbrakeAtTD1014 1015 print " enableChecklists:", self._enableChecklists1016 print " checklistHotkey:", str(self._checklistHotkey)1017 1018 print " autoUpdate:", self._autoUpdate1019 print " updateURL:", self._updateURL1020 print " useRPC:", self._useRPC1021 1022 print " messageTypeLevels:"1023 for (type, level) in self._messageTypeLevels.ite ritems():1024 print 1025 const.messageLevel2string(level)) 1026 1027 print " checklists:"1028 for (type, checklist) in self._checklists.ite ritems():1029 print " %s:" % (const.icaoCodes[type],)980 print(" pilot ID:", self._pilotID) 981 print(" rememberPassword:", self._rememberPassword) 982 983 print(" language:", self._language) 984 985 print(" hideMinimizedWindow:", self._hideMinimizedWindow) 986 print(" quitOnClose:", self._quitOnClose) 987 988 print(" onlineGateSystem:", self._onlineGateSystem) 989 print(" onlineACARS:", self._onlineACARS) 990 991 print(" flareTimeFromFS:", self._flareTimeFromFS) 992 print(" syncFSTime:", self._syncFSTime) 993 print(" usingFS2Crew:", self._usingFS2Crew) 994 995 print(" iasSmoothingLength:", self._iasSmoothingLength) 996 print(" vsSmoothingLength:", self._vsSmoothingLength) 997 998 print(" useSimBrief:", self._useSimBrief) 999 print(" simBriefUserName:", self._simBriefUserName) 1000 print(" rememberSimBriefPassword:", self._rememberSimBriefPassword) 1001 1002 print(" pirepDirectory:", self._pirepDirectory) 1003 print(" pirepAutoSave:", self._pirepAutoSave) 1004 1005 print(" defaultMSFS:", self._defaultMSFS) 1006 1007 print(" enableSounds:", self._enableSounds) 1008 1009 print(" pilotControlsSounds:", self._pilotControlsSounds) 1010 print(" pilotHotkey:", str(self._pilotHotkey)) 1011 1012 print(" enableApproachCallouts:", self._enableApproachCallouts) 1013 print(" speedbrakeAtTD:", self._speedbrakeAtTD) 1014 1015 print(" enableChecklists:", self._enableChecklists) 1016 print(" checklistHotkey:", str(self._checklistHotkey)) 1017 1018 print(" autoUpdate:", self._autoUpdate) 1019 print(" updateURL:", self._updateURL) 1020 print(" useRPC:", self._useRPC) 1021 1022 print(" messageTypeLevels:") 1023 for (type, level) in self._messageTypeLevels.items(): 1024 print(" %s: %s" % (const.messageType2string(type), 1025 const.messageLevel2string(level))) 1026 1027 print(" checklists:") 1028 for (type, checklist) in self._checklists.items(): 1029 print(" %s:" % (const.icaoCodes[type],)) 1030 1030 for path in checklist: 1031 print " " + path1032 1033 print " approachCallouts:"1034 for (type, approachCallouts) in self._approachCallouts.ite ritems():1035 print " %s:" % (const.icaoCodes[type],)1031 print(" " + path) 1032 1033 print(" approachCallouts:") 1034 for (type, approachCallouts) in self._approachCallouts.items(): 1035 print(" %s:" % (const.icaoCodes[type],)) 1036 1036 for (altitude, path) in approachCallouts: 1037 print " %d: %s" % (altitude, path)1037 print(" %d: %s" % (altitude, path)) 1038 1038 1039 1039 #-------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.