Esempio n. 1
0
	def execute(self, function, args, user):
		try:
			self.log(function, args, user)
			return function(*(args[0]), user=user, **(args[1])) #pylint: disable-msg=W0142
		except xmlrpc.Fault, exc:
			fault.log(exc)
			raise
Esempio n. 2
0
	def _worker(self):
		global workerthreads
		workerthreads += 1
		try:
			self._run()
		except Exception, exc:
			fault.log(exc)
Esempio n. 3
0
def handleError(error, function, args, kwargs, user):
	if isinstance(error, xmlrpclib.Fault):
		fault.log(error)
	else:
		if not (isinstance(error, TypeError) and function.__name__ in str(error)):
			# not a wrong API call
			fault.log(error)
			logger.log("Exception: %s" % error, user=user.name)
		return fault.wrap(error)
Esempio n. 4
0
	def run(self):
		while not self.event.isSet():
			try:
				self.event.wait(self.timeout)
			except: #pylint: disable-msg=W0702
				return
			if not self.event.isSet():
				try:
					self.func(*self.args, **self.kwargs)
				except Exception, exc: #pylint: disable-msg=W0703
					from tomato import fault
					fault.log(exc)
Esempio n. 5
0
	def run(self):
		set_current_task(self)
		self.started = time.time()
		assert self.status == Status.RUNNING
		if self.fn:
			try:
				self._run()
			except Exception, exc:
				self.result = exc
				fault.log(exc)
				self.output.write('%s:%s' % (exc.__class__.__name__, exc))
				if self.reverseFn:
					self._reverse()
				else:
					self.status = Status.FAILED
Esempio n. 6
0
	def start(self, direct=False):
		try:
			self._prepare()
			if direct:
				self._run()
				return self.dict(True)
			else:
				workers = max(min(min(MAX_WORKERS - workerthreads, MAX_WORKERS_PROCESS), len(self.tasks)), 1)
				while workers>0:
					util.start_thread(self._worker)
					workers -= 1
				return self.id
		except Exception, exc:
			fault.log(exc)
			if direct:
				raise
Esempio n. 7
0
File: tasks.py Progetto: m3z/ToMaTo
	def run(self):
		set_current_task(self)
		self.started = time.time()
		assert self.status == Status.RUNNING
		if self.fn:
			try:
				self._run()
			except Exception, exc:
				self.result = exc
				exc.message += "\nException in task %s (%s)" % (self.name, self.fn) 
				try:
					fault.log(exc)
				except:
					pass #might fail due to aborted db transaction
				self.output.write(('%s:%s' % (exc.__class__.__name__, exc)).encode("utf-8"))
				if self.reverseFn:
					self._reverse()
				else:
					self.status = Status.FAILED
			finally:
Esempio n. 8
0
	def render(self, request):
		try:
			return self.handle(request)
		except xmlrpc.Fault, exc:
			fault.log(exc)
			raise
Esempio n. 9
0
		except xmlrpc.Fault, exc:
			fault.log(exc)
			raise
		except Exception, exc:
			fault.log(exc)
			self.logger.log("Exception: %s" % exc, user=user.name)
			raise fault.wrap(exc)

	def render(self, request):
		try:
			return self.handle(request)
		except xmlrpc.Fault, exc:
			fault.log(exc)
			raise
		except Exception, exc:
			fault.log(exc)
			raise fault.wrap(exc)
		
	def handle(self, request):
		username=request.getUser()
		passwd=request.getPassword()
		user=self.login(username, passwd)
		if not user:
			request.setResponseCode(http.UNAUTHORIZED)
			if username=='' and passwd=='':
				return 'Authorization required!'
			else:
				return 'Authorization Failed!'
		request.content.seek(0, 0)
		args, functionPath=xmlrpclib.loads(request.content.read())
		function = None