Пример #1
0
	def _main():
		parse_ctx = Context(filename=name)
		#parse_ctx.logger=parse_logger
		try:
			parse(input, interpreter(Context(out=logwrite(logger))),parse_ctx)
		except Exception as e:
			fix_exception(e)
			print_exception(e,file=sys.stderr)
		finally:
			shut_down()
			if ht is not None:
				ht.try_exit()
Пример #2
0
	def process(self, event, **k):
		from homevent.collect import collections
		super(Shutdown_Collections,self).process(**k)

		def byprio(a,b):
			return cmp(a.prio,b.prio)
		for w in sorted(collections.itervalues(),cmp=byprio):
			if not w.can_do("del"):
				continue
			for d in w.values():
				try:
					d.delete(event.ctx)
				except Exception as ex:
					fix_exception(ex)
					print_exception(ex)
Пример #3
0
	def run(self,ctx,**k):

		def getter(out,q):
			while True:
				res = q.get()
				if res is None:
					return
				p,t = res
				if isinstance(t,datetime):
					if TESTING and t.year != 2003:
						t = "%s" % (humandelta(t-now(t.year != 2003)),)
					else:
						t = "%s (%s)" % (humandelta(t-now(t.year != 2003)),t)
					if TESTING:
						lim = 3
					else:
						lim = 4
					ti = t.rfind('.')
					if ti>0 and len(t)-ti>lim and len(t)-ti<lim+6: # limit to msec
						t = t[:ti+lim]+")"

				print >>out,p+u": "+unicode(t)

		event = self.params(ctx)
		c = get_collect(event, allow_collection=True)

		try:
			def out_one(c):
				q = Queue(3)
				try:
					job = spawn(getter,self.ctx.out,q)
					flatten(q,(c,))
				finally:
#					with log_wait("list "+str(event)):
					q.put(None)
					job.join()

			if c is None:
				for m in all_collect(skip=False):
					print >>self.ctx.out, " ".join(m.name)
			elif isinstance(c,Collection):
				if event[-1] == "*":
					for m in c.iteritems():
						print >>self.ctx.out,"* %s :: %s" % (n,m)
						out_one(m)
					return
				for n,m in c.iteritems():
					try:
						m = m.info
					except AttributeError:
						m = m.name
					else:
						if callable(m):
							m = m()
						if isinstance(m,basestring):
							m = m.split("\n")[0].strip()

					if isinstance(n,Name):
						n = u" ".join(unicode(x) for x in n)
					if m is not None:
						print >>self.ctx.out,u"%s :: %s" % (n,m)
					else:
						print >>self.ctx.out,u"%s" % (n,)
			else:
				out_one(c)

		except Exception as e:
			fix_exception(e)
			print >>self.ctx.out, "* ERROR *",repr(e)
			print_exception(e,file=self.ctx.out)
		finally:
			print >>self.ctx.out, "."
Пример #4
0
			def dead(e):
				fix_exception(e)
				print_exception(e)