def metarefresh(self): noid_msg = "Error: Entity %s doesn't have entityid" % (self.id) if not hasattr(self, 'entityid'): return noid_msg url = self.entityid if not url: return noid_msg try: text = fetch_resource(url) if text is None: text = fetch_resource('http://' + url) if text is None: return 'Unknown error while fetching the url' except FetchError as e: return str(e) if not text: return 'Empty metadata not allowed' content = write_temp_file(text) name = self.metadata.name commit_msg = 'Updated automatically from %s' % (url) self.metadata.save(name, content, self.owner.username, commit_msg) self.metarefresh_last_run = datetime.now() self.save() return 'Success: Data was updated successfully'
def metarefresh(self): noid_msg = "Error: Entity %s doesn't have entityid" % (self.id) if not hasattr(self, 'entityid'): return noid_msg url = self.entityid if not url: return noid_msg try: text = fetch_resource(url) if text is None: text = fetch_resource('http://' + url) if text is None: return 'Unknown error while fetching the url' except FetchError as e: return str(e) if not text: return 'Empty metadata not allowed' content = write_temp_file(text) name = self.metadata.name commit_msg = 'Updated automatically from %s' % (url) self.metadata.save(name, content, self.owner.username, commit_msg) self.metarefresh_last_run = datetime.now() self.save() return 'Success: Data was updated successfully'
def _field_value_to_metadata(self, remote_url): try: data = fetch_resource(remote_url) if data is None: data = fetch_resource('http://' + remote_url) if data is None: raise forms.ValidationError('Unknown error while fetching the url') except FetchError, e: raise forms.ValidationError(str(e))
def _field_value_to_metadata(self, remote_url): try: data = fetch_resource(remote_url) if data is None: data = fetch_resource('http://' + remote_url) if data is None: raise forms.ValidationError('Unknown error while fetching the url') except FetchError as e: raise forms.ValidationError(str(e)) return data
def check_endpoints(entity, verbosity): errors = [] if verbosity > 1: print u'Monitoring entity %s' % entity if entity.has_metadata(): for endpoint in entity.endpoints: location = endpoint['Location'] if verbosity > 1: print u'\tChecking availability of %s' % location try: fetch_resource(location, decode=False) except FetchError, e: errors.append({'endpoint': location, 'exception': e})
def check_endpoints(entity, verbosity): errors = [] if verbosity > 1: print u'Monitoring entity %s' % entity if entity.has_metadata(): for endpoint in entity.endpoints: location = endpoint['Location'] if verbosity > 1: print u'\tChecking availability of %s' % location try: fetch_resource(location, decode=False) except FetchError, e: errors.append({'endpoint': location, 'exception': e})
def metarefresh(self): noid_msg = "Error: Entity %s doesn't have entityid" % (self.id) if not hasattr(self, "entityid"): return noid_msg url = self.entityid if not url: return noid_msg try: text = fetch_resource(url) if text is None: text = fetch_resource("http://" + url) if text is None: return "Unknown error while fetching the url" except FetchError, e: return str(e)