예제 #1
0
def startDay():
    run = True
    #currentTime = "{0}:{1}:{2}".format(localtime().tm_hour, localtime().tm_min, localtime().tm_sec)
    print (timeFile.currentTime())
    infile = open(("{0}{1}".format(timeFile.day(), ".db")), "a")
    
    while run:
        #Run recieves input from other module
        userID = 113453
        userName = "******"
        #Writes ID, Name, Time, In/Out
        inout = inOut(userID)
        print(inout)
        if str(inout) == "None":
            outfile = open(("{0}{1}".format(timeFile.day(), "InOut.db")), "r+")
            outfile.write(str(userID))
            outfile.close()
        elif inout == "In":
            inout = editInOut(userID, "In")
            print(inout)
        elif inout == "Out":
            inout = editInOut(userID, "Out")
            print(inout)

        infile.write("{0}, {1}, {2}, {3}\n".format(userID, userName, timeFile.currentTime(), inout))
        run = False
                     
    infile.close()
    sleep (2)
    print (timeFile.currentTime())
예제 #2
0
def editInOut(userID, edit):
    infile = open(("{0}{1}".format(timeFile.day(), "InOut.db"))).read()
    if edit == "In":
        infile = infile.replace("{0}, {1}\n".format(userID, edit), ("{0}, {1}\n".format(userID, "Out"))) 
        outfile = open(("{0}{1}".format(timeFile.day(), "InOut.db")), "w")
        outfile.write(infile)
        outfile.close()
        return "Out"

    if edit == "Out":
        infile = infile.replace("{0}, {1}\n".format(userID, edit), ("{0}, {1}\n".format(userID, "In"))) 
        outfile = open(("{0}{1}".format(timeFile.day(), "InOut.db")), "w")
        outfile.write(infile)
        outfile.close()
        return "In"
예제 #3
0
def inOut(userID):
    infile = open(("{0}{1}".format(timeFile.day(), "InOut.db")), "a")
    infile.close()
    infile = open(("{0}{1}".format(timeFile.day(), "InOut.db")), "r+")

    for i in range(10):
        line = infile.readline()          
        if ("{0}, In\n".format(userID)) == line:
            infile.close()
            return "In"
                     
        if ("{0}, Out\n".format(userID)) == line:
            infile.close()
            return "Out"
        
        if str(userID) == line:
            print("here")
            infile.write(", In\n")
            infile.close()
            return
    
    infile.close()