def _download(self): #logger.debug('Reading resource %s for client %s' % (self._scheduler, self._client)) url = urlparse(self._scheduler) certificate = self._client.isp.certificate connection = httputils.getverifiedconnection(url = url, certificate = certificate, timeout = self._httptimeout) try: connection.request('GET', '%s?clientid=%s&version=%s&confid=%s' % (url.path, self._client.id, __version__, self._md5conf)) data = connection.getresponse().read() except Exception as e: logger.error('Impossibile scaricare lo scheduling. Errore: %s.' % e) self._updatestatus(Status(status.ERROR, 'Impossibile dialogare con lo scheduler delle misure.')) return None return xml2task(data)
def test(self, taskfile = None): task = None if (taskfile == None): # Test di download di un file di scheduling task = self._download() logger.debug('Test scaricamento task:\n\t%s' % task) else: with open(taskfile, 'r') as file: task = xml2task(file.read()) if (task != None): logger.debug('Test esecuzione task:') self._dotask(task) else: logger.info('Nessun task da eseguire.')