Example #1
0
 def GetIP(self, mac):
     ip = find_mac_on_network(mac)
     if ip is None:
         logger.error("No IP address found for MAC %s", mac)
         print("No IP address found for MAC %s", mac)
         self.ipTimer = Timer(60, self.GetIP, [mac])
         self.ipTimer.start()
     else:
         self.SetIP(ip)
Example #2
0
 def GetIP(self, mac):
     ip = find_mac_on_network(mac)
     if ip is None:
         logger.error("No IP address found for MAC %s", mac)
         print("No IP address found for MAC %s", mac)
         self.ipTimer = Timer(60, self.GetIP, [mac])
         self.ipTimer.start()
     else:
         self.SetIP(ip)
Example #3
0
    def printMenu(self):
        print(
            """
        Spyeworks Motion Sensor Configuration Main Menu

            1. Change Spyeworks MAC
            2. Change Active List
            3. Change Active Delay
            4. Change Display Turn On/Off Days
            5. Change Display Turn On Time
            6. Change Display Turn Off Time
            7. Get On-Off Times
            8. Quit/Exit
            """
        )

        # get the selection
        self.main_selection = input("Please select: ")
        print("\n")

        if self.main_selection == "1":
            # self.printSecondMenu('Spyeworks MAC', self.mac.get())
            print("Current Spyeworks MAC:", self.mac.get())
            self.newMac = input("Enter new Spyeworks MAC: ")
            if len(self.newMac) == 17:
                # set new mac
                self.mac.set(self.newMac)
                # update the text file
                self.UpdateTextFile()
                # print new active list name
                print("New Spyeworks MAC is", self.mac.get())
                # get ip address for mac
                self.getIP = find_mac_on_network(self.mac.get())
                if len(self.getIP) > 0:  # ip address found
                    # assign ip to model
                    self.ipaddy = Observable(self.getIP)
                    # print results
                    print("Spyeworks Player", self.mac.get(), "found at IP", self.ipaddy.get())
                else:
                    print("Spyeworks Player", self.mac.get(), "not found")

            else:
                print("Invalid entry")

            self.printMenu()

        elif self.main_selection == "2":
            # self.printSecondMenu('Active List', self.active.get())
            print("Current Active List:", self.active.get())
            self.newActive = input("Enter new Active List name: ")
            if len(self.newActive) > 0:
                # set new active list
                self.active.set(self.newActive)
                # update the text file
                self.UpdateTextFile()
                # print new active list name
                print("New Active List name is", self.active.get())
            else:
                print("Invalid entry")

            self.printMenu()

        elif self.main_selection == "3":
            # self.printSecondMenu('Active Delay', self.activedelay.get())
            print("Current Active List Delay:", self.activedelay.get())
            self.newActiveDelay = input("Enter new Active List Delay: ")
            try:
                if len(self.newActiveDelay) > 0 and int(self.newActiveDelay) >= 0:
                    # set new active list delay
                    self.activedelay.set(self.newActiveDelay)
                    # update the text file
                    self.UpdateTextFile()
                    # print new active list name
                    print("New Active List Delay is", self.activedelay.get(), "seconds")
                else:
                    print("Invalid entry")
            except:
                print("Invalid entry")

            self.printMenu()

        elif self.main_selection == "4":
            print("Current Turn On/Off days:", self.daysLabel.get())
            print("1. Daily")
            print("2. WeekDays")
            self.newDays = input("Select which days to use: ")
            # validate entry
            if int(self.newDays) == 1 or int(self.newDays) == 2:
                self.daysLabel.set(dayLabels[int(self.newDays) - 1])
                # update the text file
                self.UpdateTextFile()
                print("New Turn On/Off days:", self.daysLabel.get())
            else:
                print("Invalid entry")
            self.printMenu()

        elif self.main_selection == "5":
            print("Current Turn On time ", str(self.onHour.get()), ":", str(self.onMin.get()).zfill(2), sep="")
            self.newOnHour = input("Enter new turn on hour (in 24 hour clock): ")
            # validate hour entry
            if int(self.newOnHour) < 24 and int(self.newOnHour) >= 0:
                self.newOnMin = input("Enter new turn on minute: ")
                # validate min entry
                if int(self.newOnMin) < 60 and int(self.newOnMin) >= 0:
                    # assign new hour
                    self.onHour.set(int(self.newOnHour))
                    # assign new minute
                    self.onMin.set(int(self.newOnMin))
                    # update the text file
                    self.UpdateTextFile()
                    # print new turn on time
                    print("New Turn On time ", str(self.onHour.get()), ":", str(self.onMin.get()).zfill(2), sep="")
                else:
                    print("Invalid Turn On Min")
            else:
                print("Invalid Turn On Hour")
            self.printMenu()

        elif self.main_selection == "6":
            print("Current Turn Off time ", str(self.offHour.get()), ":", str(self.offMin.get()).zfill(2), sep="")
            self.newOffHour = input("Enter new turn off hour (in 24 hour clock): ")
            # validate hour entry
            if int(self.newOffHour) < 24 and int(self.newOffHour) >= 0:
                self.newOffMin = input("Enter new turn off minute: ")
                # validate min entry
                if int(self.newOffMin) < 60 and int(self.newOffMin) >= 0:
                    # assign new hour
                    self.offHour.set(int(self.newOffHour))
                    # assign new minute
                    self.offMin.set(int(self.newOffMin))
                    # update the text file
                    self.UpdateTextFile()
                    # print new turn off time
                    print("New Turn Off time ", str(self.offHour.get()), ":", str(self.offMin.get()).zfill(2), sep="")
                else:
                    print("Invalid Turn Off Min")
            else:
                print("Invalid Turn Off Hour")
            self.printMenu()

        elif self.main_selection == "7":
            print(
                "Turn On ",
                self.daysLabel.get(),
                " at ",
                str(self.onHour.get()),
                ":",
                str(self.onMin.get()).zfill(2),
                sep="",
            )
            print(
                "Turn Off ",
                self.daysLabel.get(),
                " at ",
                str(self.offHour.get()),
                ":",
                str(self.offMin.get()).zfill(2),
                sep="",
            )
            self.printMenu()

        elif self.main_selection == "8":
            sys.exit()

        else:
            print("Invalid selection.\n")
            self.printMenu()
Example #4
0
    def printMenu(self):
        print("""
        Spyeworks Motion Sensor Configuration Main Menu

            1. Change Spyeworks MAC
            2. Change Active List
            3. Change Active Delay
            4. Change Display Turn On/Off Days
            5. Change Display Turn On Time
            6. Change Display Turn Off Time
            7. Get On-Off Times
            8. Quit/Exit
            """)

        # get the selection
        self.main_selection = input("Please select: ")
        print("\n")

        if self.main_selection == '1':
            #self.printSecondMenu('Spyeworks MAC', self.mac.get())
            print('Current Spyeworks MAC:', self.mac.get())
            self.newMac = input("Enter new Spyeworks MAC: ")
            if len(self.newMac) == 17:
                # set new mac
                self.mac.set(self.newMac)
                # update the text file
                self.UpdateTextFile()
                # print new active list name
                print('New Spyeworks MAC is', self.mac.get())
                # get ip address for mac
                self.getIP = find_mac_on_network(self.mac.get())
                if len(self.getIP) > 0:  # ip address found
                    # assign ip to model
                    self.ipaddy = Observable(self.getIP)
                    # print results
                    print('Spyeworks Player', self.mac.get(), 'found at IP',
                          self.ipaddy.get())
                else:
                    print('Spyeworks Player', self.mac.get(), 'not found')

            else:
                print('Invalid entry')

            self.printMenu()

        elif self.main_selection == '2':
            #self.printSecondMenu('Active List', self.active.get())
            print('Current Active List:', self.active.get())
            self.newActive = input("Enter new Active List name: ")
            if len(self.newActive) > 0:
                # set new active list
                self.active.set(self.newActive)
                # update the text file
                self.UpdateTextFile()
                # print new active list name
                print('New Active List name is', self.active.get())
            else:
                print('Invalid entry')

            self.printMenu()

        elif self.main_selection == '3':
            #self.printSecondMenu('Active Delay', self.activedelay.get())
            print('Current Active List Delay:', self.activedelay.get())
            self.newActiveDelay = input("Enter new Active List Delay: ")
            try:
                if len(self.newActiveDelay) > 0 and int(
                        self.newActiveDelay) >= 0:
                    # set new active list delay
                    self.activedelay.set(self.newActiveDelay)
                    # update the text file
                    self.UpdateTextFile()
                    # print new active list name
                    print('New Active List Delay is', self.activedelay.get(),
                          'seconds')
                else:
                    print('Invalid entry')
            except:
                print('Invalid entry')

            self.printMenu()

        elif self.main_selection == '4':
            print('Current Turn On/Off days:', self.daysLabel.get())
            print('1. Daily')
            print('2. WeekDays')
            self.newDays = input("Select which days to use: ")
            # validate entry
            if int(self.newDays) == 1 or int(self.newDays) == 2:
                self.daysLabel.set(dayLabels[int(self.newDays) - 1])
                # update the text file
                self.UpdateTextFile()
                print('New Turn On/Off days:', self.daysLabel.get())
            else:
                print('Invalid entry')
            self.printMenu()

        elif self.main_selection == '5':
            print('Current Turn On time ',
                  str(self.onHour.get()),
                  ':',
                  str(self.onMin.get()).zfill(2),
                  sep='')
            self.newOnHour = input(
                "Enter new turn on hour (in 24 hour clock): ")
            # validate hour entry
            if int(self.newOnHour) < 24 and int(self.newOnHour) >= 0:
                self.newOnMin = input("Enter new turn on minute: ")
                # validate min entry
                if int(self.newOnMin) < 60 and int(self.newOnMin) >= 0:
                    # assign new hour
                    self.onHour.set(int(self.newOnHour))
                    # assign new minute
                    self.onMin.set(int(self.newOnMin))
                    # update the text file
                    self.UpdateTextFile()
                    # print new turn on time
                    print('New Turn On time ',
                          str(self.onHour.get()),
                          ':',
                          str(self.onMin.get()).zfill(2),
                          sep='')
                else:
                    print('Invalid Turn On Min')
            else:
                print('Invalid Turn On Hour')
            self.printMenu()

        elif self.main_selection == '6':
            print('Current Turn Off time ',
                  str(self.offHour.get()),
                  ':',
                  str(self.offMin.get()).zfill(2),
                  sep='')
            self.newOffHour = input(
                "Enter new turn off hour (in 24 hour clock): ")
            # validate hour entry
            if int(self.newOffHour) < 24 and int(self.newOffHour) >= 0:
                self.newOffMin = input("Enter new turn off minute: ")
                # validate min entry
                if int(self.newOffMin) < 60 and int(self.newOffMin) >= 0:
                    # assign new hour
                    self.offHour.set(int(self.newOffHour))
                    # assign new minute
                    self.offMin.set(int(self.newOffMin))
                    # update the text file
                    self.UpdateTextFile()
                    # print new turn off time
                    print('New Turn Off time ',
                          str(self.offHour.get()),
                          ':',
                          str(self.offMin.get()).zfill(2),
                          sep='')
                else:
                    print('Invalid Turn Off Min')
            else:
                print('Invalid Turn Off Hour')
            self.printMenu()

        elif self.main_selection == '7':
            print('Turn On ',
                  self.daysLabel.get(),
                  ' at ',
                  str(self.onHour.get()),
                  ':',
                  str(self.onMin.get()).zfill(2),
                  sep='')
            print('Turn Off ',
                  self.daysLabel.get(),
                  ' at ',
                  str(self.offHour.get()),
                  ':',
                  str(self.offMin.get()).zfill(2),
                  sep='')
            self.printMenu()

        elif self.main_selection == '8':
            sys.exit()

        else:
            print("Invalid selection.\n")
            self.printMenu()