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


Python common.Log类代码示例

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


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

示例1: generate

 def generate(self, projectName, targetPath):
   tempPath = tempfile.mkdtemp()
   try:
     # Create a build
     build = self.project.platform.createBuild(self.config, self.library, projectName, self.name)
     
     # If there is at least one C++ function, generate only C++ code
     if "c++" in self.getLanguages() or self.config.get("language", "c") == "c++":
       playerSourceName       = "player_gen.cpp"
     else:
       playerSourceName       = "player_gen.c"
       self.library.language  = "c"
     
     # Generate the player
     playerSourcePath = os.path.join(tempPath, playerSourceName)
     g = Generator.CSourcePlayerGenerator(self.config, self.project.platform, [self.library],
                                          templatePath = Resource.getPath("templates"))
     output = open(playerSourcePath, "w")
     g.generate(outputFile = output)
     output.close()
 
     # Add the generated source file to the configuration
     self.addSourceFile(playerSourcePath)
     
     # Finalize the build
     build.compile(targetPath = targetPath)
   finally:
     try:
       shutil.rmtree(tempPath)
     except:
       Log.warn("Unable to clean up temporary directory '%s'" % tempPath)
开发者ID:se210,项目名称:tracy,代码行数:31,代码来源:Target.py

示例2: readEvents

 def readEvents(self):
   tokenHandlers = {
     DefineToken:      self._handleDefineToken,
     EventToken:       self._handleEventToken,
     ValueToken:       self._handleValueToken,
     DurationToken:    self._handleDurationToken,
     ApiToken:         self._handleApiToken,
     BeginObjectToken: self._handleBeginObjectToken,
     EndObjectToken:   self._handleEndObjectToken,
   }
   
   while 1:
     try:
       token = Token.read(self.file)
     except ValueError, e:
       Log.warn("Error reading token: %s" % e)
       continue
     
     if not token:
       break
   
     try:
       event = tokenHandlers[token.__class__](token)
     except Exception, e:
       Log.warn("Error decoding token %s: %s" % (token.__class__.__name__, e))
       continue
开发者ID:se210,项目名称:tracy,代码行数:26,代码来源:BinaryCodec.py

示例3: __init__

  def __init__(self, project, options):
    Analyzer.__init__(self, project)
    self.commands             = {}
    self.commandHelp          = {}
    self.options              = options
    self.parser               = ScriptParser()
    self.done                 = False
    self.colorizer            = Console.colorizer
    self.taskMonitor          = Task.RateLimitedTaskMonitor(self)
    self.profiling            = False
    self.plugins              = []
    self.traceFiles           = {}
    self.customSyntaxCommands = set()
    
    if not self.project.targets:
      Log.warn("Using empty project file.")
      
    if not self.projectHasApiDescription():
      Log.warn("Project file does not contain an API description.")
  
    # Register internal commands  
    self.registerCommand("quit", self.quit)

    # Start receiving task notifications
    Task.setMonitor(self.taskMonitor)

    # Load all plugins
    self._loadPlugins()
开发者ID:se210,项目名称:tracy,代码行数:28,代码来源:Analyzer.py

示例4: validate

  def validate(self):
    lib = self.library

    # Validate the target
    for function in lib.functions.values():
      if function.ordinal is None and function.staticLinkage and self.project.platform.requireOrdinals:
        Log.warn("Function '%s' does not have a valid ordinal." % function.name)
开发者ID:se210,项目名称:tracy,代码行数:7,代码来源:Target.py

示例5: readEvents

 def readEvents(self):
   tokenHandlers = {
     DefineToken:      self._handleDefineToken,
     EventToken:       self._handleEventToken,
     ValueToken:       self._handleValueToken,
     DurationToken:    self._handleDurationToken,
     ApiToken:         self._handleApiToken,
     BeginObjectToken: self._handleBeginObjectToken,
     EndObjectToken:   self._handleEndObjectToken,
   }
   
   while 1:
     try:
       token = Token.read(self.file)
     except ValueError, e:
       Log.warn("Error reading token: %s" % e)
       break
     
     if not token:
       break
       
     event = tokenHandlers[token.__class__](token)
     
     if event:
       yield event
开发者ID:se210,项目名称:tracy,代码行数:25,代码来源:BinaryCodec1.py

示例6: process

  def process(self, fileName, includeMacros = False):
    """
    Process the macro declarations present in a file and return the resulting string.
    
    @param fileName:       Name of file to parse
    @param includeMacros:  Pass  True to include the preprocessor macros in the output
    """
    cmd = [self.binary]

    if self.arguments:
      cmd.append(self.arguments)
      
    if includeMacros:
      cmd.append("-dD")
      # Don't include predefined macros
      cmd.append("-undef")
    
    for macro, value in self.config.get("macros", {}).items():
      cmd.append("-D%s=%s" % (macro, value))
    if self.platform.name in self.config:
      plat = self.config[self.platform.name]
      for lib in plat.get("includedirs", []):
        cmd.append("-I")
        cmd.append(lib)
      for macro, value in plat.get("macros", {}).items():
        cmd.append("-D%s=%s" % (macro, value))
    cmd.append(fileName)

    if self.options.verbose:
      Log.debug("Running preprocessor: " + " ".join(cmd))
      
    p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
    return p.stdout.read()
开发者ID:se210,项目名称:tracy,代码行数:33,代码来源:Tools.py

示例7: getZipType

    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,代码行数:32,代码来源:zipformatter.py

示例8: deoat

    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,代码行数:25,代码来源:deoat.py

示例9: parseConfig

def parseConfig(config, template = None):
  """
  Parses the given tracer configuration and returns a tree of configuration
  symbols.
      
  @param config     Config file text
  @param template   Optional configuration to use a template.
  
  @return: A dictionary tree of configuration values
  """
  if not template:
    template = Config.Config()
  items = template

  for itemName, item in configFile.parseString(config):
    if not item:
      Log.warn("Empty top-level item '%s'." % itemName)
    if itemName in items and isinstance(item, Config.Group):
      items[itemName].update(item)
    elif itemName in items and isinstance(item, Config.List):
      items[itemName] += item
    else:
      items[itemName] = item

  return items
开发者ID:se210,项目名称:tracy,代码行数:25,代码来源:ConfigParser.py

示例10: repackageFrw

    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,代码行数:35,代码来源:deoat.py

示例11: deoatApp

    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,代码行数:26,代码来源:deoat.py

示例12: _postprocessEvent

def _postprocessEvent(event, logDir):
  # Process the render surface if there is one
  if "render_surface_width" in event.sensorData and "render_surface_height" in event.sensorData:
    try:
      _processRenderSurface(logDir, event.sensorData)
    except Exception, e:
      Log.error("Unable to load render surface for event %s(%d): %s" % (event.name, event.seq, e))
开发者ID:se210,项目名称:tracy,代码行数:7,代码来源:Instrumentation.py

示例13: _processRenderSurface

def _processRenderSurface(logDir, attributes):
  def attr(name):
    return attributes[name]
    
  w, h            = attr("render_surface_width"), attr("render_surface_height")
  redMask         = attr("red_mask")
  greenMask       = attr("green_mask")
  blueMask        = attr("blue_mask")
  alphaMask       = attr("alpha_mask")
  depthMask       = attr("depth_mask")
  stencilMask     = attr("stencil_mask")
  isLinear        = attr("is_linear")
  isPremultiplied = attr("is_premultiplied")
  
  # Convert the color buffer
  if "color_buffer" in attributes:
    fileName    = attr("color_buffer")
    if not os.path.exists(fileName):
      fileName  = os.path.join(logDir, fileName)
    fileNameOut = fileName.rsplit(".", 1)[0] + ".png"
    
    # Only do the conversion if the image doesn't already exist
    # or if the source file is newer.
    if fileName.endswith(".dat") and \
       (not os.path.exists(fileNameOut) or \
        (os.path.exists(fileName) and os.path.getmtime(fileName) > os.path.getmtime(fileNameOut))
       ):
      stride      = attr("color_stride")
      
      f           = open(fileName, "rb")
      data        = f.read(stride * h)
      f.close()
      
      if len(data) != h * stride or not data:
        Log.error("Invalid color buffer data size: %d"  % len(data))
        return
      
      colorBuffer = Graphics.decodeImageData(data, (w, h), stride, redMask, greenMask, blueMask, alphaMask, isLinear, isPremultiplied)
      colorBuffer = colorBuffer.convert("RGBA")
      colorBuffer.save(fileNameOut)
      
      # We can remove the original file now
      os.unlink(fileName)
      
      # Replace the original file name with the decoded file
      attributes["color_buffer"] = fileNameOut
      
    # Eat the render surface attributes since they are of little use further down the road
    #for attrName in ["red_mask", "green_mask", "blue_mask", "alpha_mask",
    #                 "depth_mask", "stencil_mask", "color_stride",
    #                 "is_linear", "is_premultiplied", "color_data_type", 
    #                 "depth_data_type", "stencil_data_type"]:
    #  if attrName in attributes:
    #    del attributes[attrName]

  for bufferName in ["depth_buffer", "stencil_buffer"]:
    if bufferName in attributes and not os.path.exists(attributes[bufferName]):
      # Fill in the full buffer file name
      attributes[bufferName] = os.path.join(logDir, attr(bufferName))
开发者ID:se210,项目名称:tracy,代码行数:59,代码来源:Instrumentation.py

示例14: deoatFrw

    def deoatFrw(oatJarDir):
        """ De-oat framework
        """

        if not OPTIONS.formatFrw: return

        Log.i(TAG, "De-oat files of oat-format in %s" % oatJarDir)
        for item in os.listdir(oatJarDir):
            if item.endswith(".odex"):
                # COMMANDS: oat2dex boot <jar-of-oat-format>
                oatJar = os.path.join(oatJarDir, item)
                Utils.runWithOutput([OatZip.OAT2DEX, "boot", oatJar])
开发者ID:Starstok,项目名称:systemimgpack,代码行数:12,代码来源:deoat.py

示例15: getPath

def getPath(*name, **args):
  """
  Get a path to an existing resource.
  
  @param *name      Resource path segments
  @param required   If True, a warning is logged if the resource is not found.
  """
  for path in paths:
    p = os.path.join(path, *name)
    if os.path.exists(p):
      return p
  if args.get("required", True) == True:
    Log.warn("Resource '%s' not found." % os.sep.join(name))
开发者ID:se210,项目名称:tracy,代码行数:13,代码来源:Resource.py


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