def test_modify_ram(self): datadir = os.path.join( os.path.dirname(__file__), 'data') batfile = os.path.join(datadir, 'gpt.bat') vmoptionsfile = os.path.join(datadir, 'gpt.vmoptions') all_worked = [] for fname in [batfile, vmoptionsfile]: root, base = os.path.split(fname) tempcopy = os.path.join(root, 'copy_of_' + base) shutil.copyfile(fname, tempcopy) print(tempcopy) assert os.path.isfile(tempcopy) try: installer_utils.modifyRamInBatFiles(tempcopy, 0.0) worked = False with open(tempcopy, 'r') as f: for line in f: if '-Xmx0' in line: worked = True all_worked.append(worked) finally: os.remove(tempcopy) os.remove(tempcopy + '.backup') self.assertTrue(all(all_worked))
def runInstaller(self): ######################################################################## # welcome window with license self.dialog = installerWelcomeWindow() res = self.showDialog() if res == NEXT: # select installation files for 32 or 64 bit install installationsDirs = ['Installations_x32', 'Installations_x64'] if os.path.isdir(installationsDirs[0]): is32bit = True installationsDir = installationsDirs[0] osgeo4wInstall = os.path.join(installationsDir, "osgeo4w-setup.bat") beamInstall = os.path.join(installationsDir, "beam_5.0_win32_installer.exe") snapInstall = os.path.join(installationsDir, "esa-snap_sentinel_windows_5_0.exe") rInstall = os.path.join(installationsDir, "R-3.3.2-win.exe") postgreInstall = os.path.join(installationsDir, "postgresql-9.3.6-2-windows.exe") postgisInstall = os.path.join(installationsDir, "postgis-bundle-pg93x32-setup-2.1.5-1.exe") mapwindowInstall = os.path.join(installationsDir, "MapWindowx86Full-v488SR-installer.exe") mwswatInstall = os.path.join(installationsDir, "MWSWAT2009.exe") swateditorInstall = "MWSWAT additional software\\SwatEditor_Install\\Setup.exe" elif os.path.isdir(installationsDirs[1]): is32bit = False installationsDir = installationsDirs[1] osgeo4wInstall = os.path.join(installationsDir, "osgeo4w-setup.bat") beamInstall = os.path.join(installationsDir, "beam_5.0_win64_installer.exe") snapInstall = os.path.join(installationsDir, "esa-snap_sentinel_windows-x64_5_0.exe") rInstall = os.path.join(installationsDir, "R-3.3.2-win.exe") postgreInstall = os.path.join(installationsDir, "postgresql-9.3.6-2-windows-x64.exe") postgisInstall = os.path.join(installationsDir, "postgis-bundle-pg93x64-setup-2.1.5-2.exe") mapwindowInstall = os.path.join(installationsDir, "MapWindowx86Full-v488SR-installer.exe") mwswatInstall = os.path.join(installationsDir, "MWSWAT2009.exe") swateditorInstall = "MWSWAT additional software\\SwatEditor_Install\\Setup.exe" else: self.util.error_exit('Neither 32 bit nor 64 bit instalations directory exists. Package incomplete.') return # select default installation directories for 32 or 64 bit install if is32bit: osgeo4wDefaultDir = "C:\\OSGeo4W" snapDefaultDir = "C:\\Program Files\\snap" beamDefaultDir = "C:\\Program Files\\beam-5.0" mapwindowDefaultDir = "C:\\Program Files\\MapWindow" rDefaultDir = "C:\\Program Files\\R\\R-3.3.2" else: osgeo4wDefaultDir = "C:\\OSGeo4W64" snapDefaultDir = "C:\\Program Files\\snap" beamDefaultDir = "C:\\Program Files\\beam-5.0" mapwindowDefaultDir = "C:\\Program Files (x86)\\MapWindow" rDefaultDir = "C:\\Program Files\\R\\R-3.3.2" elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Information about uninstalling old version self.dialog = uninstallInstructionsWindow() res = self.showDialog() if res == CANCEL: del self.dialog return ######################################################################## # Install OSGeo4W (QGIS, OTB, SAGA, GRASS) self.dialog = osgeo4wInstallWindow() res = self.showDialog() # run the OSGeo4W installation here as an outside process if res == NEXT: self.util.execSubprocess(osgeo4wInstall) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ask for post-installation even if user has skipped installation self.dialog = osgeo4wPostInstallWindow(osgeo4wDefaultDir) res = self.showDialog() # copy plugins, scripts, and models and activate processing providers if res == NEXT: # pip installations dirPath = str(self.dialog.dirPathText.toPlainText()) # copy the plugins dstPath = os.path.join(os.path.expanduser("~"), ".qgis2", "python", 'plugins') srcPath = os.path.join("QGIS additional software", "plugins.zip") # try to delete old plugins before copying the new ones to avoid conflicts plugins_to_delete = [ 'mikecprovider', 'processing', 'processing_gpf', 'photo2shape', 'processing_workflow', 'processing_SWAT', 'openlayers_plugin', 'pointsamplingtool', 'temporalprofiletool', 'valuetool'] for plugin in plugins_to_delete: self.util.deleteDir( os.path.join(dstPath, plugin)) # show dialog because it might take some time on slower computers self.dialog = extractingWaitWindow(self.util, srcPath, dstPath) self.showDialog() # copy scripts and models QGIS_extras_dir = os.path.abspath("QGIS additional software") dstPath = os.path.join(os.path.expanduser("~"), ".qgis2", "processing") for zipfname in [ 'WOIS_scripts.zip', 'WOIS_models_and_workflows.zip']: srcPath = os.path.join(QGIS_extras_dir, zipfname) # show dialog because it might take some time on slower computers self.dialog = extractingWaitWindow(self.util, srcPath, dstPath) self.showDialog() # additional python modules site_packages = os.path.join(dirPath, 'apps', 'Python27', 'Lib', 'site-packages') # install fmask and rios srcPath = os.path.join(QGIS_extras_dir, 'fmask-rios.zip') self.dialog = extractingWaitWindow(self.util, srcPath, site_packages) self.showDialog() # install cv2 srcPath = os.path.join(QGIS_extras_dir, 'cv2.zip') self.dialog = extractingWaitWindow(self.util, srcPath, site_packages) self.showDialog() # activate plugins and processing providers self.util.activatePlugins() self.util.activateProcessingProviders(osgeo4wDefaultDir) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ####################################################################### # Install BEAM self.dialog = beamInstallWindow() res = self.showDialog() # run the BEAM installation here as an outside process if res == NEXT: self.util.execSubprocess(beamInstall) # self.dialog = beamPostInstallWindow(beamDefaultDir); # res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ask for post-installation even if user has skipped installation self.dialog = beamPostInstallWindow(beamDefaultDir) res = self.showDialog() # copy the additional BEAM modules and set the amount of memory to be used with GPT if res == NEXT: dirPath = str(self.dialog.dirPathText.toPlainText()) dstPath = os.path.join(dirPath,"modules") srcPath = "BEAM additional modules" self.dialog = copyingWaitWindow(self.util, srcPath, dstPath) # show dialog because it might take some time on slower computers self.showDialog() # 32 bit systems usually have less RAM so assign less to BEAM ram_fraction = 0.4 if is32bit else 0.6 installer_utils.modifyRamInBatFiles(os.path.join(dirPath, "bin", 'gpt.bat'), ram_fraction) self.util.activateBEAMplugin(dirPath) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Install Snap Toolbox self.dialog = snapInstallWindow() res = self.showDialog() # run the Snap installation here as an outside process if res == NEXT: self.util.execSubprocess(snapInstall) #self.dialog = snapPostInstallWindow(snapDefaultDir); #res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ask for post-installation even if user has skipped installation self.dialog = snapPostInstallWindow(snapDefaultDir) res = self.showDialog() # Set the amount of memory to be used with NEST GPT if res == NEXT: dirPath = str(self.dialog.dirPathText.toPlainText()) confbat = os.path.join(dirPath, 'bin', 'snappy-conf.bat') osgeopython = os.path.join(osgeo4wDefaultDir, 'bin', 'python.exe') cmd = [confbat, osgeopython] # show dialog because it might take some time on slower computers self.dialog = cmdWaitWindow(self.util, cmd) self.showDialog() dstPath = os.path.join(os.path.expanduser("~"), ".snap") srcPath = "SNAP additional modules" self.util.copyFiles(srcPath, dstPath) #self.dialog = copyingWaitWindow(self.util, srcPath, dstPath) # show dialog because it might take some time on slower computers #self.showDialog() # 32 bit systems usually have less RAM so assign less to S1 Toolbox ram_fraction = 0.4 if is32bit else 0.6 settingsfile = os.path.join(dirPath, 'bin', 'gpt.vmoptions') installer_utils.modifyRamInBatFiles(settingsfile, ram_fraction) # There is a bug in snap installer so the gpt file has to be # modified for 32 bit installation if is32bit: self.util.removeIncompatibleJavaOptions(settingsfile) self.util.activateSNAPplugin(dirPath) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ####################################################################### # Install R self.dialog = rInstallWindow() res = self.showDialog() # run the R installation here as an outside process if res == NEXT: self.util.execSubprocess(rInstall) # self.dialog = rPostInstallWindow(rDefaultDir) # res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ask for post-installation even if user has skipped installation self.dialog = rPostInstallWindow(rDefaultDir) res = self.showDialog() # Copy the R additional libraries if res == NEXT: dirPath = str(self.dialog.dirPathText.toPlainText()) dstPath = os.path.join(dirPath, "library") srcPath = "R additional libraries" # show dialog because it might take some time on slower computers self.dialog = extractingWaitWindow(self.util, os.path.join(srcPath, "libraries.zip"), dstPath) self.showDialog() if is32bit: self.util.activateRplugin(dirPath, "false") else: self.util.activateRplugin(dirPath, "true") elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Install PostGIS postgres_installed = False self.dialog = postgreInstallWindow() res = self.showDialog() # install Postgres if res == NEXT: self.util.execSubprocess(postgreInstall) postgres_installed = True elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() if postgres_installed: # install PostGIS self.dialog = postgisInstallWindow() res = self.showDialog() if res == NEXT: self.util.execSubprocess(postgisInstall) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Install MapWindow, SWAT and PEST mapwindow_installed = False mswat_installed = False swateditor_installed = False # install MapWindow self.dialog = mapwindowInstallWindow() res = self.showDialog() if res == NEXT: self.util.execSubprocess(mapwindowInstall) mapwindow_installed = True elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() if mapwindow_installed: # install MS SWAT self.dialog = mwswatInstallWindow() res = self.showDialog() if res == NEXT: self.util.execSubprocess(mwswatInstall) mswat_installed = True elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() if mswat_installed: # install SWAT editor self.dialog = swateditorInstallWindow() res = self.showDialog() if res == NEXT: self.util.execSubprocess(swateditorInstall) time.sleep(5) swateditor_installed = True elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() if swateditor_installed: # install SWAT post-installation stuff self.dialog = mwswatPostInstallWindow(mapwindowDefaultDir) res = self.showDialog() if res == NEXT: # copy the DTU customised MWSWAT 2009 installation dirPath = str(self.dialog.dirPathText.toPlainText()) mwswatPath = os.path.join(dirPath,"Plugins","MWSWAT2009") dstPath = os.path.join(mwswatPath,'swat2009DtuEnvVers0.2') srcPath = "MWSWAT additional software\\swat2009DtuEnvVers0.2" # show dialog because it might take some time on slower computers self.dialog = copyingWaitWindow(self.util, srcPath, dstPath) self.showDialog() # copy and rename the customised MWSWAT exe if os.path.isfile(os.path.join(mwswatPath,"swat2009rev481.exe_old")): os.remove(os.path.join(mwswatPath,"swat2009rev481.exe_old")) os.rename(os.path.join(mwswatPath,"swat2009rev481.exe"), os.path.join(mwswatPath,"swat2009rev481.exe_old")) self.util.copyFiles(os.path.join(dstPath, "swat2009DtuEnv.exe"), mwswatPath) if os.path.isfile(os.path.join(mwswatPath,"swat2009rev481.exe")): os.remove(os.path.join(mwswatPath,"swat2009rev481.exe")) os.rename(os.path.join(mwswatPath,"swat2009DtuEnv.exe"), os.path.join(mwswatPath, "swat2009rev481.exe")) # copy the modified database file self.util.copyFiles("MWSWAT additional software\\mwswat2009.mdb", mwswatPath) # copy PEST self.dialog = copyingWaitWindow(self.util, "MWSWAT additional software\\PEST", os.path.join(mwswatPath,"PEST")) # show dialog because it might take some time on slower computers self.showDialog() # activate the plugin self.util.activateSWATplugin(dirPath) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # Finish self.dialog = finishWindow() self.showDialog() del self.dialog
def runInstaller(self): ######################################################################## # welcome window with license self.dialog = installerWelcomeWindow() res = self.showDialog() if res == NEXT: # select installation files for 32 or 64 bit install if self.dialog.osComboBox.itemText(self.dialog.osComboBox.currentIndex()) == "32 bit": is32bit = True installationsDir = "Installations_x32" osgeo4wInstall = os.path.join(installationsDir, "osgeo4w-setup.bat") beamInstall = os.path.join(installationsDir, "beam_5.0_win32_installer.exe") snapInstall = os.path.join(installationsDir, "esa-snap_sentinel_windows_3_0.exe") rInstall = os.path.join(installationsDir, "R-3.1.3-win.exe") postgreInstall = os.path.join(installationsDir, "postgresql-9.3.6-2-windows.exe") postgisInstall = os.path.join(installationsDir, "postgis-bundle-pg93x32-setup-2.1.5-1.exe") mapwindowInstall = os.path.join(installationsDir, "MapWindowx86Full-v488SR-installer.exe") mwswatInstall = os.path.join(installationsDir, "MWSWAT2009.exe") swateditorInstall = "MWSWAT additional software\\SwatEditor_Install\\Setup.exe" else: is32bit = False installationsDir = "Installations_x64" osgeo4wInstall = os.path.join(installationsDir, "osgeo4w-setup.bat") beamInstall = os.path.join(installationsDir, "beam_5.0_win64_installer.exe") snapInstall = os.path.join(installationsDir, "esa-snap_sentinel_windows-x64_3_0.exe") rInstall = os.path.join(installationsDir, "R-3.1.3-win.exe") postgreInstall = os.path.join(installationsDir, "postgresql-9.3.6-2-windows-x64.exe") postgisInstall = os.path.join(installationsDir, "postgis-bundle-pg93x64-setup-2.1.5-2.exe") mapwindowInstall = os.path.join(installationsDir, "MapWindowx86Full-v488SR-installer.exe") mwswatInstall = os.path.join(installationsDir, "MWSWAT2009.exe") swateditorInstall = "MWSWAT additional software\\SwatEditor_Install\\Setup.exe" # select default installation directories for 32 or 64 bit install if is32bit: osgeo4wDefaultDir = "C:\\OSGeo4W" snapDefaultDir = "C:\\Program Files\\snap" beamDefaultDir = "C:\\Program Files\\beam-5.0" mapwindowDefaultDir = "C:\\Program Files\\MapWindow" rDefaultDir = "C:\\Program Files\\R\\R-3.1.3" else: osgeo4wDefaultDir = "C:\\OSGeo4W64" snapDefaultDir = "C:\\Program Files\\snap" beamDefaultDir = "C:\\Program Files\\beam-5.0" mapwindowDefaultDir = "C:\\Program Files (x86)\\MapWindow" rDefaultDir = "C:\\Program Files\\R\\R-3.1.3" elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Information about uninstalling old version self.dialog = uninstallInstructionsWindow() res = self.showDialog() if res == CANCEL: del self.dialog return ######################################################################## # Install OSGeo4W (QGIS, OTB, SAGA, GRASS) self.dialog = osgeo4wInstallWindow() res = self.showDialog() # run the OSGeo4W installation here as an outside process if res == NEXT: self.util.execSubprocess(osgeo4wInstall) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ask for post-installation even if user has skipped installation self.dialog = osgeo4wPostInstallWindow(osgeo4wDefaultDir) res = self.showDialog() # copy plugins, scripts, and models and activate processing providers if res == NEXT: # pip installations dirPath = str(self.dialog.dirPathText.toPlainText()) pipbat = os.path.join("QGIS WOIS plugins", 'pip_installs', 'install_pip_packages.bat') if installer_utils.check_file_exists(pipbat): cmd = [pipbat, dirPath] # show dialog because it might take some time on slower computers self.dialog = cmdWaitWindow(self.util, cmd) self.showDialog() # copy the plugins dstPath = os.path.join(os.path.expanduser("~"),".qgis2","python") srcPath = os.path.join("QGIS WOIS plugins", "plugins.zip") # try to delete old plugins before copying the new ones to avoid conflicts plugins_to_delete = [ 'processing', 'processing_gpf', 'photo2shape', 'processing_workflow', 'processing_SWAT', 'openlayers_plugin', 'pointsamplingtool', 'temporalprofiletool', 'valuetool'] for plugin in plugins_to_delete: self.util.deleteDir( os.path.join(dstPath, 'plugins', plugin)) # show dialog because it might take some time on slower computers self.dialog = extractingWaitWindow(self.util, srcPath, dstPath) self.showDialog() # copy scripts and models dstPath = os.path.join(os.path.expanduser("~"),".qgis2","processing") srcPath = os.path.join("QGIS WOIS plugins", "scripts_and_models.zip") # show dialog because it might take some time on slower computers self.dialog = extractingWaitWindow(self.util, srcPath, dstPath) self.showDialog() # activate plugins and processing providers self.util.activatePlugins() self.util.activateProcessingProviders(osgeo4wDefaultDir) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Install BEAM self.dialog = beamInstallWindow() res = self.showDialog() # run the BEAM installation here as an outside process if res == NEXT: self.util.execSubprocess(beamInstall) #self.dialog = beamPostInstallWindow(beamDefaultDir); #res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ask for post-installation even if user has skipped installation self.dialog = beamPostInstallWindow(beamDefaultDir) res = self.showDialog() # copy the additional BEAM modules and set the amount of memory to be used with GPT if res == NEXT: dirPath = str(self.dialog.dirPathText.toPlainText()) dstPath = os.path.join(dirPath,"modules") srcPath = "BEAM additional modules" self.dialog = copyingWaitWindow(self.util, srcPath, dstPath) # show dialog because it might take some time on slower computers self.showDialog() # 32 bit systems usually have less RAM so assign less to BEAM ram_fraction = 0.4 if is32bit else 0.6 installer_utils.modifyRamInBatFiles(os.path.join(dirPath, "bin", 'gpt.bat'), ram_fraction) self.util.activateBEAMplugin(dirPath) # Temporary fix for https://github.com/TIGER-NET/Processing-GPF/issues/1, until new version of BEAM is out. # When that happens also remove beam-meris-radiometry-5.0.1.jar from "BEAM additional modules" #self.util.deleteFile(os.path.join(dstPath, "beam-meris-radiometry-5.0.jar")) #self.util.deleteFile(os.path.join(dstPath, "beam-meris-case2-regional-1.6.jar")) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Install Snap Toolbox self.dialog = snapInstallWindow() res = self.showDialog() # run the Snap installation here as an outside process if res == NEXT: self.util.execSubprocess(snapInstall) #self.dialog = snapPostInstallWindow(snapDefaultDir); #res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ask for post-installation even if user has skipped installation self.dialog = snapPostInstallWindow(snapDefaultDir) res = self.showDialog() # Set the amount of memory to be used with NEST GPT if res == NEXT: dirPath = str(self.dialog.dirPathText.toPlainText()) dstPath = os.path.join(os.path.expanduser("~"), ".snap") srcPath = "SNAP additional modules" self.util.copyFiles(srcPath, dstPath) #self.dialog = copyingWaitWindow(self.util, srcPath, dstPath) # show dialog because it might take some time on slower computers #self.showDialog() # 32 bit systems usually have less RAM so assign less to S1 Toolbox ram_fraction = 0.4 if is32bit else 0.6 settingsfile = os.path.join(dirPath, 'bin', 'gpt.vmoptions') installer_utils.modifyRamInBatFiles(settingsfile, ram_fraction) # There is a bug in snap installer so the gpt file has to be # modified for 32 bit installation if is32bit: self.util.removeIncompatibleJavaOptions(settingsfile) self.util.activateSNAPplugin(dirPath) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Install R self.dialog = rInstallWindow() res = self.showDialog() # run the R installation here as an outside process if res == NEXT: self.util.execSubprocess(rInstall) #self.dialog = rPostInstallWindow(rDefaultDir) #res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # ask for post-installation even if user has skipped installation self.dialog = rPostInstallWindow(rDefaultDir) res = self.showDialog() # Copy the R additional libraries if res == NEXT: dirPath = str(self.dialog.dirPathText.toPlainText()) dstPath = os.path.join(dirPath,"library") srcPath = "R additional libraries" # show dialog because it might take some time on slower computers self.dialog = extractingWaitWindow(self.util, os.path.join(srcPath, "libraries.zip"), dstPath) self.showDialog() if is32bit: self.util.activateRplugin(dirPath, "false") else: self.util.activateRplugin(dirPath, "true") elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Install PostGIS self.dialog = postgreInstallWindow() res = self.showDialog() # run the postgresql installer as an outside process if res == NEXT: self.util.execSubprocess(postgreInstall) self.dialog = postgisInstallWindow() res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # run the postgis installer as an outside process if res == NEXT: self.util.execSubprocess(postgisInstall) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() ######################################################################## # Install MapWindow, SWAT and PEST self.dialog = mapwindowInstallWindow() res = self.showDialog() # run the MapWindow installer as an outside process if res == NEXT: self.util.execSubprocess(mapwindowInstall) self.dialog = mwswatInstallWindow() res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # run the MWSWAT installer as an outside process if res == NEXT: self.util.execSubprocess(mwswatInstall) self.dialog = swateditorInstallWindow() res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # run the SWAT editor installer as an outside process if res == NEXT: self.util.execSubprocess(swateditorInstall) self.dialog = mwswatPostInstallWindow(mapwindowDefaultDir) res = self.showDialog() elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() if res == NEXT: # copy the DTU customised MWSWAT 2009 installation dirPath = str(self.dialog.dirPathText.toPlainText()) mwswatPath = os.path.join(dirPath,"Plugins","MWSWAT2009") dstPath = os.path.join(mwswatPath,'swat2009DtuEnvVers0.2') srcPath = "MWSWAT additional software\\swat2009DtuEnvVers0.2" # show dialog because it might take some time on slower computers self.dialog = copyingWaitWindow(self.util, srcPath, dstPath) self.showDialog() # copy and rename the customised MWSWAT exe if os.path.isfile(os.path.join(mwswatPath,"swat2009rev481.exe_old")): os.remove(os.path.join(mwswatPath,"swat2009rev481.exe_old")) os.rename(os.path.join(mwswatPath,"swat2009rev481.exe"), os.path.join(mwswatPath,"swat2009rev481.exe_old")) self.util.copyFiles(os.path.join(dstPath, "swat2009DtuEnv.exe"), mwswatPath) if os.path.isfile(os.path.join(mwswatPath,"swat2009rev481.exe")): os.remove(os.path.join(mwswatPath,"swat2009rev481.exe")) os.rename(os.path.join(mwswatPath,"swat2009DtuEnv.exe"), os.path.join(mwswatPath, "swat2009rev481.exe")) # copy the modified database file self.util.copyFiles("MWSWAT additional software\\mwswat2009.mdb", mwswatPath) # copy PEST self.dialog = copyingWaitWindow(self.util, "MWSWAT additional software\\PEST", os.path.join(mwswatPath,"PEST")) # show dialog because it might take some time on slower computers self.showDialog() # activate the plugin self.util.activateSWATplugin(dirPath) elif res == SKIP: pass elif res == CANCEL: del self.dialog return else: self.unknownActionPopup() # Finish self.dialog = finishWindow() self.showDialog() del self.dialog