Example #1
0
def updateAvailability(id, avail):
    cnx = dbCred.getCNX()
    cursor = cnx.cursor()
    cursor.execute("update officer set status = %s where officer_id = %s", (avail, id))
    cnx.commit()
    cnx.close()
    cursor.close()
Example #2
0
    def __init__(self, list):
        self.call_id = getCallID()
        self.callType = list[0]
        self.street_address = list[1]
        self.city = list[2]
        self.zip = list[3]
        self.place = list[4]
        self.phone = list[5]
        self.description = list[6]
        self.time_start = datetime.datetime.now()
        self.time_end = None
        self.officer_id = list[7]
        self.report = ""
        self.active = True
        self.on_scene_time = None

        statement = "INSERT INTO calls VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
        cnx = dbCred.getCNX()
        cursor = cnx.cursor()
        cursor.execute(statement, (self.call_id, self.callType, self.street_address, self.city, self.zip, self.place,
                                   self.phone, self.description, self.time_start, self.time_end, self.officer_id,
                                   self.report, self.active, self.on_scene_time))
        cnx.commit()
        cursor.execute("update officer set cur_call = %s where officer_id = %s", (self.call_id, self.officer_id))
        cnx.commit()
        cnx.close()
        cursor.close()
Example #3
0
def updateOnline(id, online):
    cnx = dbCred.getCNX()
    cursor = cnx.cursor()
    cursor.execute("update officer set on_duty = %s where officer_id = %s", (online, id))
    cnx.commit()
    cnx.close()
    cursor.close()
Example #4
0
def setCallInactive(id):
    print("setting active to false")
    cnx = dbCred.getCNX()
    cursor = cnx.cursor()
    cursor.execute("update calls set active = False where call_id = %s", id)
    cnx.commit()
    cursor.close()
    cnx.close()
Example #5
0
 def submit(self):
     cnx = dbCred.getCNX()
     cursor = cnx.cursor()
     expression = 'update calls set report_file = "nothing there" where call_id = 15'
     cursor.execute(expression)
     cursor.execute('update calls set report_file = %s where call_id = %s',
                    (str(self.ids.reportText.text), int(self.callid)))
     cnx.commit()
     cnx.close()
     cursor.close()
     self.dismiss()
Example #6
0
def addNow(id):
    cnx = dbCred.getCNX()
    call_id = 0
    cursor = cnx.cursor()
    cursor.execute("select call_id from calls where officer_id = %s and active = true", id)
    for cur in cursor:
        call_id = cur['call_id']
    now = datetime.datetime.now()
    cursor.execute("select on_scene_time from calls where call_id = %s", call_id)
    for st in cursor:
        if st["on_scene_time"] is not None:
            return
    try:
        cursor.execute("update calls set on_scene_time = %s where call_id = %s", (now, call_id))
    except:
        pass
    cnx.commit()
    cnx.close()
    cursor.close()
Example #7
0
def getCursor():
    cnx = dbCred.getCNX()
    cursor = cnx.cursor()
    return cursor
Example #8
0
def checkCall():
    time.sleep(2)
    print("Starting Call Check Thread")
    # While the officer screen is open/logged in
    checkState()
    while globals.offRunning is True:
        checkState()
        # If there is no current call - Text should be blank (' ' for aesthetic purposes)
        if globals.screens[2].ids.type.text == ' ':
            # Build cursor object with the call info
            cnx = dbCred.getCNX()
            cursor = cnx.cursor()
            cursor.execute(
                "select * from calls where officer_id = %s and active = True",
                globals.info[1])
            # Run through each item in the cursor, print it to the screen, build array for gTTS
            for row in cursor:
                ttsp = []
                globals.screens[2].ids.type.text = row["type"]
                ttsp.append(row["type"])
                globals.screens[2].ids.addr.text = row["street_address"]
                ttsp.append(row["street_address"])
                globals.screens[2].ids.city.text = row["city"]
                globals.screens[2].ids.zip.text = str(row["zip"])
                globals.screens[2].ids.place.text = row["place"]
                ttsp.append(row["place"])
                globals.screens[2].ids.phone.text = row["phone"]
                globals.screens[2].ids.desc.text = row["description"]
                ttsp.append(row["description"])
                globals.cur_call = row["call_id"]
                # Change availability
                cursor.execute(
                    'update officer set cur_call = %s where officer_id = %s',
                    (globals.cur_call, globals.info[1]))
                cnx.commit()
                globals.screens[2].ids.cb.buildCall(row['time_start'],
                                                    row['street_address'],
                                                    row['call_id'])
                # Change Status'
                flipState('tenSeven', '')
                # Build the gTTS and play it
                Thread(target=tts.build(ttsp)).start()
            cnx.close()
            cursor.close()
        # If in a current call, check if their status is available then end call
        else:
            cnx = dbCred.getCNX()
            cursor = cnx.cursor()
            # Get current status
            cursor.execute("select * from officer where officer_id = %s",
                           globals.info[1])
            for row in cursor:
                # Check if available, if so end the call, change database information
                if row['status'] is 1:
                    flipState('tenEight', 'twentyThreeN')
                    globals.screens[2].clear()
                    now = datetime.datetime.now()
                    cursor.execute(
                        'update officer set cur_call = NULL where officer_id = %s',
                        globals.info[1])
                    cursor.execute(
                        'update calls set active = False , time_end = %s where call_id = %s',
                        (now, globals.cur_call))
                    print(globals.cur_call)
                    cnx.commit()
        time.sleep(.25)
    print("Stopping Thread")