예제 #1
0
 def getBasePath(base):
     try:
         devices = os.path.join(os.environ["PORT_ROOT"], "devices")
         return os.path.join(devices, base)
     except KeyError:
         Log.e(TAG, "device %s not found" % base)
         sys.exit(155)
예제 #2
0
파일: diff_patch.py 프로젝트: loserq/tools
    def deletePart(self, part):
        """ Delete a part
        """

        try:
            self.mPartList.remove(part)
            Log.d(TAG, "  [Delete part %s ] " % part)
        except:
            Log.e(TAG,
                  "SmaliSpliiter.deltePart(): can not find part %s" % part)
예제 #3
0
파일: diff_patch.py 프로젝트: loserq/tools
    def replacePart(self, targetPart, newerPart):
        """ Replace the target with the newer.
        """

        try:
            index = self.mPartList.index(targetPart)
            self.mPartList[index] = newerPart
            Log.d(TAG, "  [Replace %s by %s] " % (targetPart, newerPart))
        except:
            Log.e(
                TAG, "SmaliSplitter.replacePart() can not find part %s" %
                targetPart)
예제 #4
0
    def otaNormalize(boardZip):
        """ Normalize the OTA package zip, return the root directory of unziped files
        """

        if not os.path.exists(boardZip):
            Log.e(TAG, "oatNormalize() % not exists" % boardZip)
            return None

        zipFormatter = ZipFormatter.create(ZipFormatter.genOptions(boardZip))
        # Do not need to zip back
        zipFormatter.format(zipBack=False)

        root = zipFormatter.getFilesRoot()
        if not os.path.exists(root):
            Log.e(TAG, "otaNormalize() normalize %s failed!" % boardZip)
            return None

        return root
예제 #5
0
    def decode(boardZip, out):
        """ Decode FRAMEWORK_JARS in board.zip into out directory.
        """

        Log.i(TAG, "Generating %s from %s" % (out, boardZip))

        # Phase 1: normalize
        temp = Utils.otaNormalize(boardZip)
        if temp == None:
            Log.e(TAG, "decode(): ota normalized failed")
            return

        if not os.path.exists(out): os.makedirs(out)

        Utils.decodeAPKandJAR(temp, out)

        shutil.rmtree(temp)

        # Phase 3: combine framework partitions
        Utils.combineFrameworkPartitions(out)

        # Phase 4: remove useless files
        Utils.removeUseless(out)
예제 #6
0
    def deodex(baiduZip):
        """ Deodex the baidu.zip. The deodexed with suffix "deodex.zip" is returned if succeed.
        """

        if not os.path.exists(baiduZip):
            Log.e(TAG, "deodex() % not exists" % baiduZip)
            return None

        deodexZip = baiduZip + ".deodex.zip"
        if os.path.exists(deodexZip):
            Log.d(TAG, "deodex() %s already exists" % deodexZip)
            return deodexZip

        DEODEX_THREAD_NUM = "4"
        Log.i(TAG, "Deodex %s" % baiduZip)
        subp = Utils.run(["deodex", "-framework", baiduZip, DEODEX_THREAD_NUM],
                         stdout=subprocess.PIPE)
        Utils.printSubprocessOut(subp)

        if not os.path.exists(deodexZip):
            Log.e(TAG, "deodex() deodex %s failed!" % baiduZip)
            return None

        return deodexZip
예제 #7
0
파일: utils.py 프로젝트: dibowei/tools
 def e(s):
     Log.e(SLog.TAG, s)