コード例 #1
0
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
コード例 #2
0
ファイル: debuggingmod.py プロジェクト: PipeDeveloper/Master
def createfiletailsyslog(dstfile):
    rownumber = "100"
    data = tailsyslogcmd(rownumber)
    if data:
        filestoragemod.savefiledata_plaintext(dstfile, data)
        return True
    else:
        print "data empty"
        return False
コード例 #3
0
ファイル: networkdbmod.py プロジェクト: ivan000/hydrosys4mod
def storemessage(message):
    messagelist = []
    messagelist.append(message)
    filestoragemod.savefiledata_plaintext(MESSAGEFILENAME, messagelist)