示例#1
0
def build_img_car():
    # 构造图片福利
    img_car = ImgCar()
    img_car.crude(topic='港媒:歼20跻身世界最先进喷气式战机 可媲美F-22',
                  catalog=1,
                  publish_time=time.time(),
                  catch_time=time.time())
    img1 = Img()
    img1.crude(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534330777385&di=8964941d79e54f50dd9c6e4d98ac60c4&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn19%2F266%2Fw640h426%2F20180515%2F87a4-hapkuvm3684064.jpg"
    )
    img2 = Img()
    img2.crude(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534330776990&di=e8c53a8af0f68b8059662f19010e9632&imgtype=0&src=http%3A%2F%2Fimg9.itiexue.net%2F2150%2F21502461.jpg"
    )
    img3 = Img()
    img3.crude(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534330777390&di=8cf6b983eddd9647e93f374fabd22e6f&imgtype=0&src=http%3A%2F%2F05.imgmini.eastday.com%2Fmobile%2F20171130%2F20171129_b7878026d7a51dc98fce24404c854ea9_mwpm_05501609.jpg"
    )
    img4 = Img()
    img4.crude(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534330777390&di=9336e2b0e72f9d6f38f891c45d3c3931&imgtype=0&src=http%3A%2F%2F01.imgmini.eastday.com%2Fmobile%2F20170707%2F20170707010832_397dc7df28461ca39fb9150d0cdc47ae_2.jpeg"
    )
    img5 = Img()
    img5.crude(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534330777389&di=2f35a3e47fb787fa53d994fe7915d393&imgtype=0&src=http%3A%2F%2F01.imgmini.eastday.com%2Fmobile%2F20171017%2F1d9c2db83ffd9d7221f9220647e57514.jpeg"
    )
    img_car.add_img(img1)
    img_car.add_img(img2)
    img_car.add_img(img3)
    img_car.add_img(img4)
    img_car.add_img(img5)

    return img_car
 def on_msg_receive(self, channel, method, properties, body):
     #记录日志
     log_info("=======================================================")
     log_info("收到消息:%s" % (body))
     #字符串转换为对象
     img_car = ImgCar.deserialize(body)
     self.msg_receive_event_handler(img_car)
示例#3
0
 def __init__(self, img_car=ImgCar()):
     self.img_car = img_car
     self.__img_file_rule = ImgFileRule()
     self.__img_file_storager = ImgFileStorager(self.img_car)
     self.__img_car_repository = ImgCarRepository()
     self.img_file_path_algorithm_func = lambda img_car, img: self.__img_file_rule.build_img_file_relative_path(
     img_car.catalog, img_car.topic, img.no)
示例#4
0
 def publish_msg(self,img_car=ImgCar()):
     img_car_msg=str(img_car)
     #建立通道
     channel=core.rabbitmq.create_channel(self.__msg_queue_service_config.host,self.__msg_queue_service_config.user,self.__msg_queue_service_config.pwd)
     #申明队列
     channel.queue_declare(queue=self.__queue_name)
     #f发布消息
     channel.basic_publish(exchange='', routing_key=self.__queue_name, body=img_car_msg)
     #关闭连接
     channel.connection.close()
     log_info('发布图片福利消息:%s' % (img_car_msg))
示例#5
0
def _img_car_doc_2_entity(img_doc):
    """return value of object for pickling.
           needed explicitly because __slots__() defined.
           """
    img_urls = []
    if img_doc.has_key('img_urls'):
        img_urls = img_doc['img_urls']
    img = ImgCar(str(img_doc['_id']), img_doc['title'], img_doc['catalog'],
                 img_doc['num'], img_urls, img_doc['publish_time'],
                 img_doc['catch_time'])
    return img
示例#6
0
    def add_img_car(self, img_car=ImgCar()):
        """
                获取指定ID的图片
                :param id:  tuple of (short opt, long opt), e.g: ('-f', '--format')
                :return:图片集合
                """
        id = ''

        img_car_json = JsonConvert.serialize_object(img_car, ['id'])
        img_car_json2 = img_car.to_json()
        result = self.__db.ImgCar.insert_one(img_car_json)
        result = self.__db[''].insert_one(img_car_json)
        id = str(result.inserted_id)

        return id
示例#7
0
def _img_car_entity_2_json(img_car=ImgCar()):
    """
        图片实体转换为json对象
        :param img_car:  图片实体
        :return:图片集合
        """
    # img_car_json={
    #     "title" : img_car.title,
    #     "catchTime" : img_car.catch_time,
    #     "publishTime" : img_car.publish_time,
    #     "catalog" : img_car.catalog,
    #     "num" : img_car.num,
    #     "imgUrls" : img_car.img_urls
    # }

    img_car_json = json.dumps(img_car)
    print img_car_json

    return img_car_json
示例#8
0
 def __init__(self, img_car=ImgCar()):
     self.img_car = img_car
示例#9
0
def img_car_deserialize_test():
    img_car_json_str = str(build_img_car())
    print 'img_car_json_obj:%s' % img_car_json_str
    img_car_json_obj = ImgCar.deserialize(img_car_json_str)
    print 'img_car_json_obj:%s' % str(img_car_json_obj)
示例#10
0
student2=Student(2,"王锦怡")
student3=Student(3,"何茜")
students=[]
students.append(student1)
students.append(student2)
students.append(student3)

class1=Class(1)
class1.add_student(student1)
class1.add_student(student2)
class1.add_student(student3)
class2=Class(0,)
class3=Class()

# 构造图片福利
img_car = ImgCar()
img_car.crude(topic='港媒:歼20跻身世界最先进喷气式战机 可媲美F-22', catalog=1, publish_time=time.time(),
              catch_time=time.time())
img1 = Img()
img1.crude(
    "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534330777385&di=8964941d79e54f50dd9c6e4d98ac60c4&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn19%2F266%2Fw640h426%2F20180515%2F87a4-hapkuvm3684064.jpg")
img2 = Img()
img2.crude(
    "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534330776990&di=e8c53a8af0f68b8059662f19010e9632&imgtype=0&src=http%3A%2F%2Fimg9.itiexue.net%2F2150%2F21502461.jpg")
img3 = Img()
img3.crude(
    "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534330777390&di=8cf6b983eddd9647e93f374fabd22e6f&imgtype=0&src=http%3A%2F%2F05.imgmini.eastday.com%2Fmobile%2F20171130%2F20171129_b7878026d7a51dc98fce24404c854ea9_mwpm_05501609.jpg")
img4 = Img()
img4.crude(
    "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534330777390&di=9336e2b0e72f9d6f38f891c45d3c3931&imgtype=0&src=http%3A%2F%2F01.imgmini.eastday.com%2Fmobile%2F20170707%2F20170707010832_397dc7df28461ca39fb9150d0cdc47ae_2.jpeg")
img5 = Img()