OSDN Git Service

When NVDA is started with --launcher (including running the launcher executable itsel...
authorMichael Curran <mick@kulgan.net>
Wed, 18 Apr 2012 03:22:47 +0000 (13:22 +1000)
committerMichael Curran <mick@kulgan.net>
Wed, 18 Apr 2012 03:22:47 +0000 (13:22 +1000)
      Specific changes:
        * nvda.pyw: set the configPath option by default to None rather than a default path.
        * config.getUserDefaultconfigPath: Add a keyword argument 'useInstalledUserConfigPathIfExists' which if set to true will use the installed userConfig path (appData) if it exists, even if this is not an installed copy.
        * core.main: if configPath is None (was not passed in on the commandline) then use config.getUserDefaultconfigPath setting useInstalledUserconfigPathIfExists to true if --launcher was given.
        * Initialize the config directory in core.main after the configPath hasbeen set, rather than in nvda.pyw.

source/config/__init__.py
source/core.py
source/nvda.pyw

index c4b53d2..404cc53 100644 (file)
@@ -250,12 +250,14 @@ def isInstalledCopy():
        except WindowsError:\r
                return False\r
 \r
-def getUserDefaultConfigPath():\r
-       if isInstalledCopy():\r
-               try:\r
-                       return os.path.join(shlobj.SHGetFolderPath(0, shlobj.CSIDL_APPDATA), "nvda")\r
-               except WindowsError:\r
-                       pass\r
+\r
+def getUserDefaultConfigPath(useInstalledPathIfExists=False):\r
+       try:\r
+               installedUserConfigPath=os.path.join(shlobj.SHGetFolderPath(0, shlobj.CSIDL_APPDATA), "nvda")\r
+       except WindowsError:\r
+               installedUserConfigPath=None\r
+       if installedUserConfigPath and (isInstalledCopy() or (useInstalledPathIfExists and os.path.isdir(installedUserConfigPath))):\r
+               return installedUserConfigPath\r
        return u'.\\userConfig\\'\r
 \r
 def getSystemConfigPath():\r
index af8078c..e97de89 100644 (file)
@@ -149,6 +149,11 @@ def main():
 This initializes all modules such as audio, IAccessible, keyboard, mouse, and GUI. Then it initialises the wx application object and installs the core pump timer, which checks the queues and executes functions every 1 ms. Finally, it starts the wx main loop.\r
 """\r
        log.debug("Core starting")\r
+       import config\r
+       if not globalVars.appArgs.configPath:\r
+               globalVars.appArgs.configPath=config.getUserDefaultConfigPath(useInstalledPathIfExists=globalVars.appArgs.launcher)\r
+       #Initialize the config path (make sure it exists)\r
+       config.initConfigPath()\r
        log.info("Config dir: %s"%os.path.abspath(globalVars.appArgs.configPath))\r
        log.debug("loading config")\r
        import config\r
index 3bcc033..3337757 100755 (executable)
@@ -62,7 +62,7 @@ parser.add_option('-r','--replace',action="store_true",dest='replace',default=Fa
 parser.add_option('-k','--check-running',action="store_true",dest='check_running',default=False,help="Report whether NVDA is running via the exit code; 0 if running, 1 if not running")\r
 parser.add_option('-f','--log-file',dest='logFileName',help="The file where log messages should be written to")\r
 parser.add_option('-l','--log-level',type="int",dest='logLevel',default=0,help="The lowest level of message logged (debug 10, info 20, warning 30, error 40, critical 50), default is warning") \r
-parser.add_option('-c','--config-path',dest='configPath',default=config.getUserDefaultConfigPath(),help="The path where all settings for NVDA are stored")\r
+parser.add_option('-c','--config-path',dest='configPath',default=None,help="The path where all settings for NVDA are stored")\r
 parser.add_option('-m','--minimal',action="store_true",dest='minimal',default=False,help="No sounds, no interface, no start message etc")\r
 parser.add_option('-s','--secure',action="store_true",dest='secure',default=False,help="Secure mode (disable Python console)")\r
 parser.add_option('--no-sr-flag',action="store_false",dest='changeScreenReaderFlag',default=True,help="Don't change the global system screen reader flag")\r
@@ -129,9 +129,6 @@ if not mutex or ctypes.windll.kernel32.GetLastError()==ERROR_ALREADY_EXISTS:
        if mutex: ctypes.windll.kernel32.CloseHandle(mutex)\r
        sys.exit(1)\r
 \r
-#Initialize the config path (make sure it exists)\r
-config.initConfigPath()\r
-\r
 #os.environ['PYCHECKER']="--limit 10000 -q --changetypes"\r
 #import pychecker.checker\r
 #Initial logging and logging code\r