Пример #1
0
def start():
    # This should be removed if ever committed to an online place or shared
    address = "*****@*****.**"
    password = "******"

    mainPath = r"C:\Users\Carson\OneDrive\College CSU\Year 4\Summer 2018"
    download = mainPath + r"\IHT Project\Data\Server\Daily Test\Full"

    con = connectEmail(address, password)
    emailNumbers = get_unread(con)
    print("Unread: ", emailNumbers)
    count = 1
    conn = SQ.connectDB("root", "Code", "localhost", "iht_test")
    cursor = conn.cursor(buffered=True)
    # Checks if we have unread emails
    if (emailNumbers != None):
        # Iterates through all the unread emails
        for i in emailNumbers:
            print("Running: ", str(count) + " / ", len(emailNumbers))
            #### Email Download and Process ####
            result, data = con.fetch(i, '(RFC822)')
            msg = email.message_from_bytes(data[0][1])
            temp = data[0][1].splitlines()
            date = str(temp[2][12:])
            date = date[3:-1]
            get_attachments(download, msg, date=date)

            # Gets the filename of the downloaded attatchemnts
            fileName = "blank"
            for part in msg.walk():
                if (fileName == "blank" or fileName == None):
                    fileName = part.get_filename()

            fileName = fileName[:-4] + "csv"
            fileName = fileName.replace('\n', '')
            fileName = fileName.replace('\r ', ' ')
            # Determines which file we are dealing with and processes accordingly
            if ("Report View of CREW STATUS TABLE - ONCE DAILY" in fileName):
                #print("Update Crews")
                crewsFile = open(download + "\\" + fileName)
                SQ.update_crews(crewsFile, cursor)
                conn.commit()

            elif ("Report View of CREW REQUEST AUTOMATED QUERY - Released in prior 48 hours"
                  in fileName):
                #print("Update All")
                requestFile = open(download + "\\" + fileName)
                SQ.update_all(requestFile, cursor)
                conn.commit()

            elif ("Report View of CREW REQUEST AUTOMATED QUERY - ONCE DAILY"
                  in fileName):
                #print("Update All")
                requestFile = open(download + "\\" + fileName)
                SQ.update_all(requestFile, cursor)
                conn.commit()
            count += 1
Пример #2
0
def gapCalc(time1, time2):
    if (time1 == None or time2 == None):
        return None
    #zero = datetime.datetime(0000,00,00,00,000,000)
    elif (time1 - time2 == time1 or time2 - time1 == time2):
        return None
    return abs(time1 - time2)


# returns all the requests from the previous 28 day cycle
# uses these request to determine time for the crew to go home
# returns list of all historical data
def get28Days(crewID, date):
    print()


# Checks in the current assignment gap was long enough to go home
# if it was returns true otherwise false
def checkGap(gapTime, assign1, assign2):
    return False


if __name__ == '__main__':

    conn = SQ.connectDB("root", "Code", "localhost", "iht_test")
    cursor = conn.cursor(buffered=True)
    print("Days Left: ", findGap(1330, "2018-05-16 16:35:00", cursor))

    #timeActual = calcTimeNeeded(16,8087625,cursor)

    print()