Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)

          @staticmethod
  def read(name):
    with open(name, 'rb') as f:
      bitfile = BitFile()
      
      # 11 bytes of unknown data
      if BitFile._readLength(f) != 9:
        raise BitFileReadError()
      
      BitFile._readOrDie(f, 11)
      
      # the designname field should look something like:
      # fpgaminer_top.ncd;HW_TIMEOUT=FALSE;UserID=0xFFFFFFFF
      bitfile.designname = BitFile._readField(f, 'a').rstrip('\0')
      bitfile.userid = int(bitfile.designname.split(';')[-1].split('=')[-1], base=16)
      if bitfile.userid == 0xFFFFFFFF:
        bitfile.rev = 0
        bitfile.build = 0
      elif (bitfile.userid >> 16) & 0xFFFF == 0x4224:
        bitfile.rev = (bitfile.userid >> 8) & 0xFF
        bitfile.build = bitfile.userid & 0xFF
      else:
        raise BitFileUnknown()
        
      bitfile.part = BitFile._readField(f, 'b').rstrip('\0')
      bitfile.date = BitFile._readField(f, 'c').rstrip('\0')
      bitfile.time = BitFile._readField(f, 'd').rstrip('\0')
      bitfile.idcode = idcode_lut[bitfile.part]
      
      if BitFile._readOrDie(f, 1) != 'e':
        raise BitFileReadError()
      
      length = BitFile._readLength4(f)
      bitfile.bitstream = BitFile._readOrDie(f, length)
      
      bitfile.processed = [False]*3
      
      for i in range(3):
        processed_name = name + '.' + str(i)
        if os.path.isfile(processed_name):
          bitfile.processed[i] = True
      
      return bitfile
        


src/f/t/FT232R-JTAG-HEAD/program.py   FT232R-JTAG(Download)
 
try:
  bitfile = BitFile.read(bitfileName)
except BitFileReadError, e:
  print e