parameters: (self)
docstring: Mount the binary counters file as a memory-mapped file.  If
      something goes wrong print an informative message and exit the
      program.
docstring_summary: Mount the binary counters file as a memory-mapped file.  If
      something goes wrong print an informative message and exit the
      program.
docstring_tokens: Mount the binary counters file as a memory - mapped file . If something goes wrong print an informative message and exit the program .
function: def MountSharedData(self):
      """Mount the binary counters file as a memory-mapped file.  If
      something goes wrong print an informative message and exit the
      program."""
      if not os.path.exists(self.data_name):
        maps_name = "/proc/%s/maps" % self.data_name
        if not os.path.exists(maps_name):
          print "\"%s\" is neither a counter file nor a PID." % self.data_name
          sys.exit(1)
        maps_file = open(maps_name, "r")
        try:
          self.data_name = None
          for m in re.finditer(r"/dev/shm/\S*", maps_file.read()):
            if os.path.exists(m.group(0)):
              self.data_name = m.group(0)
              break
          if self.data_name is None:
            print "Can't find counter file in maps for PID %s." % self.data_name
            sys.exit(1)
        finally:
          maps_file.close()
      data_file = open(self.data_name, "r")
      size = os.fstat(data_file.fileno()).st_size
      fileno = data_file.fileno()
      self.shared_mmap = mmap.mmap(fileno, size, access=mmap.ACCESS_READ)
      data_access = SharedDataAccess(self.shared_mmap)
      if data_access.IntAt(0) == COUNTERS_FILE_MAGIC_NUMBER:
        return CounterCollection(data_access)
      elif data_access.IntAt(0) == CHROME_COUNTERS_FILE_MAGIC_NUMBER:
        return ChromeCounterCollection(data_access)
      print "File %s is not stats data." % self.data_name
      sys.exit(1)
function_tokens: def MountSharedData ( self ) : if not os . path . exists ( self . data_name ) : maps_name = "/proc/%s/maps" % self . data_name if not os . path . exists ( maps_name ) : print "\"%s\" is neither a counter file nor a PID." % self . data_name sys . exit ( 1 ) maps_file = open ( maps_name , "r" ) try : self . data_name = None for m in re . finditer ( r"/dev/shm/\S*" , maps_file . read ( ) ) : if os . path . exists ( m . group ( 0 ) ) : self . data_name = m . group ( 0 ) break if self . data_name is None : print "Can't find counter file in maps for PID %s." % self . data_name sys . exit ( 1 ) finally : maps_file . close ( ) data_file = open ( self . data_name , "r" ) size = os . fstat ( data_file . fileno ( ) ) . st_size fileno = data_file . fileno ( ) self . shared_mmap = mmap . mmap ( fileno , size , access = mmap . ACCESS_READ ) data_access = SharedDataAccess ( self . shared_mmap ) if data_access . IntAt ( 0 ) == COUNTERS_FILE_MAGIC_NUMBER : return CounterCollection ( data_access ) elif data_access . IntAt ( 0 ) == CHROME_COUNTERS_FILE_MAGIC_NUMBER : return ChromeCounterCollection ( data_access ) print "File %s is not stats data." % self . data_name sys . exit ( 1 )