Exemplo n.º 1
0
logging.basicConfig(level=logging.DEBUG)

import time
from scrapy import log
from scrapy.conf import settings

from ec2.redis import RedisDb
from ec2.scrapy.puller import ChannelsPuller
from ec2.conf.enabled import ws_conf

from ec2.scrapy.worker import Ctrl
from ec2.utils import event

log.start()

db = RedisDb(pre='MQ')

puller = ChannelsPuller(db, 'xxx')
ctrl = Ctrl(settings, puller)

url = 'http://%s/test/slow_echo/%%s_%%s' % ws_conf['client']


def test_data():
    for i in xrange(200):
        db.queue_push('xxx', [
            {
                'url': url % (
                    i,
                    int(time.time()),
                ),
Exemplo n.º 2
0
        x,y = xy
        
        v = np.ndarray( (h,w),dtype=arr.dtype)
        v.fill(0)
        e= arr[x-h/2:x+h/2,y-w/2:y+w/2]
        _h,_w = e.shape
        v[:_h,:_w] = e
        return  v.reshape((h*w,))



#----------------------------------
if __name__=='__main__':
    from ec2.redis import RedisDb

    db = RedisDb(pre='MQ')
    d = Decoder(path='../data')
    for i in xrange(10):
        e = db.select_fields('sz_images',i+1, ['body',])
        if not e['body']: continue

        fh = open('d:/temp/sz_%s.png'%(i+1) , 'wb')
        fh.write(e['body'])
        fh.close()

        #d.Debug = 1
        code = d.img2code(e['body'])
        print '%s:%s'%(i+1, code) 

    #im.save('d:/temp/szqqq.png')
Exemplo n.º 3
0
def test_db():
    db = RedisDb(pre='MQ')
Exemplo n.º 4
0
        h, w = self.fonts[k][1].shape
        x, y = xy

        v = np.ndarray((h, w), dtype=arr.dtype)
        v.fill(0)
        e = arr[x - h / 2:x + h / 2, y - w / 2:y + w / 2]
        _h, _w = e.shape
        v[:_h, :_w] = e
        return v.reshape((h * w, ))


#----------------------------------
if __name__ == '__main__':
    from ec2.redis import RedisDb

    db = RedisDb(pre='MQ')
    d = Decoder(path='../data')
    for i in xrange(10):
        e = db.select_fields('sz_images', i + 1, [
            'body',
        ])
        if not e['body']: continue

        fh = open('d:/temp/sz_%s.png' % (i + 1), 'wb')
        fh.write(e['body'])
        fh.close()

        #d.Debug = 1
        code = d.img2code(e['body'])
        print '%s:%s' % (i + 1, code)
Exemplo n.º 5
0
#coding=utf-8


import logging, json 


from ec2.redis import RedisDb

logging.basicConfig(level=logging.INFO) #DEBUG)
db = RedisDb(pre='MQ')

_base_header = {
    'Host': 'cgs1.stc.gov.cn',
    'Connection': 'keep-alive',
    'Referer': 'http://cgs1.stc.gov.cn',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Encoding': 'gzip,deflate',
    'Accept-Language': 'en',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20100101 Firefox/10.0', 
}



_users = {
  '360502198502241612':{
    'exam': '2',
    'name': '肖春辉',
  },          
  '511121197802126810':{
    'exam': '2',
Exemplo n.º 6
0
import logging,sys
import gevent
from gevent import monkey;monkey.patch_all()

from ec2.redis  import RedisDb
from ec2.websocket import client

logging.basicConfig(level=logging.DEBUG)

MQ_PREFIX = 'MQ'
db   = RedisDb(pre=MQ_PREFIX)


#--------------------------------
def main():
    url = "ws://192.168.1.230:9090/ws/chnl/test2"
    #url = "ws://www.ectwo.com.cn/ws/chnl/test"
    
    #ctrl = client.DumpCtrlet(url)
    ctrl = client.EchoCtrlet(db, 'client:echo', url)
    
    try:
        ctrl.start()
    except KeyboardInterrupt:
        ctrl.stop()
        print '\nbye'



if __name__ == "__main__":