def get_downloads(self, bundle_id, sign):

        ipaHash = "" #最新版
        ipaVersion = "" #最新版本号
        ipaHistoryDownloads = "" #历史版本

        #直接下载数据
        download = AppDownloadController()
        res = download.get_by_bundleid(bundle_id, sign)
        tmp_download_list = {}
        if res:
            for down in res:
                try:
                    tmp = {'ipaHash': down['hash'], 'version': down['version'],
                           'addTime': str(down['addTime'])}
                    if down['version'] not in tmp_download_list:
                        tmp_download_list[down['version']] = []
                    tmp_download_list[down['version']].append(tmp)
                except Exception, ex:
                    print ex
                    pass
            try:
                ipaHistoryDownloads = sort_dict_keys(tmp_download_list)
            except Exception, ex:
                print ex
Exemple #2
0
    def get_all_downloads(self, bundle_id, vv_version="common"):
        """取得该应用下的所有下载包"""
        #直接下载数据

        download = AppDownloadController()
        sign_downloads, jb_downloads = download.get_all_downloads_of_app(bundle_id, vv_version)
        sign_downloads_info = self._extract_direct_download_info(sign_downloads)
        jb_downloads_info = self._extract_direct_download_info(jb_downloads)

        netdisk = AppDownloadNetDiskController()
        sign_nd_downloads, jb_nd_downloads = netdisk.get_all_downloads_of_app(bundle_id)
        sign_nd_downloads_info = self._extract_netdisk_download_info(
            sign_nd_downloads, sign_downloads_info["tmp_download_list"])
        jb_nd_downloads_info = self._extract_netdisk_download_info(
            jb_nd_downloads, jb_downloads_info["tmp_download_list"])

        sign_downloads_info["ipaHistoryDownloads"] = sign_nd_downloads_info["ipaHistoryDownloads"]
        jb_downloads_info["ipaHistoryDownloads"] = jb_nd_downloads_info["ipaHistoryDownloads"]
        return {"sign": sign_downloads_info, "jb": jb_downloads_info}
Exemple #3
0
    def get_downloads_of_allbundleids(self, bundle_ids, sign, vv_version="common"):
        """add by kq for bundle search"""

        download_direct = AppDownloadController()
        reses = download_direct.get_by_bundleids(bundle_ids, sign, vv_version)
        download_netdisk = AppDownloadNetDiskController()
        reses2 = download_netdisk.get_by_bundleids(bundle_ids, sign)

        result_for_download = {}
        for bundle_id in bundle_ids:

            ipaHash = "" #最新版
            ipaVersion = "" #最新版本号
            ipaHistoryDownloads = "" #历史版本
            res = reses.get(bundle_id, None)
            tmp_download_list = {}
            if res:
                for down in res:
                    down_version = "0" if down.get('version', "") == "" else down["version"]
                    try:
                        tmp = {
                            'ipaHash': down['hash'],
                            'version': down_version,
                            'addTime': str(down['addTime'])
                        }
                        if down_version not in tmp_download_list:
                            tmp_download_list[down_version] = []
                        tmp_download_list[down_version].append(tmp)
                    except Exception, ex: continue
                try:
                    ipaHistoryDownloads = sort_dict_keys(tmp_download_list)
                except Exception, ex:
                    print ex
                try:
                    key = ipaHistoryDownloads.keys()[0]
                    ipaHash = ipaHistoryDownloads[key][0]['ipaHash']
                    ipaVersion = ipaHistoryDownloads[key][0]['version']
                except Exception, ex:
                    traceback.print_exc()
                    pass
Exemple #4
0
    def get_apps_cache_mg(self, device, sign, genre_id, page, sort):
        """
        获取app列表展示  luoluo0
        """
        language = self._language if self._language in ['zh-Hans','en', 'ar'] else 'en'
        key = "%s_%s_%s_%s_%s" % (device, sign, language, genre_id, sort)
        count = mongo_db.AppKeylists.find({'appKey':key}).count()

        page_size = 12 # 每页显示12行
        total_page = int(math.ceil(count / float(page_size)))
        prev_page = (page - 1) if page - 1 > 0 else 1
        next_page = (page + 1) if page + 1 < total_page else total_page

        lists1 = list(mongo_db.AppKeylists.find(
            {'appKey':key},
            {'appKey':0,'order':0}
        ).sort([('order',pymongo.DESCENDING)]).skip((page-1)*page_size).limit(page_size))

        bundleIdlist = [i['bundleId'] for i in lists1 if 'bundleId' in i]
        download = AppDownloadController()
        ipaHashdic = download.get_by_bundleids(bundleIdlist)
        ipaHashlist = [i[0] for i in ipaHashdic.values()]

        for i in lists1:
            i['ID'] = str(i['_id'])
            del i['_id']
            for x in ipaHashlist:
                if i['bundleId'] == x['bundleId']:
                    i['ipaHash'] = str(x['hash'])
                    i['ipaVersion'] = x.get('version', '1.0')
        lists = [convertAppIpaHashToIpaURL(x) for x in lists1]
        return {
            'results': lists,
            'pageInfo': {
                'count': count, 'page': page, 'totalPage': total_page, 'prevPage': prev_page,
                'nextPage': next_page
            }
        }