def InitPlugins(self, env): """Initializes the plugins that are contained in the given environment. After calling this the list of available plugins can be obtained by calling GetPlugins. @note: plugins must emit the ENTRY_POINT defined in this file in order to be recognized and initialized. @postcondition: all plugins in the environment are initialized """ if pkg_resources == None: return pkg_env = env tmploaded = [name.lower() for name in self._loaded] for name in pkg_env: self.LOG("[pluginmgr][info] Found plugin: %s" % name) if name.lower() in tmploaded: self.LOG("[pluginmgr][info] %s is already loaded" % name) continue egg = pkg_env[name][0] # egg is of type Distrobution egg.activate() editra_version = CalcVersionValue(ed_glob.VERSION) for name in egg.get_entry_map(ENTRYPOINT): try: # Only load a given entrypoint once if name not in self._loaded: entry_point = egg.get_entry_info(ENTRYPOINT, name) cls = entry_point.load() self._loaded.append(name) else: self.LOG("[pluginmgr][info] Skip reloading: %s" % name) continue except Exception, msg: self.LOG("[pluginmgr][err] Couldn't Load %s: %s" % (name, msg)) else: try: # Only initialize plugins that haven't already been # initialized if cls not in self._plugins: self.LOG( "[pluginmgr][info] Creating Instance of %s" % name) instance = cls(self) minv = CalcVersionValue(instance.GetMinVersion()) if minv <= editra_version: self._plugins[cls] = cls(self) self._distros[egg.project_name] = egg else: # Save plugins that are not compatible with # this version to use for notifications. self._obsolete[name] = cls.__module__ else: self.LOG("[pluginmgr][info] Skip re-init of %s" % cls) finally: pass
def GetUpdatesAvailable(self): """Compares the status against the version of the running program to see if updates are available. It is expected that CheckForUpdates has been called prior to calling this function. Returns True if Available and False otherwise. @return: whether udpates are available or not """ if self._status[0].isdigit(): return CalcVersionValue(self._status) > CalcVersionValue(ed_glob.VERSION) else: return False
def run(self): """Run the update check job""" service = UpdateService() result = service.GetCurrentVersionStr() if result.replace('.', '').isdigit(): isupdate = CalcVersionValue(result) > CalcVersionValue(ed_glob.VERSION) else: isupdate = False evt = ed_event.NotificationEvent(ed_event.edEVT_NOTIFY, self.id, (isupdate, result)) wx.PostEvent(self.parent, evt)
def InitPlugins(self, env): """Initializes the plugins that are contained in the given environment. After calling this the list of available plugins can be obtained by calling GetPlugins. @note: plugins must emit the ENTRY_POINT defined in this file in order to be recognized and initialized. @postcondition: all plugins in the environment are initialized """ if pkg_resources == None: return pkg_env = env for name in pkg_env: self.LOG("[pluginmgr][info] Found plugin: %s" % name) egg = pkg_env[name][0] # egg is of type Distrobution egg.activate() for name in egg.get_entry_map(ENTRYPOINT): try: # Only load a given entrypoint once if name not in self._loaded: entry_point = egg.get_entry_info(ENTRYPOINT, name) cls = entry_point.load() self._loaded.append(name) else: continue except Exception, msg: self.LOG("[pluginmgr][err] Couldn't Load %s: %s" % \ (str(name), str(msg))) else: try: # Only initialize plugins that haven't already been # initialized if cls not in self._plugins: self.LOG( "[pluginmgr][info] Creating Instance of %s" % name) instance = cls(self) minv = CalcVersionValue(instance.GetMinVersion()) if minv <= CalcVersionValue(ed_glob.VERSION): self._plugins[cls] = cls(self) else: self._obsolete.append(name) finally: pass
def GetUpdateFiles(self, dl_to=wx.GetHomeDir()): """Gets the requested version of the program from the website if possible. It will download the current files for the host system to location (dl_to). On success it returns True, otherwise it returns false. @keyword dl_to: where to download the file to """ # Check version to see if update is needed # Dont allow update if files are current verpat = re.compile('[0-9]+\.[0-9]+\.[0-9]+') current = self.GetCurrentVersionStr() if not re.match(verpat, current): return False if CalcVersionValue(ed_glob.VERSION) < CalcVersionValue(current): dl_path = self.GetCurrFileURL() dl_file = dl_path.split('/')[-1] dl_to = ebmlib.GetUniqueName(dl_to, dl_file) blk_sz = 4096 read = 0 try: # Download the file in chunks so it can be aborted if need be # inbetween reads. webfile = self.__GetUrlHandle(dl_path) fsize = int(webfile.info()['Content-Length']) locfile = open(dl_to, 'wb') while read < fsize and not self._abort: locfile.write(webfile.read(blk_sz)) read += blk_sz self.UpdaterHook(int(read / blk_sz), blk_sz, fsize) locfile.close() webfile.close() finally: self._abort = False if os.path.exists(dl_to) and \ os.stat(dl_to)[stat.ST_SIZE] == fsize: return True else: return False else: return False
def _UpdatesCheckThread(self): """Sets internal status value to the return value from calling GetCurrentVersionStr. This function is called on a separate thread in the CheckForUpdates function to allow the ui to update properly while this function waits for the result from the network. Returns True to the consumer if updates are available and false if they are not or status is unknown. @return: whether updates are available or not """ self.LOG("[updateprog][evt] Checking for updates") self._checking = True ret = self.GetCurrentVersionStr() self._status = ret self.LOG("[updateprog][evt] Update Check Finished: result = " + ret) if ret[0].isdigit() and \ CalcVersionValue(ret) > CalcVersionValue(ed_glob.VERSION): ret = True else: ret = False return ret