121 name=VirtualenvManager.DefaultKey, |
121 name=VirtualenvManager.DefaultKey, |
122 interpreter=defaultPy, |
122 interpreter=defaultPy, |
123 is_global=True, |
123 is_global=True, |
124 ) |
124 ) |
125 |
125 |
|
126 self.__cleanEnvironments() |
|
127 |
126 self.__saveSettings() |
128 self.__saveSettings() |
127 |
129 |
128 def __saveSettings(self): |
130 def __saveSettings(self): |
129 """ |
131 """ |
130 Private slot to save the virtual environments. |
132 Private slot to save the virtual environments. |
146 """ |
148 """ |
147 Public slot to reload the virtual environments. |
149 Public slot to reload the virtual environments. |
148 """ |
150 """ |
149 Preferences.syncPreferences() |
151 Preferences.syncPreferences() |
150 self.__loadSettings() |
152 self.__loadSettings() |
|
153 |
|
154 def __cleanEnvironments(self): |
|
155 """ |
|
156 Private method to delete all non-existent local environments. |
|
157 """ |
|
158 removed = False |
|
159 |
|
160 for venvName in list(self.__virtualEnvironments): |
|
161 venvItem = self.__virtualEnvironments[venvName] |
|
162 if not venvItem.is_remote: |
|
163 # It is a local environment; check it is still valid. |
|
164 venvPath = venvItem.path |
|
165 if venvPath and not os.path.exists(venvPath): |
|
166 del self.__virtualEnvironments[venvName] |
|
167 removed = True |
|
168 if removed: |
|
169 self.__saveSettings() |
|
170 self.virtualEnvironmentRemoved.emit() |
|
171 self.virtualEnvironmentsListChanged.emit() |
151 |
172 |
152 def getDefaultEnvironment(self): |
173 def getDefaultEnvironment(self): |
153 """ |
174 """ |
154 Public method to get the default virtual environment. |
175 Public method to get the default virtual environment. |
155 |
176 |