def addString(self, filelabel, string):
    if int(filelabel) <= 0 or int(filelabel) > 95 or int(filelabel) == 63:
      return "BAD_FILELABEL"
    dom = getDom()
    lilinfosys = dom.documentElement
    files = lilinfosys.getElementsByTagName('file')
    found = False
    foundFile = None
	
    flash = False #do we need to flash a memory config (and thus the display) for this?
    for file in files:
      if int(file.getAttribute('label')) == int(filelabel):
        assert not found
        found = True
        foundFile = file
    
    if not found:
      return "FILE_DOES_NOT_EXIST"

    if len(string) > 120: #play it safe, I guess
      string = string[:120]
      print "** WARNING ** truncating string to 120 characters"
		
    if foundFile.getElementsByTagName('text').length != 0:
	  print "CANNOT HAVE STRING AND TEXT IN SAME FILE"
	  return "CANNOT_HAVE_STRING_AND_TEXT_IN_SAME_FILE"
	  #Yo, you can't have a string and text item together.
		
    strings = foundFile.getElementsByTagName(u'string')
    if strings.length != 1 or not strings.item(0).hasAttribute(u'size') and strings.item(0).getAttribute(u'size') < len(string):
      print "Well, this won't be as seemless as we would've liked..."
      flash = True
		
    file_element = dom.createElement('file')
    file_label = file_element.setAttribute('label', str(filelabel))

    string_element = dom.createElement('string')
    string_size = string_element.setAttribute('size', str(len(string)))
    string_element.appendChild( dom.createTextNode( string ) )
	
    file_element.appendChild(string_element)
    lilinfosys.replaceChild(file_element, foundFile) #we'll just perform a switcheroo here...
    	
	#and NOW we should actually process that update...
    saveDom(dom)
    if flash:
      dom = getDom()
      parsexml(dom.toxml())
    else:
      startPacket()
      handleFile(file_element)
      endPacket()

    return 'ok'
 def updateSign(self):
   dom = getDom()
   parsexml(dom.toxml())
   print("updating sign")
   return 'ok'
Example #3
0
 def updateSign(self):
   dom = getDom()
   parsexml(dom.toxml())
   return 'ok'