Esempio n. 1
0
    def _generate_ticket_table(self, json_file, account_id):

        if json_file is None:
            return

        tickets = self._open_json_file(json_file).get('presp', {}).get('pdata', {}).get('activityList', [])
        for ticket_info in tickets:
            try:
                activity_info = ticket_info.get('activityInfo', {})
                ticket = model_map.LocationJourney()
                ticket.account_id = account_id
                ticket.flightid = activity_info.get('tktNo', None)
                start_time = '{} {}'.format(activity_info.get('deptDateTz', ''), activity_info.get('deptTimeTz', ''))
                ticket.start_time = TimeHelper.str_to_ts(start_time, _format='%Y-%m-%d %H:%M')
                ticket.depart = activity_info.get('deptCityCode', None)
                ticket.depart_address = activity_info.get('deptCityName', None)
                end_time = '{} {}'.format(activity_info.get('destDateTz', ''), activity_info.get('destTimeTz', ''))
                ticket.end_time = TimeHelper.str_to_ts(end_time, _format='%Y-%m-%d %H:%M')
                ticket.destination = activity_info.get('destCityCode', None)
                ticket.destination_address = activity_info.get('destCityName', None)
                ticket.purchase_price = activity_info.get('priceJointWithUnit', None)
                ticket.ticket_status = activity_info.get('tktStatusDesc', None)
                ticket.order_time = activity_info.get('createTime', None)
                ticket.latest_mod_time = activity_info.get('modifyTime', None)
                self.csm.db_insert_table_journey(ticket)
            except Exception as e:
                print e
        self.csm.db_commit()
Esempio n. 2
0
    def _generate_message_table(self, node, account_id):
        sender_id = node
        source = node.AbsolutePath
        messages = self._open_json_file(node).get('messages', [])

        for m in messages:
            message = model_im.Message()
            message.source = source
            message.msg_id = m.get("clientmessageid", None)
            message.account_id = account_id
            message.talker_id = m.get("conversationid")
            message.sender_id = message.sender_name = sender_id = message.sender_name = sender_id = m.get(
                'from').split('/')[-1]
            message.is_sender = 1
            content = self.convert_message_content(m.get("content", None),
                                                   message)
            message.content = content
            send_time = TimeHelper.str_to_ts(m.get('originalarrivaltime',
                                                   None)[:-5].replace(
                                                       'T', " "),
                                             _format="%Y-%m-%d %H:%M:%S")
            message.send_time = send_time
            message.type = self.convert_message_content_type(
                m.get("messagetype", None))
            message.talker_type = model_im.CHAT_TYPE_GROUP if "@" in message.talker_id else model_im.CHAT_TYPE_FRIEND
            # TODO media path 无法添加,案例数据没有
            self.model_im_col.db_insert_table_message(message)
        self.model_im_col.db_commit()
Esempio n. 3
0
 def _parse_photos(self, node):
     gallery_files = node.Search(r'Gallery_user_galleries_\d+.txt')
     for f in gallery_files:
         data = self._open_file(f)
         for g in data.get('galleries', []):
             try:
                 file_name = g.get('fileName', None)
                 if not file_name:
                     continue
                 pic = next(iter(self.root.Search(file_name)), None)
                 if not pic:
                     continue
                 m = model_media.Media()
                 m.source = f.AbsolutePath
                 m.url = pic.AbsolutePath
                 m.id = g.get('id', None)
                 m.title = g.get('title', None)
                 m.type = 'image'
                 m.modify_date = TimeHelper.convert_timestamp(
                     g.get('dateModified', None))
                 m.add_date = TimeHelper.str_to_ts(
                     g.get('exifinfo', {}).get('dateTime', None),
                     _format="%Y-%m-%d %H:%M:%S")
                 m.size = g.get('size', None)
                 m.height = g.get('exifinfo', {}).get('imageLength', None)
                 m.width = g.get('exifinfo', {}).get('imageWidth', None)
                 self.mm.db_insert_table_media(m)
             except Exception as e:
                 print(e)
     self.mm.db_commit()
Esempio n. 4
0
 def _insert_item_to_db(self, obj):
     f = model_nd.NDFileList()
     f.set_value_with_idx(f.account, self.account_id)
     f.set_value_with_idx(f.file_name, obj.get('name', None))
     f.set_value_with_idx(f.file_size, obj.get('Size', None))
     f.set_value_with_idx(f.update_time, TimeHelper.str_to_ts(obj.get('FileModifyedTime', None),
                                                              _format="%Y-%m-%dT%H:%M:%S"))
     f.set_value_with_idx(f.server_path, obj.get('Path', None))
     self.model_nd.db_insert_filelist(f.get_values())
Esempio n. 5
0
    def _generate_deal_table(self):
        deal_db = self._search_file('MyJourneyDB.sqlite$')
        if not deal_db:
            return
        FlightTicket.connect(deal_db)
        account_id = self.master_account.account_id

        for ticket in FlightTicket.objects.all:
            try:
                deal = model_eb.EBDeal()
                deal.set_value_with_idx(deal.account_id, account_id)
                deal.set_value_with_idx(deal.deleted, ticket.deleted)
                deal.set_value_with_idx(deal.source_file, ticket.source_path)
                deal.set_value_with_idx(
                    deal.begin_time,
                    TimeHelper.str_to_ts(
                        "{} {}".format(ticket.dept_flight_date,
                                       ticket.departure_time),
                        "%Y-%m-%d %H:%M"))
                deal.set_value_with_idx(
                    deal.end_time,
                    TimeHelper.str_to_ts(
                        "{} {}".format(ticket.dest_flight_date,
                                       ticket.destination_time),
                        "%Y-%m-%d %H:%M"))
                deal.set_value_with_idx(
                    deal.content,
                    self._process_ticket_content(
                        ticket.departure_name,
                        ticket.destination_name,
                        "{} {}".format(ticket.dept_flight_date,
                                       ticket.departure_time),
                        "{} {}".format(ticket.dest_flight_date,
                                       ticket.destination_time),
                    ))
                deal.set_value_with_idx(
                    deal.status, self._process_ticket_status(ticket.status))
                deal.set_value_with_idx(deal.deal_type,
                                        model_eb.EBDEAL_TYPE_REC)
                deal.set_value_with_idx(deal.target, ticket.ticket_id)
                self.model_eb_col.db_insert_table_deal(deal.get_value())
            except Exception as e:
                self.logger.error()
        self.model_eb_col.db_commit()
Esempio n. 6
0
 def _generate_search_table(self):
     """添加search记录"""
     db_col = self.soul_app_col
     table = db_col.get_table(
         "search_record_post", {
             "_id": [FieldType.Text, FieldConstraints.NotNull],
             "ts": [FieldType.Int, FieldConstraints.NotNull],
         })
     for record in db_col.read_records(table):
         try:
             s = model_im.Search()
             s.key = record['_id'].Value
             s.create_time = TimeHelper.str_to_ts(
                 record['ts'].Value, _format="%Y-%m-%d %H:%M:%S")
             s.deleted = 1 if record.IsDeleted else 0
             s.source = db_col.db_path
             self.model_im_col.db_insert_table_search(s)
         except Exception as e:
             self.logger.error()
     self.model_im_col.db_commit()
Esempio n. 7
0
    def _generate_account_table(self):
        """
        创建account table
        """
        account_file = self._search_account_info_file()
        if not account_file:
            return

        file_info = PlistHelper.ReadPlist(account_file)
        if not file_info:
            return

        for account_id in self._account_list:
            try:
                if not account_file:
                    return
                account = model_im.Account()
                account.account_id = account.username = account.nickname = account_id
                account.email = file_info.Get('USER_MAIL' + account_id)
                birth_day = file_info.Get('currentUserBrithday' + account_id)
                if birth_day:
                    account.birthday = TimeHelper.str_to_ts(
                        birth_day.ToString())
                if str(file_info['userInformation'].Get(
                        "chatUserID")) == account_id:
                    account.password = file_info['userInformation'].Get(
                        "loginUserPassWord")
                    account.telephone = file_info['userInformation'].Get(
                        "loginUserPhone")
                    account.signature = file_info["signatureText"]
                    account.username = file_info["userChatUsername"]
                    account.gender = model_im.GENDER_FEMALE if file_info[
                        "gender"] == "女" else model_im.GENDER_MALE
                account.nickname = account.signature
                # account.photo = account_info.get("account_info", {}).get("photo_url", None)
                account.source = account_file.PathWithMountPoint
                self.model_im_col.db_insert_table_account(account)
            except Exception as e:
                self.logger.error()
        self.model_im_col.db_commit()