Exemplo n.º 1
0
	def submitStatement(self, jsonObject):	  
		##Attempts to submit a single statement
		try:
			##Validates that the verb is valid
			if(not dataValidation.validateVerb(jsonObject['verb'])):
				raise ValueError("INVALID VERB: "+jsonObject['verb'])

			resp = requests.post(self._endpoint,
				            data=json.dumps(jsonObject),
				            auth=HTTPBasicAuth(self._userName,self._secret),
				            headers={"Content-Type":"application/json"})
			
		except IOError as e:
			if self.logger is not None:
				self.logger.error(e)
Exemplo n.º 2
0
	def submitStatementList(self, jsonObjectList):
		##Submits a list of Statements
		for statement in jsonObjectList:	
			try:
				##Validates that the verb is valid
				if(not dataValidation.validateVerb(statement['verb'])):
					raise ValueError("INVALID VERB: "+statement['verb'])


				resp = requests.post(self._endpoint,
				            data=json.dumps(statement),
				            auth=HTTPBasicAuth(self._userName,self._secret),
				            headers={"Content-Type":"application/json"})
			except IOError as e:
				if self.logger is not None:
					self.logger.error(e)
				else:
					print e