当前位置: 首页>>代码示例>>Python>>正文


Python Log.d方法代码示例

本文整理汇总了Python中common.Log.d方法的典型用法代码示例。如果您正苦于以下问题:Python Log.d方法的具体用法?Python Log.d怎么用?Python Log.d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.Log的用法示例。


在下文中一共展示了Log.d方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getZipType

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import d [as 别名]
    def getZipType(self):
        """ Retrieve the OTA package type
            The property <persist.sys.dalvik.vm.lib> defines the VM type.
            If libart.so is used, it is an ART package;
            If libdvm.so is used, it is an DVM package.
        """

        if self.mRoot is None: self.unzip()

        buildProp = os.path.join(self.mRoot, "system/build.prop")

        # Retrieve the <persist.sys.dalvik.vm.lib> in build.prop
        zipType = None
        if os.path.exists(buildProp):
            fileHandle = open(buildProp, "r")
            content = fileHandle.read()
            vmlib = re.compile("\n.*sys.dalvik.vm.lib.*=\s*(?P<lib>.*)\n")
            match = vmlib.search(content)
            if match is not None:
                libType = match.group("lib")
                Log.d(TAG, "sys.dalvik.vm.lib=%s" % libType)

            fileHandle.close()
        else:
            raise Exception("Could not find %s, unknown ota type" %buildProp)

        if libType.find("art") >= 0:
            zipType = ZipModel.ART
        elif libType.find("dvm") >= 0:
            zipType = ZipModel.DVM

        return zipType
开发者ID:duanqz,项目名称:systemimgpack,代码行数:34,代码来源:zipformatter.py

示例2: deoat

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import d [as 别名]
    def deoat(self):
        """ De-oat the OTA package.
        """

        if self.mBootOAT == None:
            Log.i(TAG, "deoat(): boot.oat not found in %s, nothing need deoat" % self.mRoot)
            return self

        if os.path.exists(self.mBootClassFolder):
            Log.d(TAG, "Delete the already exists %s" %self.mBootClassFolder)
            shutil.rmtree(self.mBootClassFolder)

        # Phase 1: de-oat boot.oat
        OatZip.deoatBootOAT(self.mBootOAT)

        # Phase 2: de-oat all the other oat files, of which suffix is odex.
        # [Android 5.0]: All the oat jars are located in the same folder with boot.oat
        OatZip.deoatFrw(self.mBootOATDir)

        # Phase 3: de-oat app
        OatZip.deoatApp(self.mFrwDir, self.mBootClassFolder)
        OatZip.deoatApp(self.mAppDir, self.mBootClassFolder)
        OatZip.deoatApp(self.mPrivAppDir, self.mBootClassFolder)

        return self
开发者ID:Starstok,项目名称:systemimgpack,代码行数:27,代码来源:deoat.py

示例3: repackageFrw

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import d [as 别名]
    def repackageFrw(frwDir, bootClassFolder):
        """ Repackage the classes.dex into jar of frwDir.
        """

        if OPTIONS.formatFrw == False : return

        # Keep the old directory, we will change back after some operations.
        oldDir = os.path.abspath(os.curdir)

        # Some dexFiles are parted, such as framework-classes2.dex
        regex = re.compile("(.*)-(classes\d?).dex")

        Log.i(TAG, "Repackage JARs of %s" %(frwDir))
        os.chdir(frwDir)
        for dexFile in os.listdir(bootClassFolder):
            if dexFile.endswith(".dex"):
                jarFile = dexFile[0:-4] + ".jar"
                dexName = "classes.dex"

                if not os.path.exists(jarFile):
                    # Match out the jar file with regex
                    matcher = regex.match(dexFile)
                    if matcher != None:
                        jarFile = matcher.group(1) + ".jar"
                        dexName = matcher.group(2) + ".dex"
 
                Log.d(TAG, "Repackage %s" %(jarFile))
                # Put the dex and framework's jar in the same folder, and jar into the jarFile
                shutil.move(os.path.join(bootClassFolder, dexFile), os.path.join(frwDir, dexName))
                Utils.runWithOutput(["jar", "uf", jarFile, dexName])

                if os.path.exists(dexName):
                    os.remove(dexName)

        os.chdir(oldDir)
开发者ID:Starstok,项目名称:systemimgpack,代码行数:37,代码来源:deoat.py

示例4: deoatApp

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import d [as 别名]
    def deoatApp(oatApkDir, bootClassFolder):
        """ De-oat app
        """

        if OPTIONS.formatApp == False: return

        Log.i(TAG, "De-oat files of oat-format in %s, with BOOTCLASSFOLDER=%s" %(oatApkDir, bootClassFolder))
        for (dirpath, dirnames, filenames) in os.walk(oatApkDir):

            dirnames = dirnames # no use, to avoid warning

            for filename in filenames:
                if filename.endswith(".odex"):
                    # no need to de-oat if original apk does not exist
                    apkFile = filename[0:-5] + ".apk"
                    apkPath = os.path.dirname(dirpath)
                    if not os.path.exists(os.path.join(apkPath, apkFile)):
                        continue

                    oatApk = os.path.join(dirpath, filename)
                    deoatApk = oatApk[0:-5] + ".dex"
                    if os.path.exists(deoatApk):
                        Log.d(TAG, "Delete the already exists %s" % deoatApk)
                        os.remove(deoatApk)

                    Utils.runWithOutput([OatZip.OAT2DEX, oatApk, bootClassFolder])
开发者ID:Starstok,项目名称:systemimgpack,代码行数:28,代码来源:deoat.py

示例5: zip

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import d [as 别名]
    def zip(self):
        if self.mRoot is None: return

        origDir = os.path.abspath(os.curdir)

        Log.i(TAG, "zip from %s to %s" % (self.mRoot, self.mOutZip))

        os.chdir(self.mRoot)
        cmd = "zip -r -y -q tmp *; mv tmp.zip %s" % self.mOutZip
        Log.d(TAG, commands.getoutput(cmd))
        os.chdir(origDir)

        Log.i(TAG, "Deleting %s" % self.mRoot)
        shutil.rmtree(self.mRoot)

        Log.i(TAG, "===> %s" % self.mOutZip)
开发者ID:duanqz,项目名称:systemimgpack,代码行数:18,代码来源:zipformatter.py

示例6: unzip

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import d [as 别名]
    def unzip(self):
        # Already unziped
        if self.mRoot is not None: return

        self.mRoot = tempfile.mkdtemp()

        Log.i(TAG, "unzip %s to %s" % (self.mInZip, self.mRoot))
        cmd = "unzip -q -o %s -d %s" %(self.mInZip, self.mRoot)
        Log.d(TAG, commands.getoutput(cmd))

        self.dedatIfNeeded()

        # Format path
        if os.path.exists(os.path.join(self.mRoot, "SYSTEM")):
            shutil.move(os.path.join(self.mRoot, "SYSTEM"), os.path.join(self.mRoot, "system"))

        return self
开发者ID:duanqz,项目名称:systemimgpack,代码行数:19,代码来源:zipformatter.py

示例7: dedatIfNeeded

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import d [as 别名]
    def dedatIfNeeded(self):
        """ Android 5.0 zip structure:
            * META-INF (folder containing scripts)
            * system.new.dat (compressed /system partition)
            * system.patch.dat
            * system.transfer.list (see explanation below)
        """

        if not os.path.exists(os.path.join(self.mRoot, "system.new.dat")):
            return

        if not os.path.exists(os.path.join(self.mRoot, "system.transfer.list")):
            return

        if os.geteuid() != 0:
            raise Exception("DEDAT should be executed as root.")

        cmd = "%s %s" % (commands.mkarg(ZipModel.DAT2IMG), commands.mkarg(self.mRoot))
        Log.d(TAG, commands.getoutput(cmd))
开发者ID:duanqz,项目名称:systemimgpack,代码行数:21,代码来源:zipformatter.py

示例8: repackageApp

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import d [as 别名]
    def repackageApp(appDir):
        """ Repackage the classes.dex into apk of appDir
        """

        if OPTIONS.formatApp == False: return

        # Keep the old directory, we will change back after some operations.
        oldDir = os.path.abspath(os.curdir)

        Log.i(TAG, "Repackage APKs of %s" %(appDir))
        for (dirpath, dirnames, filenames) in os.walk(appDir):

            dirnames = dirnames # no use, to avoid warning

            for dexFile in filenames:
                if dexFile.endswith(".dex"):
                    apkFile = dexFile[0:-4] + ".apk"
                    apkPath  = os.path.dirname(dirpath)

                    if not os.path.exists(os.path.join(apkPath, apkFile)):
                        Log.d(TAG, "No apk matched with %s, Ignore" %dexFile)
                        continue

                    dexName = "classes.dex"

                    Log.d(TAG, "Repackage %s" %(apkPath))
                    # Put the dex and apk in the same folder, and jar into the apk
                    shutil.move(os.path.join(dirpath, dexFile), os.path.join(apkPath, dexName))

                    os.chdir(apkPath)
                    Utils.runWithOutput(["jar", "uf", apkFile, dexName])
                    if os.path.exists(dexName):
                        os.remove(dexName)

                    shutil.rmtree(dirpath)


        os.chdir(oldDir)
开发者ID:Starstok,项目名称:systemimgpack,代码行数:40,代码来源:deoat.py

示例9: deodexOneFile

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import d [as 别名]
    def deodexOneFile(odexFile, deodexFile):
        """ De-odex one file.
        """

        if not odexFile.endswith(".odex"): return

        temp = tempfile.mktemp()

        # Phase 1: Baksmali the odex file
        cmd = ["baksmali", "-x", odexFile, "-d", "framework", "-I", "-o", os.path.join(temp, "out")]
        if OPTIONS.apiLevel  != None: cmd.extend(["-a", OPTIONS.apiLevel])
        if OPTIONS.classpath != None: cmd.extend(["-c", OPTIONS.classpath])

        cmd = " ".join(cmd)
        Log.d(TAG, cmd)
        Log.d(TAG, commands.getoutput(cmd))

        # Phase 2: Smali the files into dex
        oldDir = os.path.abspath(os.curdir)
        os.chdir(temp)

        cmd = "smali out/ -o classes.dex"
        Log.d(TAG, commands.getoutput(cmd))
        #Utils.runWithOutput(["smali", "out", "-o", "classes.dex"])

        # Phase 3: Package
        if os.path.exists(deodexFile):
            #cmd = ["jar", "uf", deodexFile, "classes.dex"]
            cmd = "jar uf %s classes.dex" % deodexFile
        else:
            #cmd = ["jar", "cf", deodexFile, "classes.dex"]
            cmd = "jar cf %s classes.dex" % deodexFile

        Log.d(TAG, commands.getoutput(cmd))
        #Utils.runWithOutput(cmd)
        os.chdir(oldDir)

        if os.path.exists(odexFile): os.remove(odexFile)

        Log.i(TAG, "Delete %s" %temp)
        shutil.rmtree(temp)

        # Phase 4: zipalign
        #Utils.runWithOutput(["zipalign", "4", deodexFile, deodexFile+".aligned"])
        #Utils.runWithOutput(["mv", deodexFile+".aligned", deodexFile])

        cmd = "zipalign 4 %s %s" %(deodexFile, deodexFile+".aligned")
        Log.d(TAG, commands.getoutput(cmd))

        cmd = "mv %s %s" %(deodexFile+".aligned", deodexFile)
        Log.d(TAG, cmd)
开发者ID:Starstok,项目名称:systemimgpack,代码行数:53,代码来源:deodex.py


注:本文中的common.Log.d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。