Esempio n. 1
0
 def initConnection(self):
     host = Configuration.getworker()['mongo']['host']
     port = Configuration.getworker()['mongo']['port']
     db = Configuration.getworker()['mongo']['db']
     self.mp = MongoPool(host, port, db, self.MAX_CONNECTION)
     #print mp
     return self.mp.getConnection()
Esempio n. 2
0
 def test_worker(self):
     ip = Configuration.getworker()['zookeeper']['ip']
     port = Configuration.getworker()['zookeeper']['port']
     zb = ZooBorg(ip, port)
     worker_id = 'test_worket_id'
     try:
         zb.register(ZooBorg.WORKER, worker_id, self.stubhandler)
         # client id must be in client list
         cl = zb.getList(ZooBorg.WORKER)
         #print "workerlist:",cl
         assert worker_id in cl
         #just created + test infra worker
         assert len(cl) >= 2
     except:
         traceback.print_exc()
         assert 0
     finally:
         zb.unregister(ZooBorg.WORKER, worker_id)
Esempio n. 3
0
import re

from sh import wc
from sh import cat
from sh import mv
from distark.commons.utils.db.mongopool import MongoPool
from distark.commons.utils.MyConfiguration import Configuration

MODE_DESC='description'
MODE_POINT='points'
MODE_PROPERTIES='prop'
MODE_QTE="qte"
MODE_NOTHING='nothing'

MAX_CONN = 1
host = Configuration.getworker()['mongo']['host']
port = Configuration.getworker()['mongo']['port']
db = Configuration.getworker()['mongo']['db']
mp = MongoPool(host, port, db, MAX_CONN)
dbcon = mp.getConnection()
refloat = re.compile('^\d+(\.\d+)*$')


def is_mode_qte(line):
    res=False
    qte = ['100 g', '1 part', '1 pot', u'1 unité', '1 tranche',
           '1 portion', '100 ml', '1 canette', 'c.c.']
    if line in qte:
        res = True

    return res
Esempio n. 4
0
 def test_conf_worker(self):
     assert Configuration.getworker() is not None
     assert Configuration.initialized is True
     assert Configuration.worker_initialized is True
     assert len(Configuration.getworker()['zookeeper']['ip'])>0