def print_summary(f): fl = CheckUpgradeResponse() fl.ParseFromString(open(f, 'rb').read()) for f in fl.files: print f #if f.md5 == '394c3095f155d77bc2f397df53df3961': # print f # print 'is valid file : ', is_valid_file(f.url) if not is_valid_file(f.url): continue file_dir = f.md5[0:2] if not os.path.exists(os.path.join('jodo_diff_files', file_dir)): os.mkdir(os.path.join('jodo_diff_files', file_dir)) if f.url.find('.') > 0: file_ext = f.url[f.url.rfind('.'):] else: file_ext = '' ipath = os.path.join('assets/', f.md5[0:2] + '/' + f.md5[2:] + file_ext) opath = os.path.join('jodo_diff_files/', f.md5[0:2] + '/' + f.md5[2:] + file_ext) copyto(ipath, opath)
def update_diff_file(v1, valid, v2): fl1 = FileList() fl1.ParseFromString(open('%s_%s.files%s' % (v1, platform, '' if valid else '.invalid'), 'rb').read()) fl2 = FileList() fl2.ParseFromString(open('%s_%s.files' % (v2, platform), 'rb').read()) fileset1 = { f.url:(f.md5,f.size) for f in fl1.files } fileset2 = { f.url:(f.md5,f.size) for f in fl2.files } fileset_all = copy(fileset1) fileset_all.update(fileset2) bigupgrade = v2/100000 > v1/100000 print 'bigupgrade', bigupgrade rsp = CheckUpgradeResponse(isbigupgrade=False) rsp.isbigupgrade = bigupgrade rsp.versionId = fl2.version rsp.versionName = fl2.version_name rsp.config_version = fl2.config_version for f in fileset_all: if f not in fileset2: # deleted info = rsp.files.add() info.url = f info.md5 = fileset1[f][0] info.size = 0 info.new = False else: if fileset2[f] != fileset1.get(f, ('', 0)): info = rsp.files.add() info.url = f info.md5, info.size = fileset2[f] info.new = f not in fileset1 difffile = '%s_%s.list'%(fl1.version, platform) print 'write diff file', difffile open(difffile, 'wb').write(rsp.SerializeToString())
def update_diff_file(v1, valid, v2): fl1 = FileList() fl1.ParseFromString( open('%s_%s.files%s' % (v1, platform, '' if valid else '.invalid'), 'rb').read()) fl2 = FileList() fl2.ParseFromString(open('%s_%s.files' % (v2, platform), 'rb').read()) fileset1 = {f.url: (f.md5, f.size) for f in fl1.files} fileset2 = {f.url: (f.md5, f.size) for f in fl2.files} fileset_all = copy(fileset1) fileset_all.update(fileset2) bigupgrade = v2 / 100000 > v1 / 100000 print 'bigupgrade', bigupgrade rsp = CheckUpgradeResponse(isbigupgrade=False) rsp.isbigupgrade = bigupgrade rsp.versionId = fl2.version rsp.versionName = fl2.version_name rsp.config_version = fl2.config_version for f in fileset_all: if f not in fileset2: # deleted info = rsp.files.add() info.url = f info.md5 = fileset1[f][0] info.size = 0 info.new = False else: if fileset2[f] != fileset1.get(f, ('', 0)): info = rsp.files.add() info.url = f info.md5, info.size = fileset2[f] info.new = f not in fileset1 difffile = '%s_%s.list' % (fl1.version, platform) print 'write diff file', difffile open(difffile, 'wb').write(rsp.SerializeToString())
#!/usr/bin/env python import sys, files_pb2 from session_pb2 import CheckUpgradeResponse def version_name(ver): return str(ver / 100000.0) version, platform = int(sys.argv[1]), sys.argv[2] #flist = files_pb2.FileList() #flist.version = version #flist.platform = platform #flist.version_name = version_name(version) #open('%s_%s.list' % (version, platform), 'wb').write(flist.SerializeToString()) flist = CheckUpgradeResponse() flist.isbigupgrade = False flist.versionId = version flist.versionName = version_name(version) output = '%s_%s.list' % (version, platform) print 'write to', output open(output, 'wb').write(flist.SerializeToString())
#!/usr/bin/env python import sys, files_pb2 from session_pb2 import CheckUpgradeResponse def version_name(ver): return str(ver/100000.0) version, platform = int(sys.argv[1]), sys.argv[2] #flist = files_pb2.FileList() #flist.version = version #flist.platform = platform #flist.version_name = version_name(version) #open('%s_%s.list' % (version, platform), 'wb').write(flist.SerializeToString()) flist = CheckUpgradeResponse() flist.isbigupgrade = False flist.versionId = version flist.versionName = version_name(version) output = '%s_%s.list' % (version, platform) print 'write to', output open(output, 'wb').write(flist.SerializeToString())
def print_summary(f): fl = CheckUpgradeResponse() fl.ParseFromString(open(f, 'rb').read()) for f in fl.files: print f.size, f.url print 'total size', sum(f.size for f in fl.files)