コード例 #1
0
 def __init__(self,ipaddy,filepath,active,idle,initialValue="Offline"):
     Observable.__init__(self,initialValue)
     self.ipaddy=ipaddy
     self.port=8900
     self.filepath=filepath
     self.active=active
     self.idle=idle
     self.activeplaying=False
     self.idleplaying=False
     self.parse=False
     self.currentList=Observable()
     self.allLists=Observable()
     self.getCurrentList()
コード例 #2
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()
コード例 #3
0
    def __init__(self):

        # check to see if values are in text file, otherwise load defaults
        try:
            f = open('spyeconfig.txt', 'r')
        # problem opening the file, load the default values
        except:
            logger.warn("Could not open spyeconfig.txt")

            self.filepath = Observable(
                "c:/users/public/documents/spyeworks/content/")
            self.mac = Observable("00:00:00:00:00:00")
            #self.ipaddy = Observable("192.168.1.110")
            self.active = Observable("active")
            self.activedelay = Observable("10")
            self.idle = Observable("idle")
            self.idledelay = Observable("10")
            self.daysLabel = Observable("Daily")
            self.onHour = Observable(7)
            self.onMin = Observable(0)
            self.offHour = Observable(19)
            self.offMin = Observable(0)
            self.UpdateTextFile()

            logger.warn("spyeconfig.txt created with default values.")
        else:
            logger.info("Parsing spyeconfig.txt...")

            self.filepath = Observable(f.readline()[:-1])
            #self.ipaddy = Observable(f.readline()[:-1])
            self.mac = Observable(f.readline()[:-1])
            self.active = Observable(f.readline()[:-1])
            self.activedelay = Observable(f.readline()[:-1])
            self.idle = Observable(f.readline()[:-1])
            self.idledelay = Observable(f.readline()[:-1])
            self.daysLabel = Observable(f.readline()[:-1])
            self.onHour = Observable(int(f.readline()[:-1]))
            self.onMin = Observable(int(f.readline()[:-1]))
            self.offHour = Observable(int(f.readline()[:-1]))
            self.offMin = Observable(int(f.readline()[:-1]))
            logger.info("Parsing complete.")
            # close the file
            f.close()

        # create the title/value dictionary
        self.settingsDict = {
            'Spyeworks MAC': self.mac,
            'Active List': self.active,
            'Active Delay': self.activedelay,
            'Idle List': self.idle,
            'Idle Delay': self.idledelay
        }

        # print the menu
        self.printMenu()