def modifyfilestring(filename, oldstring, newstring, afterkeyword, beforekeyword, keyword, separator): filedata = [] filestoragemod.readfiledata_plaintext(filename, filedata) #print "text File /n" , filedata can_modify = False for i in range(len(filedata)): line = filedata[i] if afterkeyword in line: can_modify = True if (beforekeyword != "") and (beforekeyword in line): can_modify = False if (keyword in line) and (can_modify): print " row found ------------ !!!!!!!!! ", line if oldstring in line: # isolate and change the string #print " oldstring ", oldstring, " new ", newstring filedata[i] = line.replace(oldstring, newstring) print " new row ------------ !!!!!!!!! ", filedata[i] filestoragemod.savefiledata_plaintext(filename, filedata) return True else: print "String value not found ", oldstring return False
def createfiletailsyslog(dstfile): rownumber = "100" data = tailsyslogcmd(rownumber) if data: filestoragemod.savefiledata_plaintext(dstfile, data) return True else: print "data empty" return False
def storemessage(message): messagelist = [] messagelist.append(message) filestoragemod.savefiledata_plaintext(MESSAGEFILENAME, messagelist)