def execute(channel, decompileDir, packageName): appID = sdk_helper.getSdkParamByKey(channel, 'Vivo_AppID') supplierconfig = os.path.join(decompileDir, 'assets/supplierconfig.json') config = None if config_utils.is_py_env_2(): with open(supplierconfig, 'r') as f: content = f.read() config = json.loads(content) else: with open(supplierconfig, 'r', encoding="utf-8") as f: content = f.read() config = json.loads(content) config['supplier']['vivo']['appid'] = appID if config_utils.is_py_env_2(): with open(supplierconfig, 'w') as f: f.write(json.dumps(config)) else: with open(supplierconfig, 'w', encoding="utf-8") as f: f.write(json.dumps(config)) return 0
def mergeResXml(copyFrom, copyTo): """ Merge all android res xml """ if not os.path.exists(copyTo): return False aryXml = ['strings.xml','styles.xml','colors.xml','dimens.xml','ids.xml','attrs.xml','integers.xml','arrays.xml','bools.xml','drawables.xml'] basename = os.path.basename(copyFrom) if basename in aryXml: if config_utils.is_py_env_2(): f = open(copyTo) else: f = open(copyTo, 'r', encoding='utf-8') targetContent = f.read() f.close() fromTree = ET.parse(copyFrom) fromRoot = fromTree.getroot() toTree = ET.parse(copyTo) toRoot = toTree.getroot() for node in list(fromRoot): val = node.get('name') if val != None and len(val) > 0: valMatched = '"'+val+'"' attrIndex = targetContent.find(valMatched) if -1 == attrIndex: toRoot.append(node) else: log_utils.warning("The node %s is already exists in %s", val, basename) toTree.write(copyTo, 'UTF-8') return True return False
#!/usr/bin/python # -*- coding: utf-8 -*- # Author tik # Date 2015-06-18 import config_utils #python3.x urllib2,urllib,urlparse,robotparser合并到了urllib中,形成了多个子库 if config_utils.is_py_env_2(): import urllib2 import urlparse else: import urllib.request as urllib2 import urllib.parse as urlparse def get(url, params): full_url = url if params != None and len(params) > 0: data = urlparse.urlencode(params) full_url = full_url + "?" + data f = urllib2.urlopen(full_url) content = f.read() return content # with urllib2.urlopen(full_url) as f: # content = f.read() # return content
# # The main operation entry for multi thread. # import sys import core import file_utils import apk_utils import config_utils import os import os.path import time import threading import log_utils if config_utils.is_py_env_2(): import Queue as queue else: import queue def main(game, isPublic, threadNum = 1): packAllChannels(game, isPublic, threadNum) def packAllChannels(game, isPublic, threadNum): basePath = file_utils.getCurrDir() log_utils.info("Curr Work Dir::%s", basePath)