Пример #1
0
def initDataBase(url):

    set_connection_settings()
Пример #2
0
            return projList

    @staticmethod
    def _checkAndApplyChanges(orig, other):
        if 'source' in other:
            source = other.pop('source')
            other.pop('md5Hash', None)
            newHash = getMd5(getMd5(source))
            if orig.md5Hash != newHash:
                orig.source = source
                orig.md5Hash = newHash
        for attr, value in six.iteritems(other):
            setattr(orig, attr, value)

if __name__ == '__main__':
    set_connection_settings(db=7)
    isProject = False
    if isProject:
        a = {'md5Hash': '998889', 'source': 'xxx', 'startUrl': ''}
        pm = ProjectManager('')
        print(pm.createProject(a))
        print(pm.getAllProjects())
        ps = list(pm._projects.keys())
        print(pm._projects)

        # print('-->Ps:{}'.format(ps))
        # print(pm.deleteProject(ps[0], delay=None))
    else:
        # task = Task(url='http://www.baidu.com')
        # print(task.save())
        taskList = Task.query.filter().all()
Пример #3
0
from rom import *
from rom import util
import rom 
util.set_connection_settings(host='10.40.0.190', db=15)

class Person(rom.Model):
    name=String(prefix=True, suffix=True,index=True)
    sex=String(prefix=True, suffix=True,index=True)
    edad=Integer(prefix=True,suffix=True,index=True)
    idPerson=String(prefix=True, suffix=True,index=True)
    description=String(prefix=True, suffix=True,index=True)

import unittest
class TestFilter(unittest.TestCase):
    
    def populate(self):
        # WARNING , it cleans the db
        import redis
        r = redis.StrictRedis(host='10.40.0.190',db=15)
        r.flushdb()
        
        for z in (0,100000):
            objPerson=Person()
            objPerson.name='Julia'
            objPerson.sex='female'
            objPerson.edad=20
            objPerson.ididPerson="8947589545872"
            objPerson.description="ayuntamientodeciudad"
            objPerson.save()
            
            objPerson=Person()
Пример #4
0
import asyncio
import redis
from rom import util
from app import app, config
from app.routes import add_routes

if __name__ == "__main__":
    app.config.from_object(config)
    add_routes(app)
    util.set_connection_settings(host=config.REDIS_HOST, db=config.REDIS_DB)
    server = app.create_server(
        host=app.config.HOST,
        port=app.config.PORT,
        debug=app.config.DEBUG
    )
    loop = asyncio.get_event_loop()
    loop.run_until_complete(server)
    loop.run_forever()
Пример #5
0
def load_json_file(fn) :
    if os.path.isfile(fn) :                                                                                                                          
        with open(fn, 'r+') as fh :
            data = json.load(fh)
        return data
    return None

DB_CONF_FILE  = os.path.expanduser("~") + "/.praxyk/dbconfig/config"
dbconf        = load_json_file(DB_CONF_FILE)
REDIS_CONF    = dbconf['redisdb']

redis_host = REDIS_CONF['dbip']
redis_port = REDIS_CONF['port']
redis_pw   = REDIS_CONF['dbpasswd']
redis_num  = REDIS_CONF['dbnum']
util.set_connection_settings(host=redis_host, password=redis_pw, port=redis_port,  db=redis_num)

class Results(rom.Model) :
    results         = rom.OneToMany('ResultBase', column='transaction')
    transaction_id  = rom.Integer(required=True, unique=True, index=True)
    user_id         = rom.Integer(required=True, index=True)
    size_total_KB   = rom.Float(required=True)
    items_finished  = rom.Integer(required=True, default=0)
    items_total     = rom.Integer(required=True, default=0)


class ResultBase(rom.Model) :
    created_at     = rom.DateTime()
    finished_at    = rom.DateTime()
    item_number    = rom.Integer(required=True, index=True)
    item_name      = rom.String(index=True, required=True, keygen=rom.IDENTITY)