Ejemplo n.º 1
0
 def share(self):
     project_dict = s.listProjects(folder_id, service)
     project_name, ok = QInputDialog.getItem(self, "Collaborate",
                                             "Select a project to share",
                                             project_dict, 0, False)
     if ok and project_name:
         project_id = project_dict[project_name]
         print(self.user_email)
         try:
             s.shareProject(service, project_id, self.user_email)
             message = "Project shared with " + (self.user_email)
             msg = QMessageBox()
             msg.setText(message)
             msg.setWindowTitle("Shared Project")
             msg.setStyleSheet(
                 'background-color: darkSlateGray; color: white; font: Courier'
             )
             msg.setIcon(QMessageBox.Information)
             msg.exec_()
         except:
             message = "Unable to share project with " + (self.user_email)
             msg = QMessageBox()
             msg.setText(message)
             msg.setStyleSheet(
                 'background-color: darkSlateGray; color: white; font: Courier'
             )
             msg.setWindowTitle("Share Project Error")
             message = "Please ensure " + self.user_email + " is a valid email address"
             msg.setInformativeText(message)
             msg.setIcon(QMessageBox.Warning)
             msg.exec_()
Ejemplo n.º 2
0
 def delete(self):
     print("Deleting from contacts:", self.user_email)
     s.deleteContact(self.user_email)
     message = "Deleted " + self.user_email + " from contacts"
     msg = QMessageBox()
     msg.setText(message)
     msg.setWindowTitle("Deleted Contact")
     msg.setStyleSheet(
         'background-color: darkSlateGray; color: white; font: Courier')
     msg.setIcon(QMessageBox.Information)
     msg.exec_()
     #self.hide()
     for widget in self.win.contWidget:  #show all widgets with contact deleted from it
         widget.hide()  #show all the contacts widgets
     contacts = s.addContact(None, None, None)
     self.win.contWidget = []
     #have to update the contacts widget so that when we add a new contact or delete contacts
     #old ones dont reappear
     for name in contacts:
         user_email = contacts[
             name]  #accessing email from dictionary of contacts
         item = contactsWidget(
             name, user_email, self.win
         )  #make a project widget with the name of the current project
         #and with the list with file_id and project_id
         self.win.controlsLayout.insertWidget(0, item)
         self.win.contWidget.append(
             item)  #append it to our list of widgets of projects
     for widget in self.win.contWidget:  #show all widgets with contact deleted from it
         widget.show()  #show all the contacts widgets
     self.win.currentWindow = self.win.contWidget
Ejemplo n.º 3
0
 def delete(self, fileProj_id):
     try:
         q_box = QtWidgets.QMessageBox(
             self)  #create a message box asking do you want to delete file
         q_box.setStandardButtons(QtWidgets.QMessageBox.No
                                  | QtWidgets.QMessageBox.Yes)
         q_box.setWindowTitle("Delete File")
         q_box.setText("Are you sure you would like to delete this file?")
         q_box.setStyleSheet(
             'background-color: darkSlateGray; color: white; font: Courier')
         q_box.exec_()
         if (q_box.result() == QtWidgets.QMessageBox.Yes
             ):  #if response is yes, deletes the file
             s.delete(service, self.fileProj_id[0])
             #hide the deleted widget
             self.hide()
         else:
             print("User chose not to delete", self.name)
     except:  #if file doesn't exist, must already be deleted
         error_dialog = QtWidgets.QErrorMessage(
         )  #show file already deleted error msg
         error_dialog.showMessage("File already deleted")
         error_dialog.setWindowTitle("File error")
         error_dialog.setStyleSheet(
             'background-color: darkSlateGray; color: white; font: Courier')
         error_dialog.exec_()
Ejemplo n.º 4
0
 def deleteProj(self):
     try:
         q_box = QtWidgets.QMessageBox(
             self
         )  #create a message box asking do you want to delete the project
         q_box.setStandardButtons(QtWidgets.QMessageBox.No
                                  | QtWidgets.QMessageBox.Yes)
         q_box.setWindowTitle("Delete Project")
         q_box.setText(
             "Are you sure you would like to delete this project?")
         q_box.setStyleSheet(
             'background-color: darkSlateGray; color: white; font: Courier')
         q_box.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
         q_box.exec_()
         if (q_box.result() == QtWidgets.QMessageBox.Yes
             ):  #if response is yes, deletes the the project
             s.delete(service, self.project_id)
             #hide the deleted widget
             self.win.currentWindow = self.win.projWidget
             self.hide()
         else:
             print("User chose not to delete", self.name)
     except:  #if file doesn't exist, must already be deleted
         error_dialog = QtWidgets.QErrorMessage(
         )  #show project already deleted error msg
         error_dialog.showMessage("Project already deleted")
         error_dialog.setWindowTitle("File error")
         error_dialog.setStyleSheet(
             'background-color: darkSlateGray; color: white; font: Courier')
         error_dialog.exec_()
Ejemplo n.º 5
0
def Compile_Drives(pbp_data, game):
	drives = []
	cur_drive = Drive(0, 0, 0, 0, 0, 0)
	cur_drive.Finished = 1
	for play in pbp_data:
		game.Set_Quarter(play)
		start = re.match(r"t(?P<offense>\d+) at (?P<min>\d{1,2})\:(?P<sec>\d{2})", play[0])
		stop = re.match(r"t(?P<team>\d+) DRIVE TOTALS\: (?P<plays>\d+) play(?:s)?\, (?:\-)?(?P<yards>\d+) (?:yards|yard|yds|yd)\, (?P<min>\d{1,2})\:(?P<sec>\d{2})", play[0])
		if start:	# Check for the start of a new drive
			if int(start.group("offense")) == game.Home:
				offense = game.Home
				defense = game.Visitor
			elif int(start.group("offense")) == game.Visitor:
				offense = game.Visitor
				defense = game.Home
			else:
				print int(start.group("offense"))
				print game.Home
				print game.Visitor
			start_time = Set_Clock(start.group("min"), start.group("sec"))
			if cur_drive.Finished != 1 and cur_drive.Game_Code != 0:
				# print "WARNING: Drive summary never produced"
				drives.append(cur_drive)
			cur_drive = Drive(game.Code, offense, defense, start_time, game.Current_Qrt, len(drives) + 1)
		elif stop:	# Check for the end of a drive
			plays = int(stop.group("plays"))
			yards = int(stop.group("yards"))
			stop_time = Set_Clock(stop.group("min"), stop.group("sec"))
			cur_drive.Set_Summary(plays, yards, stop_time, game.Current_Qrt)
			if cur_drive.Game_Code != 0:
				drives.append(cur_drive)
		else:		# Add play to drives
			cur_drive.Raw_Pbp_Data.append(play)
	return drives
Ejemplo n.º 6
0
 def collaborateProj(self):
     contacts = s.addContact(None, None, None)
     contact_selected, ok = QInputDialog.getItem(self,
                                                 "Collaborate on Project",
                                                 "Contacts", contacts, 0,
                                                 False)
     if ok and contact_selected:
         user_email = contacts[contact_selected]
         try:
             s.shareProject(service, self.project_id, user_email)
             message = "Project shared with " + contact_selected + ": " + contacts[
                 contact_selected]
             print(message)
             msg = QMessageBox()
             msg.setText(message)
             msg.setWindowTitle("Shared Project")
             msg.setIcon(QMessageBox.Information)
             msg.setStyleSheet(
                 'background-color: darkSlateGray; color: white; font: Courier'
             )
             msg.exec_()
         except:
             message = "Unable to share project with " + (user_email)
             msg = QMessageBox()
             msg.setText(message)
             msg.setWindowTitle("Share Project Error")
             message = "Please ensure " + user_email + " is a valid email address"
             msg.setInformativeText(message)
             msg.setIcon(QMessageBox.Warning)
             msg.setStyleSheet(
                 'background-color: darkSlateGray; color: white; font: Courier'
             )
             msg.exec_()
Ejemplo n.º 7
0
 def uploadToProj(self):
     print(self.name, "id is", self.project_id)
     loop = True  #reacurring loop if we keep cancelling uploads and then say we want to upload
     while (loop == True):
         file_uploaded = s.upload(service, self.name, self.project_id)
         if (file_uploaded == None):
             q_box = QtWidgets.QMessageBox(
                 self
             )  #create a message box asking do you want to upload to the project
             q_box.setStandardButtons(QtWidgets.QMessageBox.No
                                      | QtWidgets.QMessageBox.Yes)
             q_box.setWindowTitle("Upload to Project")
             q_box.setStyleSheet(
                 'background-color: darkSlateGray; color: white; font: Courier'
             )
             q_box.setText(
                 "No file was uploaded, do you want to try again?")
             q_box.exec_()
             if (q_box.result() != QtWidgets.QMessageBox.Yes):
                 loop = False
         else:  #This means we uploaded a file successfully
             msg_box = QtWidgets.QMessageBox(
                 self
             )  #create a message box asking do you want to upload to the project
             msg_box.setWindowTitle("Upload Successful")
             msg_box.setText("File uploaded to " + self.name)
             msg_box.setStyleSheet(
                 'background-color: darkSlateGray; color: white; font: Courier'
             )
             msg_box.exec_()
             loop = False
     self.win.currentWindow = self.win.projWidget
Ejemplo n.º 8
0
    def projView(self):
        for widget in self.fileWidget:  #hide all file widgets
            widget.hide()
        for widget in self.contWidget:  #hide all contacts widgets
            widget.hide()
        for widget in self.projWidget:  #hide all project widgets
            widget.hide()
        # List of names, widgets are stored in a dictionary by these keys.
        self.projWidget = []
        project_dict = s.listProjects(folder_id, service)
        #Iterating through all the projects, creating a widget
        #for each one with their own buttons
        for name in project_dict:
            project_id = project_dict[name]
            #print("adding",name, "to widget:", project_id, "ProjectWindow")
            item = ProjectWidget(
                name, project_id, self
            )  #make a project widget with the name of the current project
            self.controlsLayout.insertWidget(
                0, item
            )  #^^^ we pass self so we can hide it from the widgets inside it
            self.projWidget.append(
                item)  #append it to our list of widgets of projects

        self.NewContact.hide()  #hide the add new contacts button
        self.contacts.show()  #show the view contacts button
        self.currentWindow = self.projWidget
Ejemplo n.º 9
0
 def viewProj(self):
     print("id is", self.project_id)
     for widget in self.win.projWidget:
         widget.hide()
     self.win.fileWidget = []
     project_dict = s.listProjects(folder_id, service)
     #print(project_dict)
     proj_id = project_dict[self.name]
     thisProj_dict = s.listProjects(proj_id, service)
     for name in thisProj_dict:
         file_id = thisProj_dict[name]  #access file_id from the dictionary
         fileProj_id = [file_id, proj_id]  #bundle it into list object
         #print("adding",name, "to widget:", file_id)
         item = viewWidget(
             name, fileProj_id
         )  #make a project widget with the name of the current project
         #and with the list with file_id and project_id
         self.win.controlsLayout.insertWidget(0, item)
         self.win.fileWidget.append(
             item)  #append it to our list of widgets of projects
     self.win.currentWindow = self.win.fileWidget  #set it as current window to filter results in search bar
Ejemplo n.º 10
0
 def addNew(self):
     contacts = s.addContact(None, None, None)  #refresh the contacts list
     loop = True  #loop around until they either create a new contact successfully or decide to not create one
     while loop == True:
         name_in, ok = QInputDialog.getText(self, 'New Contact',
                                            'Contact Name:')
         if (ok):  #if okay button pressed for name
             contact_name = str(name_in)  #convert to string
             email_in, ok = QInputDialog.getText(self, 'New Contact',
                                                 'Contact Email:')
             contact_email = str(email_in)  #convert to string
             if (ok) & (
                     contact_name != contact_email
             ):  #if okay button pressed for email, and theyre not the same
                 s.addContact(contact_name, contact_email, contacts)
                 for widget in self.contWidget:  #hide all the widgets
                     widget.hide()
                 item = contactsWidget(
                     contact_name, contact_email, self
                 )  #make a project widget with the name of the current project
                 self.controlsLayout.insertWidget(
                     0, item)  #insert it at the top of the list
                 self.contWidget.append(
                     item)  #append it to our list of widgets of projects
                 for widget in self.contWidget:  #show all widgets with new contacts appended to it
                     widget.show()  #show all the contacts widgets
                 loop = False
             elif (contact_name == contact_email):
                 msg_box = QtWidgets.QMessageBox(self)
                 msg_box.setWindowTitle("New Contact Error")
                 msg_box.setText(
                     "Contact name and email address can't be the same")
                 msg_box.setStyleSheet(
                     'background-color: darkSlateGray; color: white; font: Courier'
                 )
                 msg_box.exec_(
                 )  #they cant be the same, ask them to enter new details
         else:  #break from loop as we chose not to add a new contact
             loop = False
     self.currentWindow = self.contWidget
Ejemplo n.º 11
0
 def down(self, fileProj_id):
     try:
         loop = True
         while loop == True:
             print("Downloading file with id:", self.fileProj_id[0])
             success = s.download(
                 self.fileProj_id[0],
                 service)  #download the file from the drive
             if success:
                 return loop == False
             else:
                 q_box = QtWidgets.QMessageBox(
                     self
                 )  #create a message box asking do you want to delete file
                 q_box.setStandardButtons(QtWidgets.QMessageBox.No
                                          | QtWidgets.QMessageBox.Yes)
                 q_box.setWindowTitle("Download Failed")
                 q_box.setText(
                     "Would you like to try and download the file again?")
                 q_box.setStyleSheet(
                     'background-color: darkSlateGray; color: white; font: Courier'
                 )
                 q_box.exec_()
                 if (q_box.result() != QtWidgets.QMessageBox.Yes
                     ):  #if response is not yes, breaks the loop
                     cancel_dialog = QtWidgets.QMessageBox(
                     )  #let user know they cancelled the download
                     cancel_dialog.setText("The file was not downloaded")
                     cancel_dialog.setWindowTitle("Download Cancelled")
                     cancel_dialog.setStyleSheet(
                         'background-color: darkSlateGray; color: white; font: Courier'
                     )
                     cancel_dialog.exec_()  #show the message box
                     return loop == False  #breaks loop
     except:
         cancel_dialog = QtWidgets.QMessageBox(
         )  #let user know they cancelled the download
         cancel_dialog.setText("The file was not downloaded")
         cancel_dialog.setWindowTitle("Download Cancelled")
         cancel_dialog.setStyleSheet(
             'background-color: darkSlateGray; color: white; font: Courier')
         cancel_dialog.exec_()  #show the message box
Ejemplo n.º 12
0
 def contactsView(self):
     for widget in self.projWidget:
         widget.hide()  #hide all the projects widgets
     for widget in self.fileWidget:
         widget.hide()  #hide all the file widgets
     for widget in self.contWidget:
         widget.hide()  #show all the contacts widgets
     self.contacts.hide()  #hide view contacts button
     self.NewContact.show()  #show add new contacts button
     #this will to take us to scrollable contacts view
     self.contWidget = []  #empty list of contact widgets
     contacts = s.addContact(None, None, None)  #get the list of contacts
     for name in contacts:
         user_email = contacts[
             name]  #accessing email from dictionary of contacts
         item = contactsWidget(
             name, user_email, self
         )  #make a project widget with the name of the current project
         #and with the list with file_id and project_id
         self.controlsLayout.insertWidget(0, item)
         self.contWidget.append(
             item)  #append it to our list of widgets of projects
     self.currentWindow = self.contWidget
data = Data()

leftMotor = LargeMotor(OUTPUT_A)
rightMotor = LargeMotor(OUTPUT_B)
ultrasonicMotor = MediumMotor(OUTPUT_C)
clawMotor = MediumMotor(OUTPUT_D)
colorSensor = ColorSensor(INPUT_2)
gyroSensor = GyroSensor(INPUT_3)
ultrasonicSensor = UltrasonicSensor(INPUT_4)
try:
    victimUltrasonicSensor = UltrasonicSensor(INPUT_1)
except:
    victimUltrasonicSensor = 1
    data.cprint('FATAL: VICTIM ULTRASONIC SENSOR IS NOT PLUGGED IN')

drive = Drive(leftMotor, rightMotor, gyroSensor, ultrasonicSensor, colorSensor,
              victimUltrasonicSensor, clawMotor, start_time)
us_arm = UltrasonicArm(ultrasonicMotor, gyroSensor, ultrasonicSensor)

mazealg = MazeAlgorithm()


def elapsed_time():
    return str(time.time() - start_time)


def init_robot():
    print('WARNING: INIT ROBOT', file=sys.stderr, flush=True)
    drive.drive_init()


def main():
Ejemplo n.º 14
0
WebContentID = '1YgCNWrbxPUT9bGaNzVYjY0i6itJj1_Hi'
PurchasesID = '14WmsBbl2sbo0ctoGiPPR3Pom-h4PisZz'
DocID = "1OVgaYiZkLOOzfYxjhm1pf3O2Rm3SsxYViYg7JIHQjco"
TestID = "17hOXCgzzCd-dE6CXHbf2U-ltyjrbT8MyN05g0zDU-aQ"
url = "http://127.0.0.1:8000/uploads/inventory/"
#url  = "http://blasterhackers.com/uploads/components/"
inventoryURL = "http://blasterhackers.com/uploads/inventory/"
SHEET_ID = '1boZJT_4ePXHZBbRs2_LLiUvZl-F6qZm8SDOkOMsPEAg'
BigDocID = "1hczIuBEJMP3E4vvdV91h87LrBtnE-w-xUUXqDqPALnc"

purchases2018ID = '1O7ZQ5BRnesuut6zHC1TwllNJIXXihq0b'
purchases2019ID = '1YvRyPvyZe4nIKireP68Nz5QhWL4dYnbu'

u = Uploader.Uploader(url)
d = Drive.Service()
h = HTMLParser()
s = Sheets.Service()


def main():
    # h.parseDoc("samples/Test File.html")
    title = d.getDocHTML(BigDocID)
    # data = HTML_Editor.parseDoc(title)
    docs = d.getChilds(PurchasesID)
    # updateContent(WebContentID)
    # s = Sheets.Service()

def individualTest():
    file_name = d.getDocHTML("1bgD38YbS3znMUDBJpgLFQ1hTg8VnTjNehmZkh0JZiCM")
    content = HTML_Editor.parseDoc("doc_html/Dream Orb")
Ejemplo n.º 15
0
def Compile_Drives(pbp_data, game):
    drives = []
    cur_drive = Drive(0, 0, 0, 0, 0, 0)
    cur_drive.Finished = 1
    new_Quarter = False
    ignore_start = False
    new_Half = False
    prev_off = 0
    prev_start = ""
    for play in pbp_data:

        start = re.match(
            r"t(?P<offense>\d+) at (?P<min>\d{1,2})\:(?P<sec>\d{2})", play[0])
        stop = re.match(
            r"t(?P<team>\d+) DRIVE TOTALS\: (?P<plays>\d+) play(?:s)?\, (?:\-)?(?P<yards>\d+) (?:yards|yard|yds|yd)(\, (?P<min>\d{1,2})\:(?P<sec>\d{2}))?",
            play[0], re.IGNORECASE)

        quarter_start1 = game.Set_Quarter(play)
        quarter_start2 = re.match(
            r"(?P<qrt>\d)(?:st|nd|rd|th) Quarter Play-by-Play", play[0],
            re.IGNORECASE)
        if quarter_start1 and quarter_start2:
            new_Quarter = True
            if game.Current_Qrt == 1 or game.Current_Qrt == 3:
                new_Half = True
        elif not quarter_start1 and quarter_start2:
            ignore_start = True

        if start:  # Check for the start of a new drive
            if ignore_start:
                ignore_start = False
            elif prev_start == play[
                    0] and cur_drive.Finished == 0 and cur_drive.Game_Code != 0:
                continue
            elif not new_Quarter or (new_Quarter and prev_off != int(
                    start.group("offense"))) or new_Half:
                if int(start.group("offense")) == game.Home:
                    offense = game.Home
                    defense = game.Visitor
                elif int(start.group("offense")) == game.Visitor:
                    offense = game.Visitor
                    defense = game.Home
                else:
                    print int(start.group("offense"))
                    print game.Home
                    print game.Visitor
                    print "Couldn't find who the offense is"
                    raw_input()
                start_time = Set_Clock(start.group("min"), start.group("sec"))

                if cur_drive.Finished == 0 and cur_drive.Game_Code != 0:
                    print "WARNING: Drive summary never produced"
                    print play[0]
                    print game.Current_Qrt
                    print new_Quarter
                    print new_Half
                    print prev_off
                    print int(start.group("offense"))
                    # raw_input()
                    drives.append(cur_drive)

                prev_start = play[0]
                prev_off = offense
                new_Quarter = False
                new_Half = False
                cur_drive = Drive(game.Code, offense, defense, start_time,
                                  game.Current_Qrt,
                                  len(drives) + 1)
        elif stop:  # Check for the end of a drive
            plays = int(stop.group("plays"))
            yards = int(stop.group("yards"))
            try:
                stop_time = Set_Clock(stop.group("min"), stop.group("sec"))
            except:
                stop_time = cur_drive.Start_Time
            cur_drive.Set_Summary(plays, yards, stop_time, game.Current_Qrt)
            if cur_drive.Game_Code != 0:
                # print "Summary produced"
                drives.append(cur_drive)
        else:  # Add play to drives
            cur_drive.Raw_Pbp_Data.append(play)
    return drives
def main():
    rospy.init_node('smach_example_state_machine')

    # Create a SMACH state machine
    sm_main = smach.StateMachine(outcomes=['TisUseless'])
    sm_main.userdata.aVariable = 0

    sm_dumper = Dumping_State_Machine.dumper_main()
    sm_digger = Digging_State_Machine.digger_main()

    # Open the container
    with sm_main:
        # Add startup state to the Container
        smach.StateMachine.add('Startup',
                               Starting(),
                               transitions={'outcome_start': 'Drive'},
                               remapping={
                                   'x_in': 'aVariable',
                                   'x_out': 'aVariable'
                               })

        # Under here are the states that will continue to loop
        smach.StateMachine.add('Drive',
                               Drive.Driving(),
                               transitions={
                                   'outcome_mine': 'Mine',
                                   'outcome_dump': 'Dump',
                                   'outcome_manual': 'Manual'
                               },
                               remapping={
                                   'x_in': 'aVariable',
                                   'x_out': 'aVariable'
                               })
        smach.StateMachine.add('Mine',
                               Mining.Mining(),
                               transitions={
                                   'outcome_drive': 'Drive',
                                   'outcome_manual': 'Manual',
                                   'outcome_dig': 'Start_Digging'
                               },
                               remapping={
                                   'x_in': 'aVariable',
                                   'x_out': 'aVariable'
                               })
        smach.StateMachine.add('Dump',
                               Dump.Dump(),
                               transitions={
                                   'outcome_drive': 'Drive',
                                   'outcome_manual': 'Manual',
                                   'outcome_dump': 'Start_Dumping'
                               },
                               remapping={
                                   'x_in': 'aVariable',
                                   'x_out': 'aVariable'
                               })
        smach.StateMachine.add('Manual',
                               Manual_Control.Manual_Control(),
                               transitions={
                                   'outcome_drive': 'Drive',
                                   'outcome_mine': 'Mine',
                                   'outcome_dump': 'Dump'
                               },
                               remapping={
                                   'x_in': 'aVariable',
                                   'x_out': 'aVariable'
                               })

        # Create Dig Sub Container
        smach.StateMachine.add('Start_Digging',
                               sm_digger,
                               transitions={'end_digging': 'Dump'},
                               remapping={
                                   'aVar': 'aVariable',
                                   'aVar': 'aVariable'
                               })

        # Create Dump Sub Container
        smach.StateMachine.add('Start_Dumping',
                               sm_dumper,
                               transitions={'end_dumping': 'Drive'},
                               remapping={
                                   'aVari': 'aVariable',
                                   'aVari': 'aVariable'
                               })

    sis = smach_ros.IntrospectionServer('state_machine', sm_main, '/SM_ROOT')
    sis.start()

    # Execute SMACH plan
    sm_main.execute()

    rospy.spin()
    sis.stop()
Ejemplo n.º 17
0
    def __init__(self, *args, **kwargs):
        super().__init__()
        #Create our 4 main buttons, the add contacts button will only be visible
        #on the contacts screen
        self.setStyleSheet(
            'background-color: #242424; color: white; font-size: 14pt;'
            'font: Courier;')
        self.create = QtWidgets.QPushButton(self)
        self.create.setText("Create Project")
        # padding: 6px;')
        self.create.setStyleSheet(
            "QPushButton{background-color : darkSlateGray;}"
            "QPushButton::pressed{background-color : #242424;}")
        self.create.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
        self.create.clicked.connect(self.createProj)

        self.view = QtWidgets.QPushButton(self)
        self.view.setText("View All Projects")
        self.view.setStyleSheet(
            "QPushButton{background-color : darkSlateGray;}"
            "QPushButton::pressed{background-color : #242424;}")
        self.view.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
        self.view.clicked.connect(self.projView)

        self.contacts = QtWidgets.QPushButton(self)
        self.contacts.setText("Contacts")
        self.contacts.setStyleSheet(
            "QPushButton{background-color : darkSlateGray;}"
            "QPushButton::pressed{background-color : #242424;}")
        self.contacts.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
        self.contacts.clicked.connect(self.contactsView)

        #This button is hidden and only made visible on contacts screen
        self.NewContact = QtWidgets.QPushButton(self)
        self.NewContact.setText("Add New Contact")
        self.NewContact.clicked.connect(self.addNew)
        self.NewContact.setStyleSheet(
            "QPushButton{background-color : darkSlateGray;}"
            "QPushButton::pressed{background-color : #242424;}")
        self.NewContact.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
        self.NewContact.hide()

        self.controls = QWidget()  #Controls container widget.
        self.controlsLayout = QVBoxLayout()  #Controls container layout.

        # List of names, widgets are stored in a dictionary by these keys.
        self.projWidget = []
        project_dict = s.listProjects(folder_id, service)
        #Iterating through all the projects, creating a widget
        #for each one with their own buttons
        for name in project_dict:
            project_id = project_dict[name]
            #print("adding",name, "to widget:", project_id, "ProjectWindow")
            item = ProjectWidget(
                name, project_id, self
            )  #make a project widget with the name of the current project
            self.controlsLayout.insertWidget(
                0, item
            )  #^^^ we pass self so we can hide it from the widgets inside it
            self.projWidget.append(
                item)  #append it to our list of widgets of projects

        self.contWidget = []  #empty list of contact widgets
        contacts = s.addContact(None, None, None)  #get the list of contacts

        for name in contacts:
            user_email = contacts[
                name]  #accessing email from dictionary of contacts
            item = contactsWidget(
                name, user_email, self
            )  #make a project widget with the name of the current project
            #and with the list with file_id and project_id
            self.controlsLayout.insertWidget(0, item)
            self.contWidget.append(
                item)  #append it to our list of widgets of projects

        #Hide the contacts until the contact view is opened
        for widget in self.contWidget:
            widget.hide()

        self.fileWidget = [
        ]  #declaring this for later use in viewing the files in a project

        #Hide the project view widgets until a project is clicked
        for widget in self.fileWidget:
            widget.hide()

        spacer = QSpacerItem(1, 1, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.controlsLayout.addItem(spacer)
        self.controls.setLayout(self.controlsLayout)

        # Scroll Area Properties.
        self.scroll = QScrollArea()
        self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scroll.setWidgetResizable(True)
        self.scroll.setWidget(self.controls)

        # Search bar.
        self.searchbar = QLineEdit()
        self.searchbar.setStyleSheet(
            'background-color: white; color: black; font: Courier; padding: 6px;'
            'border-style: outset;'
            'border-width: 2px; border-radius: 6px;'
            'border-color: beige;')
        self.searchbar.textChanged.connect(self.update_display)

        # Adding Completer.
        self.completer = QCompleter(project_dict)
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.searchbar.setCompleter(self.completer)

        #Add the items to VBoxLayout (applied to container widget)
        #which encompasses the whole window.
        container = QWidget()
        containerLayout = QVBoxLayout()
        containerLayout.addWidget(self.create)
        containerLayout.addWidget(self.view)
        containerLayout.addWidget(self.contacts)
        containerLayout.addWidget(self.NewContact)
        containerLayout.addWidget(self.searchbar)
        containerLayout.addWidget(self.scroll)

        container.setLayout(containerLayout)
        self.setCentralWidget(container)

        self.showMaximized()
        self.setWindowTitle('StudioHub')

        #when we initialise this is the current window
        #We will keep track of this and hide all other results outside of it
        self.currentWindow = self.projWidget
Ejemplo n.º 18
0
 def run(self):
     try:
         nextcommand = self.cmdlist[self.index]
         self.index += 1
         if nextcommand and self.running:
             if nextcommand[0] is "f":
                 if len(nextcommand) is 3:
                     dist = float(nextcommand[2])
                     Drive.getinstance().forwardtime(dist)
                 else:
                     dist = float(nextcommand[2] + nextcommand[3])  
                     Drive.getinstance().forwardtime(dist)
                     
             elif nextcommand[0] is "b":
                 if len(nextcommand) is 3:
                     dist = float(nextcommand[2])
                     Drive.getinstance().reverse(dist)
                 else:
                     dist = float(nextcommand[2] + nextcommand[3])
                     Drive.getinstance().reverse(dist)      
             
             elif nextcommand[0] is "l":
                 if len(nextcommand) is 3:
                     deg = int(nextcommand[2])
                     Drive.getinstance().left(deg)
                 else:
                     deg = int(nextcommand[2] + nextcommand[3])
                     Drive.getinstance().left(deg)
                     
             elif nextcommand[0] is "r":
                 if len(nextcommand) is 3:
                     deg = int(nextcommand[2])
                     Drive.getinstance().right(deg)
                 else:
                     deg = int(nextcommand[2] + nextcommand[3])
                     Drive.getinstance().right(deg)
                     
             elif nextcommand[0] is "s":
                 Drive.getinstance().stop()
             
             elif nextcommand is None:
                 Drive.getinstance().stop()
             
             else:
                 raise SyntaxError("Invalid syntax: " + nextcommand)
     except:
         if self.running:
             print("Stopped")
         self.running = False
Ejemplo n.º 19
0
# Change these certificate names
createMQTTClient.configureCredentials(
    "/home/pi/TwitchRobot/certs/AmazonRootCA1.crt",
    "/home/pi/TwitchRobot/certs/TwitchRobot.pem.key",
    "/home/pi/TwitchRobot/certs/TwitchRobot.pem.crt")
createMQTTClient.configureOfflinePublishQueueing(
    -1)  # Infinite offline Publish queueing
createMQTTClient.configureDrainingFrequency(2)  # Draining: 2 Hz
createMQTTClient.configureConnectDisconnectTimeout(10)  # 10 sec
createMQTTClient.configureMQTTOperationTimeout(5)  # 5 sec

createMQTTClient.connect()

rospy.init_node('alexa', anonymous=True)
drive = Drive()


def unsubscribe_topics():
    """Unbsubscribes from AWS IoT topics before exiting
    """

    topics = ['/voice/drive']

    for topic in topics:
        createMQTTClient.unsubscribe(topic)


# Interrupt Handler useful to break out of the script
def interrupt_handler(signum, frame):
    unsubscribe_topics()
Ejemplo n.º 20
0
    def createProj(self):
        #Text input doalog window to input project name
        text, ok = QInputDialog.getText(self, 'New Project',
                                        'Name your project:')
        if (ok):  #if okay button pressed
            project_name = str(text)  #project name is string of inputted text
            #calling it project id created to use it if we want to upload soemthing to it straight away
            project_id_created = s.newProject(
                folder_id, project_name,
                service)  #make a new project with that name
            for widget in self.contWidget:
                widget.hide()
            for widget in self.fileWidget:
                widget.hide()
            for widget in self.projWidget:
                widget.hide()
            # List of names, widgets are stored in a dictionary by these keys.
            self.projWidget = []
            project_dict = s.listProjects(folder_id, service)
            #Iterating through all the projects, creating a widget
            #for each one with their own buttons
            for name in project_dict:
                project_id = project_dict[name]
                #print("adding",name, "to widget:", project_id, "ProjectWindow")
                item = ProjectWidget(
                    name, project_id, self
                )  #make a project widget with the name of the current project
                self.controlsLayout.insertWidget(
                    0, item
                )  #^^^ we pass self so we can hide it from the widgets inside it
                self.projWidget.append(
                    item)  #append it to our list of widgets of projects

            q_box = QtWidgets.QMessageBox(
                self
            )  #create a message box asking do you want to upload to the project
            q_box.setStandardButtons(QtWidgets.QMessageBox.No
                                     | QtWidgets.QMessageBox.Yes)
            q_box.setWindowTitle("Upload to Project")
            q_box.setText("Would you like to upload a file to this project?")
            q_box.setStyleSheet(
                'background-color: darkSlateGray; color: white; font: Courier')
            q_box.exec_()
            if (q_box.result() == QtWidgets.QMessageBox.Yes):
                loop = True  #reacurring loop if we keep cancelling uploads and then say we want to upload
                while (loop == True):
                    file_uploaded = s.upload(service, project_name,
                                             project_id_created)
                    if (file_uploaded == None):
                        q_box = QtWidgets.QMessageBox(
                            self
                        )  #create a message box asking do you want to upload to the project
                        q_box.setStandardButtons(QtWidgets.QMessageBox.No
                                                 | QtWidgets.QMessageBox.Yes)
                        q_box.setWindowTitle("Upload to Project")
                        q_box.setText(
                            "No file was uploaded, do you want to try again?")
                        q_box.setStyleSheet(
                            'background-color: darkSlateGray; color: white; font: Courier'
                        )
                        q_box.exec_()
                        if (q_box.result() != QtWidgets.QMessageBox.Yes):
                            loop = False
                        else:  #loop around again
                            loop = True
                    else:  #This means we uploaded a file successfully
                        msg_box = QtWidgets.QMessageBox(
                            self
                        )  #create a message box asking do you want to upload to the project
                        msg_box.setWindowTitle("Upload Successful")
                        msg_box.setText("File uploaded to " + project_name)
                        msg_box.setStyleSheet(
                            'background-color: darkSlateGray; color: white; font: Courier'
                        )
                        msg_box.exec_()
                        loop = False
        for widget in self.contWidget:
            widget.hide()
        for widget in self.fileWidget:
            widget.hide()
        self.currentWindow = self.projWidget
Ejemplo n.º 21
0
def Compile_Drives(pbp_data, game):
	drives = []
	cur_drive = Drive(0, 0, 0, 0, 0, 0)
	cur_drive.Finished = 1
	new_Quarter = False
	ignore_start = False
	new_Half = False
	prev_off = 0
	prev_start = ""
	for play in pbp_data:

		start = re.match(r"t(?P<offense>\d+) at (?P<min>\d{1,2})\:(?P<sec>\d{2})", play[0])

		stop = re.match(r"t(?P<team>\d+) DRIVE TOTALS\: (?P<plays>\d+) play(?:s)?\, (?:\-)?(?P<yards>\d+) (?:yards|yard|yds|yd)(\, (?P<min>\d{1,2})\:(?P<sec>\d{2}))?", play[0], re.IGNORECASE)
		quarter_start_old = re.search(r"(?P<qrt>\d)(?:st|nd|rd|th) Quarter Play-by-Play", play[0], re.IGNORECASE)
		quarter_start_new = re.search("End of (?P<qrt>\d)(?:st|nd|rd|th) Quarter",play[1],re.IGNORECASE)
		quarter_start1 = game.Set_Quarter(play)
		quarter_start2 = quarter_start_old if quarter_start_old else quarter_start_new
		if quarter_start1 and quarter_start2:
			new_Quarter = True
			if game.Current_Qrt == 1 or game.Current_Qrt == 3:
				new_Half = True
		elif not quarter_start1 and quarter_start2:
			ignore_start = True

		if start:	# Check for the start of a new drive
			#off = int(start.group("offense"))
			#if int(start.group("offense")) == game.Home:
			#	offense = game.Home
			#	defense = game.Visitor
			#elif int(start.group("offense")) == game.Visitor:
			#	offense = game.Visitor
			#	defense = game.Home
			#else:
			#	print int(start.group("offense"))
			#	print game.Home
			#	print game.Visitor
			#start_time = Set_Clock(start.group("min"), start.group("sec"))
			#if new_Quarter:
			#	new_Quarter = False
			#else:
			#	if cur_drive.Finished != 1 and cur_drive.Game_Code != 0:
			#		# print "WARNING: Drive summary never produced"
			if ignore_start:
				ignore_start = False
			elif prev_start == play[0] and cur_drive.Finished == 0 and cur_drive.Game_Code != 0:
				continue
			elif not new_Quarter or (new_Quarter and prev_off != int(start.group("offense"))) or new_Half:
				if int(start.group("offense")) == game.Home:
					offense = game.Home
					defense = game.Visitor
				elif int(start.group("offense")) == game.Visitor:
					offense = game.Visitor
					defense = game.Home
				else:
					print int(start.group("offense"))
					print game.Home
					print game.Visitor
					print "Couldn't find who the offense is"
					raw_input()
				start_time = Set_Clock(start.group("min"), start.group("sec"))

				if cur_drive.Finished == 0 and cur_drive.Game_Code != 0:
					print "WARNING: Drive summary never produced"
					print play[0]
					print game.Current_Qrt
					print new_Quarter
					print new_Half
					print prev_off
					print int(start.group("offense"))
					# raw_input()
					drives.append(cur_drive)

				prev_start = play[0]
				prev_off = offense
				new_Quarter = False
				new_Half = False
				cur_drive = Drive(game.Code, offense, defense, start_time, game.Current_Qrt, len(drives) + 1)
		elif stop:	# Check for the end of a drive
			plays = int(stop.group("plays"))
			yards = int(stop.group("yards"))
			try:
				stop_time = Set_Clock(stop.group("min"), stop.group("sec"))
			except:
				stop_time = cur_drive.Start_Time
			cur_drive.Set_Summary(plays, yards, stop_time, game.Current_Qrt)
			if cur_drive.Game_Code != 0:
				# print "Summary produced"
				drives.append(cur_drive)
		else:		# Add play to drives
			cur_drive.Raw_Pbp_Data.append(play)
	return drives
Ejemplo n.º 22
0
from tkinter import filedialog  # Using this for windows explorer popup

import PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QCursor
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QApplication, QCompleter, QHBoxLayout, QLabel,
                             QLineEdit, QMainWindow, QPushButton, QScrollArea,
                             QSizePolicy, QSpacerItem, QVBoxLayout, QWidget,
                             QMessageBox, QErrorMessage, QInputDialog,
                             QFormLayout)

import Drive as s

creds = None
service = s.GoogleAuth(
    creds)  #authenticate user, make sure permissions are accepted
exists, folder_id = s.searchFile(
    service, 'StudioHub')  #Check if folder exists and get its id
if (exists == 0):  #if we have not created a google drive StudioHub folder
    print("No folder named StudioHub existed, creating new one")
    folder_id = s.createFolder(service, 'StudioHub',
                               None)  #Get folder_id of new folder created
else:  #We have already created StudioHub folder, its id is the one from searchFile function
    print("StudioHub folder already exists")


#Main window that opens when we start the program,
#has all the projects and contacts button, create project etc
class ProjectsWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super().__init__()