Changeset 11025:b69249383d87 in orange


Ignore:
Timestamp:
11/14/12 13:29:40 (17 months ago)
Author:
Matija Polajnar <matija.polajnar@…>
Branch:
default
Message:

Add-ons: enable uninstallation on systems with pip installed.

Location:
Orange
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/orngDlgs.py

    r11023 r11025  
    77from orngCanvasItems import MyCanvasText 
    88import OWGUI, sys, os 
     9 
     10has_pip = True 
     11try: 
     12    import pip.req 
     13except ImportError: 
     14    has_pip = False 
    915 
    1016# this class is needed by signalDialog to show widgets and lines 
     
    941947 
    942948    def cbToggled(self, item): 
     949        ao = self.getAddOnFromItem(item) 
     950        if ao and not has_pip and ao.installed_version and item.checkState()==Qt.Unchecked: 
     951            QMessageBox.warning(self, "Unable to uninstall", "Pip is not installed on your system. Without it, automated removal of add-ons is not possible.\n\nInstall pip (try 'easy_install --user pip') and restart Orange to make this action possible.") 
     952            item.setCheckState(Qt.Checked) 
    943953        self.refreshInfoPane(item) 
    944954 
  • Orange/utils/addons.py

    r11024 r11025  
    247247        func() 
    248248 
    249 def uninstall(name, progress_callback=None): #TODO 
    250     raise Exception('Unable to uninstall %s: uninstallation of add-ons is not yet implemented.' % name) 
    251     # Implement this either by using pip.commands.uninstall, and complain if pip is not installed on the system, 
    252     # or by "stealing" pip's uninstallation code. 
     249def uninstall(name, progress_callback=None): 
     250    try: 
     251        import pip.req 
     252        ao = pip.req.InstallRequirement(name, None) 
     253        ao.uninstall(True) 
     254    except ImportError: 
     255        raise Exception("Pip is required for add-on uninstallation. Install pip and try again.") 
    253256 
    254257def upgrade(name, progress_callback=None): 
Note: See TracChangeset for help on using the changeset viewer.