2 # vim: set et sw=4 sts=4 encoding=utf-8 foldmethod=marker :
5 locale.setlocale(locale.LC_ALL, '')
8 pkg_resources.require("TurboGears")
10 from turbogears import update_config, start_server
12 cherrypy.lowercase_api = True
16 # first look on the command line for a desired config file,
17 # if it's not on the command line, then
18 # look for setup.py in this directory. If it's not there, this script is
21 update_config(configfile=sys.argv[1],
22 modulename="sercom.config")
23 elif exists(join(dirname(__file__), "setup.py")):
24 update_config(configfile="dev.cfg",modulename="sercom.config")
26 update_config(configfile="prod.cfg",modulename="sercom.config")
28 from sercom.model import InstanciaDeEntrega, Entrega, AND, hub
29 from sercom.finalizer import Finalizer
30 from threading import Thread
31 from datetime import datetime
35 log = logging.getLogger('sercom.tester')
37 class Queue(object): #{{{
45 select = InstanciaDeEntrega.select(AND(
46 InstanciaDeEntrega.q.inicio_proceso == None,
47 InstanciaDeEntrega.q.fin <= datetime.now()))
48 instancia = select.orderBy(InstanciaDeEntrega.q.fin)[0]
49 instancia.inicio_proceso = datetime.now()
54 log.debug(_(u'No hay instancias de entrega sin finalizar'))
55 time.sleep(30) # TODO config?
57 if isinstance(e, SystemExit):
59 log.exception('Queue: ')
60 time.sleep(30) # TODO config?
65 #finalizer = Finalizer(name='juanca', queue=q)
66 #t = Thread(name='juanca', target=finalizer.run)
69 from sercom.controllers import Root