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, 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.selectBy(inicio_proceso=None)
46 instancia = select.orderBy(InstanciaDeEntrega.q.fin)[0]
47 instancia.inicio_proceso = datetime.now()
52 log.debug(_(u'No hay instancias de entrega sin finalizar'))
53 time.sleep(30) # TODO config?
55 if isinstance(e, SystemExit):
57 log.exception('Queue: ')
58 time.sleep(30) # TODO config?
63 #finalizer = Finalizer(name='juanca', queue=q)
64 #t = Thread(name='juanca', target=finalizer.run)
67 from sercom.controllers import Root