src/eric7/VirtualEnv/VirtualenvManager.py

branch
eric7
changeset 10194
2c26b4fe25db
parent 9653
e67609152c5e
child 10195
d763674ac9a3
equal deleted inserted replaced
10193:0d7392e49c48 10194:2c26b4fe25db
19 from eric7 import Preferences 19 from eric7 import Preferences
20 from eric7.EricWidgets import EricMessageBox 20 from eric7.EricWidgets import EricMessageBox
21 from eric7.EricWidgets.EricApplication import ericApp 21 from eric7.EricWidgets.EricApplication import ericApp
22 from eric7.SystemUtilities import FileSystemUtilities, PythonUtilities 22 from eric7.SystemUtilities import FileSystemUtilities, PythonUtilities
23 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog 23 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog
24
25 from .VirtualenvMeta import VirtualenvMetaData
24 26
25 27
26 class VirtualenvManager(QObject): 28 class VirtualenvManager(QObject):
27 """ 29 """
28 Class implementing an object to manage Python virtual environments. 30 Class implementing an object to manage Python virtual environments.
83 # is_remote: a flag indicating a remotely accessed environment 85 # is_remote: a flag indicating a remotely accessed environment
84 # exec_path: a string to be prefixed to the PATH environment 86 # exec_path: a string to be prefixed to the PATH environment
85 # setting 87 # setting
86 # description a description of the environment 88 # description a description of the environment
87 # 89 #
88 envsToDelete = []
89 for venvName in environments: 90 for venvName in environments:
90 environment = environments[venvName] 91 environment = environments[venvName]
92 environment["name"] = venvName
91 if ("is_remote" in environment and environment["is_remote"]) or os.access( 93 if ("is_remote" in environment and environment["is_remote"]) or os.access(
92 environment["interpreter"], os.X_OK 94 environment["interpreter"], os.X_OK
93 ): 95 ):
94 if "is_global" not in environment: 96 if "is_global" not in environment:
95 environment["is_global"] = environment["path"] == "" 97 environment["is_global"] = environment["path"] == ""
96 if "is_conda" not in environment: 98 self.__virtualEnvironments[venvName] = VirtualenvMetaData.from_dict(
97 environment["is_conda"] = False 99 environment
98 if "is_remote" not in environment: 100 )
99 environment["is_remote"] = False
100 if "exec_path" not in environment:
101 environment["exec_path"] = ""
102 if "description" not in environment:
103 environment["description"] = ""
104 self.__virtualEnvironments[venvName] = environment
105
106 # now remove unsupported environments
107 for venvName in envsToDelete:
108 del environments[venvName]
109 101
110 # check, if the interpreter used to run eric is in the environments 102 # check, if the interpreter used to run eric is in the environments
111 defaultPy = PythonUtilities.getPythonExecutable() 103 defaultPy = PythonUtilities.getPythonExecutable()
112 if "{0}.venv{0}".format(os.sep) not in defaultPy: 104 if "{0}.venv{0}".format(os.sep) not in defaultPy:
113 # only check for a non-embedded environment 105 # only check for a non-embedded environment
118 ): 110 ):
119 found = True 111 found = True
120 break 112 break
121 if not found: 113 if not found:
122 # add an environment entry for the default interpreter 114 # add an environment entry for the default interpreter
123 self.__virtualEnvironments[VirtualenvManager.DefaultKey] = { 115 self.__virtualEnvironments[
124 "path": "", 116 VirtualenvManager.DefaultKey
125 "interpreter": defaultPy, 117 ] = VirtualenvMetaData(
126 "variant": 3, 118 name=VirtualenvManager.DefaultKey,
127 "is_global": True, 119 interpreter=defaultPy,
128 "is_conda": False, 120 is_globa=True,
129 "is_remote": False, 121 )
130 "exec_path": "",
131 "description": "",
132 }
133 122
134 self.__saveSettings() 123 self.__saveSettings()
135 124
136 def __saveSettings(self): 125 def __saveSettings(self):
137 """ 126 """
140 Preferences.getSettings().setValue( 129 Preferences.getSettings().setValue(
141 "PyVenv/VirtualEnvironmentsBaseDir", self.__virtualEnvironmentsBaseDir 130 "PyVenv/VirtualEnvironmentsBaseDir", self.__virtualEnvironmentsBaseDir
142 ) 131 )
143 132
144 Preferences.getSettings().setValue( 133 Preferences.getSettings().setValue(
145 "PyVenv/VirtualEnvironments", json.dumps(self.__virtualEnvironments) 134 "PyVenv/VirtualEnvironments",
135 json.dumps(
136 {env.name: env.as_dict() for env in self.__virtualEnvironments.values()}
137 ),
146 ) 138 )
147 Preferences.syncPreferences() 139 Preferences.syncPreferences()
148 140
149 @pyqtSlot() 141 @pyqtSlot()
150 def reloadSettings(self): 142 def reloadSettings(self):
160 152
161 Default is an environment with the key '<default>' or the first one 153 Default is an environment with the key '<default>' or the first one
162 having an interpreter matching sys.executable (i.e. the one used to 154 having an interpreter matching sys.executable (i.e. the one used to
163 execute eric with) 155 execute eric with)
164 156
165 @return tuple containing the environment name and a dictionary 157 @return tuple containing the environment name and a copy of the metadata
166 containing a copy of the default virtual environment 158 of the default virtual environment
167 @rtype tuple of (str, dict) 159 @rtype tuple of (str, VirtualenvMetaData)
168 """ 160 """
169 if VirtualenvManager.DefaultKey in self.__virtualEnvironments: 161 if VirtualenvManager.DefaultKey in self.__virtualEnvironments:
170 return ( 162 return (
171 VirtualenvManager.DefaultKey, 163 VirtualenvManager.DefaultKey,
172 copy.copy(self.__virtualEnvironments[VirtualenvManager.DefaultKey]), 164 copy.copy(self.__virtualEnvironments[VirtualenvManager.DefaultKey]),
179 """ 171 """
180 Public method to get the environment a given interpreter belongs to. 172 Public method to get the environment a given interpreter belongs to.
181 173
182 @param interpreter path of the interpreter 174 @param interpreter path of the interpreter
183 @type str 175 @type str
184 @return tuple containing the environment name and a dictionary 176 @return tuple containing the environment name and a copy of the metadata
185 containing a copy of the default virtual environment 177 of the virtual environment the interpreter belongs to
186 @rtype tuple of (str, dict) 178 @rtype tuple of (str, VirtualenvMetaData)
187 """ 179 """
188 py = FileSystemUtilities.normcaseabspath(interpreter.replace("w.exe", ".exe")) 180 py = FileSystemUtilities.normcaseabspath(interpreter.replace("w.exe", ".exe"))
189 for venvName in self.__virtualEnvironments: 181 for venvName in self.__virtualEnvironments:
190 if py == FileSystemUtilities.normcaseabspath( 182 if py == FileSystemUtilities.normcaseabspath(
191 self.__virtualEnvironments[venvName]["interpreter"] 183 self.__virtualEnvironments[venvName].interpreter
192 ): 184 ):
193 return (venvName, copy.copy(self.__virtualEnvironments[venvName])) 185 return (venvName, copy.copy(self.__virtualEnvironments[venvName]))
194 186
195 if os.path.samefile(interpreter, sys.executable): 187 if os.path.samefile(interpreter, sys.executable):
196 return (VirtualenvManager.SystemKey, {}) 188 return (VirtualenvManager.SystemKey, {})
221 ok, prefix, interpreter = conda.createCondaEnvironment( 213 ok, prefix, interpreter = conda.createCondaEnvironment(
222 resultDict["arguments"] 214 resultDict["arguments"]
223 ) 215 )
224 if ok and "--dry-run" not in resultDict["arguments"]: 216 if ok and "--dry-run" not in resultDict["arguments"]:
225 self.addVirtualEnv( 217 self.addVirtualEnv(
226 resultDict["logicalName"], 218 VirtualenvMetaData(
227 prefix, 219 name=resultDict["logicalName"],
228 venvInterpreter=interpreter, 220 path=prefix,
229 isConda=True, 221 interpreter=interpreter,
222 is_conda=True,
223 )
230 ) 224 )
231 else: 225 else:
232 # now do the call 226 # now do the call
233 dia = VirtualenvExecDialog(resultDict, self) 227 dia = VirtualenvExecDialog(resultDict, self)
234 dia.show() 228 dia.show()
260 dia = VirtualenvUpgradeExecDialog(venvName, pythonExe, createLog, self) 254 dia = VirtualenvUpgradeExecDialog(venvName, pythonExe, createLog, self)
261 dia.show() 255 dia.show()
262 dia.start(args) 256 dia.start(args)
263 dia.exec() 257 dia.exec()
264 258
265 def addVirtualEnv( 259 def addVirtualEnv(self, metadata):
266 self,
267 venvName,
268 venvDirectory,
269 venvInterpreter="",
270 isGlobal=False,
271 isConda=False,
272 isRemote=False,
273 execPath="",
274 description="",
275 ):
276 """ 260 """
277 Public method to add a virtual environment. 261 Public method to add a virtual environment.
278 262
279 @param venvName logical name for the virtual environment 263 @param metadata object containing the metadata of the virtual environment
280 @type str 264 @type VirtualenvMetaData
281 @param venvDirectory directory of the virtual environment
282 @type str
283 @param venvInterpreter interpreter of the virtual environment
284 @type str
285 @param isGlobal flag indicating a global environment
286 @type bool
287 @param isConda flag indicating an Anaconda virtual environment
288 @type bool
289 @param isRemote flag indicating a remotely accessed environment
290 @type bool
291 @param execPath search path string to be prepended to the PATH
292 environment variable
293 @type str
294 @param description descriptive text for the environment
295 @type str
296 """ 265 """
297 from .VirtualenvInterpreterSelectionDialog import ( 266 from .VirtualenvInterpreterSelectionDialog import (
298 VirtualenvInterpreterSelectionDialog, 267 VirtualenvInterpreterSelectionDialog,
299 ) 268 )
300 from .VirtualenvNameDialog import VirtualenvNameDialog 269 from .VirtualenvNameDialog import VirtualenvNameDialog
301 270
302 if venvName in self.__virtualEnvironments: 271 if metadata.name in self.__virtualEnvironments:
303 ok = EricMessageBox.yesNo( 272 ok = EricMessageBox.yesNo(
304 None, 273 None,
305 self.tr("Add Virtual Environment"), 274 self.tr("Add Virtual Environment"),
306 self.tr( 275 self.tr(
307 """A virtual environment named <b>{0}</b> exists""" 276 """A virtual environment named <b>{0}</b> exists"""
308 """ already. Shall it be replaced?""" 277 """ already. Shall it be replaced?"""
309 ).format(venvName), 278 ).format(metadata.name),
310 icon=EricMessageBox.Warning, 279 icon=EricMessageBox.Warning,
311 ) 280 )
312 if not ok: 281 if not ok:
313 dlg = VirtualenvNameDialog( 282 dlg = VirtualenvNameDialog(
314 list(self.__virtualEnvironments.keys()), venvName 283 list(self.__virtualEnvironments.keys()), metadata.name
315 ) 284 )
316 if dlg.exec() != QDialog.DialogCode.Accepted: 285 if dlg.exec() != QDialog.DialogCode.Accepted:
317 return 286 return
318 287
319 venvName = dlg.getName() 288 metadata.name = dlg.getName()
320 289
321 if not venvInterpreter: 290 if not metadata.interpreter:
322 dlg = VirtualenvInterpreterSelectionDialog(venvName, venvDirectory) 291 dlg = VirtualenvInterpreterSelectionDialog(metadata.name, metadata.path)
323 if dlg.exec() == QDialog.DialogCode.Accepted: 292 if dlg.exec() == QDialog.DialogCode.Accepted:
324 venvInterpreter = dlg.getData() 293 metadata.interpreter = dlg.getData()
325 294
326 if venvInterpreter: 295 if metadata.interpreter:
327 self.__virtualEnvironments[venvName] = { 296 self.__virtualEnvironments[metadata.name] = metadata
328 "path": venvDirectory,
329 "interpreter": venvInterpreter,
330 "variant": 3, # always 3
331 "is_global": isGlobal,
332 "is_conda": isConda,
333 "is_remote": isRemote,
334 "exec_path": execPath,
335 "description": description,
336 }
337
338 self.__saveSettings() 297 self.__saveSettings()
339 298
340 self.virtualEnvironmentAdded.emit() 299 self.virtualEnvironmentAdded.emit()
341 self.virtualEnvironmentsListChanged.emit() 300 self.virtualEnvironmentsListChanged.emit()
342 301
343 def setVirtualEnv( 302 def setVirtualEnv(self, metadata):
344 self,
345 venvName,
346 venvDirectory,
347 venvInterpreter,
348 isGlobal,
349 isConda,
350 isRemote,
351 execPath,
352 description,
353 ):
354 """ 303 """
355 Public method to change a virtual environment. 304 Public method to change a virtual environment.
356 305
357 @param venvName logical name of the virtual environment 306 @param metadata object containing the metadata of the virtual environment
358 @type str 307 @type VirtualenvMetaData
359 @param venvDirectory directory of the virtual environment 308 """
360 @type str 309 if metadata.name not in self.__virtualEnvironments:
361 @param venvInterpreter interpreter of the virtual environment
362 @type str
363 @param isGlobal flag indicating a global environment
364 @type bool
365 @param isConda flag indicating an Anaconda virtual environment
366 @type bool
367 @param isRemote flag indicating a remotely accessed environment
368 @type bool
369 @param execPath search path string to be prepended to the PATH
370 environment variable
371 @type str
372 @param description descriptive text for the environment
373 @type str
374 """
375 if venvName not in self.__virtualEnvironments:
376 EricMessageBox.yesNo( 310 EricMessageBox.yesNo(
377 None, 311 None,
378 self.tr("Change Virtual Environment"), 312 self.tr("Change Virtual Environment"),
379 self.tr( 313 self.tr(
380 """A virtual environment named <b>{0}</b> does not""" 314 """A virtual environment named <b>{0}</b> does not"""
381 """ exist. Aborting!""" 315 """ exist. Aborting!"""
382 ).format(venvName), 316 ).format(metadata.name),
383 icon=EricMessageBox.Warning, 317 icon=EricMessageBox.Warning,
384 ) 318 )
385 return 319 return
386 320
387 self.__virtualEnvironments[venvName] = { 321 self.__virtualEnvironments[metadata.name] = metadata
388 "path": venvDirectory,
389 "interpreter": venvInterpreter,
390 "variant": 3, # always 3
391 "is_global": isGlobal,
392 "is_conda": isConda,
393 "is_remote": isRemote,
394 "exec_path": execPath,
395 "description": description,
396 }
397
398 self.__saveSettings() 322 self.__saveSettings()
399 323
400 self.virtualEnvironmentChanged.emit(venvName) 324 self.virtualEnvironmentChanged.emit(metadata.name)
401 self.virtualEnvironmentsListChanged.emit() 325 self.virtualEnvironmentsListChanged.emit()
402 326
403 def renameVirtualEnv( 327 def renameVirtualEnv(
404 self, 328 self,
405 oldVenvName, 329 oldVenvName,
406 venvName, 330 metadata,
407 venvDirectory,
408 venvInterpreter,
409 isGlobal,
410 isConda,
411 isRemote,
412 execPath,
413 description,
414 ): 331 ):
415 """ 332 """
416 Public method to substitute a virtual environment entry with a new 333 Public method to substitute a virtual environment entry with a new
417 name. 334 name.
418 335
419 @param oldVenvName old name of the virtual environment 336 @param oldVenvName old name of the virtual environment
420 @type str 337 @type str
421 @param venvName logical name for the virtual environment 338 @param metadata object containing the metadata of the virtual environment
422 @type str 339 @type VirtualenvMetaData
423 @param venvDirectory directory of the virtual environment
424 @type str
425 @param venvInterpreter interpreter of the virtual environment
426 @type str
427 @param isGlobal flag indicating a global environment
428 @type bool
429 @param isConda flag indicating an Anaconda virtual environment
430 @type bool
431 @param isRemote flag indicating a remotely accessed environment
432 @type bool
433 @param execPath search path string to be prepended to the PATH
434 environment variable
435 @type str
436 @param description descriptive text for the environment
437 @type str
438 """ 340 """
439 if oldVenvName not in self.__virtualEnvironments: 341 if oldVenvName not in self.__virtualEnvironments:
440 EricMessageBox.yesNo( 342 EricMessageBox.yesNo(
441 None, 343 None,
442 self.tr("Rename Virtual Environment"), 344 self.tr("Rename Virtual Environment"),
447 icon=EricMessageBox.Warning, 349 icon=EricMessageBox.Warning,
448 ) 350 )
449 return 351 return
450 352
451 del self.__virtualEnvironments[oldVenvName] 353 del self.__virtualEnvironments[oldVenvName]
452 self.addVirtualEnv( 354 self.addVirtualEnv(metadata)
453 venvName,
454 venvDirectory,
455 venvInterpreter=venvInterpreter,
456 isGlobal=isGlobal,
457 isConda=isConda,
458 isRemote=isRemote,
459 execPath=execPath,
460 description=description,
461 )
462 355
463 def deleteVirtualEnvs(self, venvNames): 356 def deleteVirtualEnvs(self, venvNames):
464 """ 357 """
465 Public method to delete virtual environments from the list and disk. 358 Public method to delete virtual environments from the list and disk.
466 359
468 @type list of str 361 @type list of str
469 """ 362 """
470 venvMessages = [] 363 venvMessages = []
471 for venvName in venvNames: 364 for venvName in venvNames:
472 if venvName in self.__virtualEnvironments and bool( 365 if venvName in self.__virtualEnvironments and bool(
473 self.__virtualEnvironments[venvName]["path"] 366 self.__virtualEnvironments[venvName].path
474 ): 367 ):
475 venvMessages.append( 368 venvMessages.append(
476 self.tr("{0} - {1}").format( 369 self.tr("{0} - {1}").format(
477 venvName, self.__virtualEnvironments[venvName]["path"] 370 venvName, self.__virtualEnvironments[venvName].path
478 ) 371 )
479 ) 372 )
480 if venvMessages: 373 if venvMessages:
481 dlg = DeleteFilesConfirmationDialog( 374 dlg = DeleteFilesConfirmationDialog(
482 None, 375 None,
490 if dlg.exec() == QDialog.DialogCode.Accepted: 383 if dlg.exec() == QDialog.DialogCode.Accepted:
491 for venvName in venvNames: 384 for venvName in venvNames:
492 if self.__isEnvironmentDeleteable(venvName): 385 if self.__isEnvironmentDeleteable(venvName):
493 if self.isCondaEnvironment(venvName): 386 if self.isCondaEnvironment(venvName):
494 conda = ericApp().getObject("Conda") 387 conda = ericApp().getObject("Conda")
495 path = self.__virtualEnvironments[venvName]["path"] 388 path = self.__virtualEnvironments[venvName].path
496 res = conda.removeCondaEnvironment(prefix=path) 389 res = conda.removeCondaEnvironment(prefix=path)
497 if res: 390 if res:
498 del self.__virtualEnvironments[venvName] 391 del self.__virtualEnvironments[venvName]
499 else: 392 else:
500 shutil.rmtree( 393 shutil.rmtree(
501 self.__virtualEnvironments[venvName]["path"], True 394 self.__virtualEnvironments[venvName].path, True
502 ) 395 )
503 del self.__virtualEnvironments[venvName] 396 del self.__virtualEnvironments[venvName]
504 397
505 self.__saveSettings() 398 self.__saveSettings()
506 399
518 @rtype bool 411 @rtype bool
519 """ 412 """
520 ok = False 413 ok = False
521 if venvName in self.__virtualEnvironments: 414 if venvName in self.__virtualEnvironments:
522 ok = True 415 ok = True
523 ok &= bool(self.__virtualEnvironments[venvName]["path"]) 416 ok &= bool(self.__virtualEnvironments[venvName].path)
524 ok &= not self.__virtualEnvironments[venvName]["is_global"] 417 ok &= not self.__virtualEnvironments[venvName].is_global
525 ok &= not self.__virtualEnvironments[venvName]["is_remote"] 418 ok &= not self.__virtualEnvironments[venvName].is_remote
526 ok &= os.access(self.__virtualEnvironments[venvName]["path"], os.W_OK) 419 ok &= os.access(self.__virtualEnvironments[venvName].path, os.W_OK)
527 420
528 return ok 421 return ok
529 422
530 def removeVirtualEnvs(self, venvNames): 423 def removeVirtualEnvs(self, venvNames):
531 """ 424 """
537 venvMessages = [] 430 venvMessages = []
538 for venvName in venvNames: 431 for venvName in venvNames:
539 if venvName in self.__virtualEnvironments: 432 if venvName in self.__virtualEnvironments:
540 venvMessages.append( 433 venvMessages.append(
541 self.tr("{0} - {1}").format( 434 self.tr("{0} - {1}").format(
542 venvName, self.__virtualEnvironments[venvName]["path"] 435 venvName, self.__virtualEnvironments[venvName].path
543 ) 436 )
544 ) 437 )
545 if venvMessages: 438 if venvMessages:
546 dlg = DeleteFilesConfirmationDialog( 439 dlg = DeleteFilesConfirmationDialog(
547 None, 440 None,
562 self.virtualEnvironmentRemoved.emit() 455 self.virtualEnvironmentRemoved.emit()
563 self.virtualEnvironmentsListChanged.emit() 456 self.virtualEnvironmentsListChanged.emit()
564 457
565 def getEnvironmentEntries(self): 458 def getEnvironmentEntries(self):
566 """ 459 """
567 Public method to get a dictionary containing the defined virtual 460 Public method to get a list of the defined virtual environment entries.
568 environment entries. 461
569 462 @return list containing a copy of the defined virtual environments
570 @return dictionary containing a copy of the defined virtual 463 @rtype list
571 environments 464 """
572 @rtype dict 465 return [copy.copy(env) for env in self.__virtualEnvironments.values()]
573 """
574 return copy.deepcopy(self.__virtualEnvironments)
575 466
576 @pyqtSlot() 467 @pyqtSlot()
577 def showVirtualenvManagerDialog(self, modal=False): 468 def showVirtualenvManagerDialog(self, modal=False):
578 """ 469 """
579 Public slot to show the virtual environment manager dialog. 470 Public slot to show the virtual environment manager dialog.
609 @type str 500 @type str
610 @return interpreter path 501 @return interpreter path
611 @rtype str 502 @rtype str
612 """ 503 """
613 if venvName in self.__virtualEnvironments: 504 if venvName in self.__virtualEnvironments:
614 return self.__virtualEnvironments[venvName]["interpreter"].replace( 505 return self.__virtualEnvironments[venvName].interpreter.replace(
615 "w.exe", ".exe" 506 "w.exe", ".exe"
616 ) 507 )
617 elif venvName == VirtualenvManager.SystemKey: 508 elif venvName == VirtualenvManager.SystemKey:
618 return sys.executable.replace("w.exe", ".exe") 509 return sys.executable.replace("w.exe", ".exe")
619 else: 510 else:
627 @type str 518 @type str
628 @param venvInterpreter interpreter path to be set 519 @param venvInterpreter interpreter path to be set
629 @type str 520 @type str
630 """ 521 """
631 if venvName in self.__virtualEnvironments: 522 if venvName in self.__virtualEnvironments:
632 self.__virtualEnvironments[venvName]["interpreter"] = venvInterpreter 523 self.__virtualEnvironments[venvName].interpreter = venvInterpreter
633 self.__saveSettings() 524 self.__saveSettings()
634 525
635 self.virtualEnvironmentChanged.emit(venvName) 526 self.virtualEnvironmentChanged.emit(venvName)
636 self.virtualEnvironmentsListChanged.emit() 527 self.virtualEnvironmentsListChanged.emit()
637 528
643 @type str 534 @type str
644 @return directory path 535 @return directory path
645 @rtype str 536 @rtype str
646 """ 537 """
647 if venvName in self.__virtualEnvironments: 538 if venvName in self.__virtualEnvironments:
648 return self.__virtualEnvironments[venvName]["path"] 539 return self.__virtualEnvironments[venvName].path
649 else: 540 else:
650 return "" 541 return ""
651 542
652 def getVirtualenvNames(self, noRemote=False, noConda=False): 543 def getVirtualenvNames(self, noRemote=False, noConda=False):
653 """ 544 """
681 @type str 572 @type str
682 @return flag indicating a global environment 573 @return flag indicating a global environment
683 @rtype bool 574 @rtype bool
684 """ 575 """
685 if venvName in self.__virtualEnvironments: 576 if venvName in self.__virtualEnvironments:
686 return self.__virtualEnvironments[venvName]["is_global"] 577 return self.__virtualEnvironments[venvName].is_global
687 else: 578 else:
688 return False 579 return False
689 580
690 def isCondaEnvironment(self, venvName): 581 def isCondaEnvironment(self, venvName):
691 """ 582 """
696 @type str 587 @type str
697 @return flag indicating an Anaconda environment 588 @return flag indicating an Anaconda environment
698 @rtype bool 589 @rtype bool
699 """ 590 """
700 if venvName in self.__virtualEnvironments: 591 if venvName in self.__virtualEnvironments:
701 return self.__virtualEnvironments[venvName]["is_conda"] 592 return self.__virtualEnvironments[venvName].is_conda
702 else: 593 else:
703 return False 594 return False
704 595
705 def isRemoteEnvironment(self, venvName): 596 def isRemoteEnvironment(self, venvName):
706 """ 597 """
711 @type str 602 @type str
712 @return flag indicating a remotely accessed environment 603 @return flag indicating a remotely accessed environment
713 @rtype bool 604 @rtype bool
714 """ 605 """
715 if venvName in self.__virtualEnvironments: 606 if venvName in self.__virtualEnvironments:
716 return self.__virtualEnvironments[venvName]["is_remote"] 607 return self.__virtualEnvironments[venvName].is_remote
717 else: 608 else:
718 return False 609 return False
719 610
720 def getVirtualenvExecPath(self, venvName): 611 def getVirtualenvExecPath(self, venvName):
721 """ 612 """
725 @type str 616 @type str
726 @return search path prefix 617 @return search path prefix
727 @rtype str 618 @rtype str
728 """ 619 """
729 if venvName in self.__virtualEnvironments: 620 if venvName in self.__virtualEnvironments:
730 return self.__virtualEnvironments[venvName]["exec_path"] 621 return self.__virtualEnvironments[venvName].exec_path
731 else: 622 else:
732 return "" 623 return ""
733 624
734 def setVirtualEnvironmentsBaseDir(self, baseDir): 625 def setVirtualEnvironmentsBaseDir(self, baseDir):
735 """ 626 """

eric ide

mercurial