def activate(): logger = logging.getLogger() logger.debug("Pkgs is activating") config = PkgsConfig("pkgs") if config.disabled: logger.warning("Plugin pkgs: disabled by configuration.") return False return True
def activate(): logger = logging.getLogger() logger.debug("Pkgs is activating") config = PkgsConfig("pkgs") if config.disabled: logger.warning("Plugin pkgs: disabled by configuration.") return False DashboardManager().register_panel(Panel('appstream')) TaskManager().addTask("pkgs.updateAppstreamPackages", (updateAppstreamPackages, ), cron_expression='23 10 * * *') return True
def updateAppstreamPackages(self): """ This methode update appstream package and download package who need to be download. It can effectly work only one at a time. @rtype: bool @return: True if done,False if already working. """ # if an other update is working, don't update. if self.update: return False self.update = True tempfile.tempdir = '/var/tmp/' logger = logging.getLogger() appstream_url = PkgsConfig("pkgs").appstream_url #add non downloaded package to download package list for pkg, details in getActivatedAppstreamPackages().iteritems(): try: # Creating requests session s = requests.Session() s.auth = ('appstream', details['key']) base_url = '%s/%s/' % (appstream_url, pkg) # Get Package uuid r = s.get(base_url + 'info.json') if not r.ok: raise Exception("Cannot get package metadata. Status: %d" % (r.status_code)) info = parse_json(r.content.strip()) uuid = info['uuid'] # If package is already downloaded, skip logger.debug('Got UUID %s, checking if it already exists ...' % uuid) if not uuid or os.path.exists( '/var/lib/pulse2/appstream_packages/%s/' % uuid): continue #add package to download package list self._add_appstream(pkg) except Exception, e: logger.error('Appstream: Error while fetching package %s' % pkg) logger.error(str(e))
def getPServerTmpDir(self): config = PkgsConfig("pkgs") return config.tmp_dir
def getPServerIP(self): config = PkgsConfig("pkgs") return config.upaa_server