def need_update(self): payload = {'os': 'osx', 'branch': self.branch} r = requests.get(self.base_url, params=payload) json = r.json() self.response.externalVersion = common.makeVersionHuman(json['major'], json['minor'], json['revision'], json['build']) if common.isThisVersionNewer(json['major'], json['minor'], json['revision'], json['build']): self.response.needUpdate = True msg = 'Update available %s' % self.response.externalVersion log.info(msg) self.response.message = msg else: self.response.needUpdate = False self.response.message = 'No update available' return self.response
def need_update(self): payload = {'os': 'osx', 'branch': self.branch} r = requests.get(self.base_url, params=payload) json = r.json() self.response.externalVersion = common.makeVersionHuman( json['major'], json['minor'], json['revision'], json['build']) if common.isThisVersionNewer(json['major'], json['minor'], json['revision'], json['build']): self.response.needUpdate = True msg = 'Update available %s' % self.response.externalVersion log.info(msg) self.response.message = msg else: self.response.needUpdate = False self.response.message = 'No update available' return self.response
def install(self, identifier, doCleanUp=True): self._prepareIntall() self.install_messages = [('info', 'install.py -i %s' % identifier)] self.setNewMessage('info', 'Getting download URL') plugin_to_update = None for repo in self.repos: for _repo_plugin in repo.getPlugins(): if _repo_plugin.identifier == identifier: plugin_to_update = _repo_plugin break if plugin_to_update is None: self.setNewMessage( 'error', 'Could not find a plugin with identifier %s' % identifier) self.setNewMessage('info', 'Done!') return if not plugin_to_update.xdmMeetsVersionRequirement(): self.setNewMessage( 'error', 'The plugin requires XDM version %s or higher you have %s' % (common.makeVersionHuman(*plugin_to_update.xdm_version)), common.getVersionHuman()) self.setNewMessage( 'info', 'by the way how did you even get here ? the GUI should not have allowed this to begin with!' ) self.setNewMessage('info', 'Done!') return self.setNewMessage( 'info', 'Installing %s(%s)' % (plugin_to_update.name, plugin_to_update.versionHuman())) old_instalation = None for plugin in common.PM.getAll(returnAll=True, instance='Default'): if plugin.identifier == plugin_to_update.identifier: if not self._updateable(plugin_to_update, plugin): self.setNewMessage( 'error', '%s is already installed and does not need an update' % plugin_to_update.name) self.setNewMessage('info', 'Done!') return else: self.setNewMessage( 'info', '%s is already installed but has an update' % plugin_to_update.name) old_instalation = plugin break else: self.setNewMessage( 'info', '%s is not yet installed' % plugin_to_update.name) if old_instalation is not None: old_plugin_path = os.path.abspath( old_instalation.get_plugin_isntall_path()['path']) old_plugin_path_parent = os.path.abspath( os.path.join(old_plugin_path, os.pardir)) self.setNewMessage( 'info', 'Renaming old install path %s' % old_plugin_path) new_dir = '__old__%s %s %s' % (plugin.type, plugin.identifier, plugin.version) new_dir = new_dir.replace(' ', '-').replace('.', '_') new_path = os.path.join(old_plugin_path_parent, new_dir) self.setNewMessage('info', 'to %s' % new_path) os.rename(old_plugin_path, new_path) if plugin_to_update.format == 'zip': downloader = ZipPluginInstaller() else: self.setNewMessage( 'error', 'Format %s is not supported. sorry' % plugin_to_update.format) self.setNewMessage('info', 'Done!') return install_path = common.SYSTEM.c.extra_plugin_path self.setNewMessage('info', 'Installing into %s' % install_path) if self.lastDownload != plugin_to_update.download_url: log('old: "%s" is not new: "%s", cleaning temp folder (%s) downloading new url and setting old to nothing.' % (self.lastDownload, plugin_to_update.download_url, xdm.TEMPPATH)) helper.cleanTempFolder() self.lastDownload = '' self.setNewMessage('info', 'Downloading, please wait...') else: self.setNewMessage('info', 'Downloaded this file already.') install_result = False try: install_result = downloader.install(self, plugin_to_update, install_path) except Exception as ex: log.error('Something went wrong during download') self.setNewMessage('error', 'Error during download') self.setNewMessage('error', '%s' % ex) if install_result: self.setNewMessage('info', 'Installation successful!') if doCleanUp: self.doCleanUp() else: self.setNewMessage('error', 'Installation unsuccessful!')
def install(self, identifier): self._prepareIntall() self.install_messages = [('info', 'install.py -i %s' % identifier)] self.setNewMessage('info', 'Getting download URL') plugin_to_update = None for repo in self.repos: for repo_plugin in repo.getPlugins(): if repo_plugin.identifier == identifier: plugin_to_update = repo_plugin break if plugin_to_update is None: self.setNewMessage('error', 'Could not find a plugin with identifier %s' % identifier) self.setNewMessage('info', 'Done!') return if not plugin_to_update.xdmMeetsVersionRequirement(): self.setNewMessage('error', 'The plugin requires XDM version %s or higher you have %s' % (common.makeVersionHuman(*plugin_to_update.xdm_version)), common.getVersionHuman()) self.setNewMessage('info', 'by the way how did you even get here ? the GUI should not have allowed this to begin with!') self.setNewMessage('info', 'Done!') return self.setNewMessage('info', 'Installing %s(%s)' % (plugin_to_update.name, plugin_to_update.versionHuman())) old_instalation = None for plugin in common.PM.getAll(returnAll=True, instance='Default'): if plugin.identifier == plugin_to_update.identifier: if not self._updateable(plugin_to_update, plugin): self.setNewMessage('error', '%s is already installed and does not need an update' % plugin_to_update.name) self.setNewMessage('info', 'Done!') return else: self.setNewMessage('info', '%s is already installed but has an update' % plugin_to_update.name) old_instalation = plugin break else: self.setNewMessage('info', '%s is not yet installed' % plugin_to_update.name) if old_instalation is not None: old_plugin_path = os.path.abspath(old_instalation.get_plugin_isntall_path()) old_plugin_path_parent = os.path.abspath(os.path.join(old_plugin_path, os.pardir)) self.setNewMessage('info', 'Renaming old install path %s' % old_plugin_path) new_dir = '__old__%s%s' % (plugin.type, plugin.version) new_dir = new_dir.replace(' ', '-').replace('.', '_') new_path = os.path.join(old_plugin_path_parent, new_dir) self.setNewMessage('info', 'to %s' % new_path) os.rename(old_plugin_path, new_path) if repo_plugin.format == 'zip': downloader = ZipPluginInstaller() else: self.setNewMessage('error', 'Format %s is not supported. sorry' % plugin_to_update.format) self.setNewMessage('info', 'Done!') return install_path = common.SYSTEM.c.extra_plugin_path self.setNewMessage('info', 'Installing into %s' % install_path) self.setNewMessage('info', 'Starting download. please wait...') install_result = False try: install_result = downloader.install(self, plugin_to_update, install_path) except Exception as ex: log.error('Something went wrong during download') self.setNewMessage('error', 'Error during download') self.setNewMessage('error', '%s' % ex) if install_result: self.setNewMessage('info', 'Installation successful') self.setNewMessage('info', 'Recaching plugins...') actionManager.executeAction('recachePlugins', ['RepoManager']) self.setNewMessage('info', 'Recaching pugins done.') self.setNewMessage('info', 'Recaching repos...') self.cache() self.setNewMessage('info', 'Recaching repos done. (please refresh page)') else: self.setNewMessage('error', 'Installation unsuccessful') self.setNewMessage('info', 'Done!')
def install(self, identifier, doCleanUp=True): self._prepareIntall() self.install_messages = [("info", "install.py -i %s" % identifier)] self.setNewMessage("info", "Getting download URL") plugin_to_update = None for repo in self.repos: for _repo_plugin in repo.getPlugins(): if _repo_plugin.identifier == identifier: plugin_to_update = _repo_plugin break if plugin_to_update is None: self.setNewMessage("error", "Could not find a plugin with identifier %s" % identifier) self.setNewMessage("info", "Done!") return if not plugin_to_update.xdmMeetsVersionRequirement(): self.setNewMessage( "error", "The plugin requires XDM version %s or higher you have %s" % (common.makeVersionHuman(*plugin_to_update.xdm_version)), common.getVersionHuman(), ) self.setNewMessage( "info", "by the way how did you even get here ? the GUI should not have allowed this to begin with!" ) self.setNewMessage("info", "Done!") return self.setNewMessage("info", "Installing %s(%s)" % (plugin_to_update.name, plugin_to_update.versionHuman())) old_instalation = None for plugin in common.PM.getAll(returnAll=True, instance="Default"): if plugin.identifier == plugin_to_update.identifier: if not self._updateable(plugin_to_update, plugin): self.setNewMessage( "error", "%s is already installed and does not need an update" % plugin_to_update.name ) self.setNewMessage("info", "Done!") return else: self.setNewMessage("info", "%s is already installed but has an update" % plugin_to_update.name) old_instalation = plugin break else: self.setNewMessage("info", "%s is not yet installed" % plugin_to_update.name) if old_instalation is not None: old_plugin_path = os.path.abspath(old_instalation.get_plugin_isntall_path()["path"]) old_plugin_path_parent = os.path.abspath(os.path.join(old_plugin_path, os.pardir)) self.setNewMessage("info", "Renaming old install path %s" % old_plugin_path) new_dir = "__old__%s %s %s" % (plugin.type, plugin.identifier, plugin.version) new_dir = new_dir.replace(" ", "-").replace(".", "_") new_path = os.path.join(old_plugin_path_parent, new_dir) self.setNewMessage("info", "to %s" % new_path) os.rename(old_plugin_path, new_path) if plugin_to_update.format == "zip": downloader = ZipPluginInstaller() else: self.setNewMessage("error", "Format %s is not supported. sorry" % plugin_to_update.format) self.setNewMessage("info", "Done!") return install_path = common.SYSTEM.c.extra_plugin_path self.setNewMessage("info", "Installing into %s" % install_path) if self.lastDownload != plugin_to_update.download_url: log( 'old: "%s" is not new: "%s", cleaning temp folder (%s) downloading new url and setting old to nothing.' % (self.lastDownload, plugin_to_update.download_url, xdm.TEMPPATH) ) helper.cleanTempFolder() self.lastDownload = "" self.setNewMessage("info", "Downloading, please wait...") else: self.setNewMessage("info", "Downloaded this file already.") install_result = False try: install_result = downloader.install(self, plugin_to_update, install_path) except Exception as ex: log.error("Something went wrong during download") self.setNewMessage("error", "Error during download") self.setNewMessage("error", "%s" % ex) if install_result: self.setNewMessage("info", "Installation successful!") if doCleanUp: self.doCleanUp() else: self.setNewMessage("error", "Installation unsuccessful!")
def install(self, identifier, doCleanUp=True): """install a plugin #. checks if plugin is already installed #. checks if plugins is installed but has an update, if so move the old version to __old__oldFolderName #. chooses install method by the given "format" e.g. "zip" #. use the Appropriate installer #. if doCleanUp was True doCleanUp_ is called .. _doCleanUp: """ self._prepareIntall() self.install_messages = [('info', 'install.py -i %s' % identifier)] self.setNewMessage('info', 'Getting download URL') plugin_to_update = None for repo in self.repos: for _repo_plugin in repo.getPlugins(): if _repo_plugin.identifier == identifier: plugin_to_update = _repo_plugin break if plugin_to_update is None: self.setNewMessage('error', 'Could not find a plugin with identifier %s' % identifier) self.setNewMessage('info', 'Done!') return if not plugin_to_update.xdmMeetsVersionRequirement(): self.setNewMessage('error', 'The plugin requires XDM version %s or higher you have %s' % (common.makeVersionHuman(*plugin_to_update.xdm_version)), common.getVersionHuman()) self.setNewMessage('info', 'by the way how did you even get here ? the GUI should not have allowed this to begin with!') self.setNewMessage('info', 'Done!') return self.setNewMessage('info', 'Installing %s(%s)' % (plugin_to_update.name, plugin_to_update.versionHuman())) old_instalation = None for plugin in common.PM.getAll(returnAll=True, instance='Default'): if plugin.identifier == plugin_to_update.identifier: if not self._updateable(plugin_to_update, plugin): self.setNewMessage('error', '%s is already installed and does not need an update' % plugin_to_update.name) self.setNewMessage('info', 'Done!') return else: self.setNewMessage('info', '%s is already installed but has an update' % plugin_to_update.name) old_instalation = plugin break else: self.setNewMessage('info', '%s is not yet installed' % plugin_to_update.name) if old_instalation is not None: old_plugin_path = os.path.abspath(old_instalation.get_plugin_isntall_path()['path']) old_plugin_path_parent = os.path.abspath(os.path.join(old_plugin_path, os.pardir)) self.setNewMessage('info', 'Renaming old install path %s' % old_plugin_path) new_dir = '__old__%s %s %s' % (plugin.type, plugin.identifier, plugin.version) new_dir = new_dir.replace(' ', '-').replace('.', '_') new_path = os.path.join(old_plugin_path_parent, new_dir) self.setNewMessage('info', 'to %s' % new_path) os.rename(old_plugin_path, new_path) if plugin_to_update.format == 'zip': downloader = ZipPluginInstaller() elif plugin_to_update.format == 'github': downloader = GithubPluginInstaller() else: self.setNewMessage('error', 'Format %s is not supported. sorry' % plugin_to_update.format) self.setNewMessage('info', 'Done!') return install_path = common.SYSTEM.c.extra_plugin_path self.setNewMessage('info', 'Installing into %s' % install_path) if self.lastDownload != plugin_to_update.download_url: log('old: "%s" is not new: "%s", cleaning temp folder (%s) downloading new url and setting old to nothing.' % (self.lastDownload, plugin_to_update.download_url, xdm.TEMPPATH)) helper.cleanTempFolder() self.lastDownload = '' self.setNewMessage('info', 'Downloading, please wait...') else: self.setNewMessage('info', 'Downloaded this file already.') install_result = False try: install_result = downloader.install(self, plugin_to_update, install_path) except Exception as ex: log.error('Something went wrong during download') self.setNewMessage('error', 'Error during download') self.setNewMessage('error', '%s' % ex) if install_result: self.setNewMessage('info', 'Installation successful!') if doCleanUp: self.doCleanUp() else: self.setNewMessage('error', 'Installation unsuccessful!')