Esempio n. 1
0
def launch(user, password, targetip, portnumber):

    logger = logging.getLogger('wc.controller')
    logger.info('Starting cmdline python file')

    while True:
        print("If you want to exit type 0")
        print("If you want rain type 1")
        print("If you want sun type 2")
        print("If you want day type 3")
        print("If you want night type 4")
        choice = input("Enter your choice: ")

        if choice == '0':
            print("Your choice is " + choice)
            break

        nreg = re.compile(r"^\d{1}$")
        nmatch = nreg.match(choice)

        if not nmatch:
            logger.debug(
                'Test module - invalid entry (has to be a single digit) ')
            print("This is not a valid choice")
            continue

        if choice == '1':
            logger.debug('Test module - choice 1')
            print("Your choice is " + choice)
            rain(user, password, targetip, portnumber)
            continue

        if choice == '2':
            logger.debug('Test module - choice 2')
            print("Your choice is " + choice)
            sun(user, password, targetip, portnumber)
            continue

        if choice == '3':
            logger.debug('Test module - choice 3')
            print("Your choice is " + choice)
            day(user, password, targetip, portnumber)
            continue

        if choice == '4':
            logger.debug('Test module - choice 4')
            print("Your choice is " + choice)
            night(user, password, targetip, portnumber)
            continue

        else:
            continue

        break
Esempio n. 2
0
def launch(user, password, targetip, portnumber):

    logger = logging.getLogger('wc.controller')
    logger.info('Starting cmdline python file')

    while True:
        print("If you want to exit type 0")
        print("If you want rain type 1")
        print("If you want sun type 2")
        print("If you want day type 3")
        print("If you want night type 4")
        choice = input("Enter your choice: ")

        if choice == '0':
            print("Your choice is " + choice)
            break
        
        nreg = re.compile(r"^\d{1}$")
        nmatch = nreg.match(choice)

        if not nmatch:
            logger.debug('Test module - invalid entry (has to be a single digit) ')
            print("This is not a valid choice")
            continue

        if choice == '1':
            logger.debug('Test module - choice 1')
            print("Your choice is " + choice)
            rain(user, password, targetip, portnumber)
            continue

        if choice == '2':
            logger.debug('Test module - choice 2')
            print("Your choice is " + choice)
            sun(user, password, targetip, portnumber)
            continue

        if choice == '3':
            logger.debug('Test module - choice 3')
            print("Your choice is " + choice)
            day(user, password, targetip, portnumber)
            continue

        if choice == '4':
            logger.debug('Test module - choice 4')
            print("Your choice is " + choice)
            night(user, password, targetip, portnumber)
            continue

        else:
            continue

        break;
Esempio n. 3
0
def foreverlight(user, password, targetip, portnumber):
    # Main program loop

    lightswitch = None
    daylight = None
    nighttime = None

    while True:
        time.sleep(5.0)
        light = RCtime(4)
        print(light)
        if (light > 1000):
            if not nighttime:
                night(user, password, targetip, portnumber)
            daylight = False
            nighttime = True
        elif (light <= 1000):
            if not daylight:
                day(user, password, targetip, portnumber)
            daylight = True
            nighttime = False
Esempio n. 4
0
def foreverlight(user, password, targetip, portnumber):
  # Main program loop

  lightswitch = None  
  daylight = None
  nighttime = None

  while True:
    time.sleep(5.0)
    light = RCtime(4)
    print (light)
    if(light>1000):
      if not nighttime:
        night(user, password, targetip, portnumber)
      daylight = False
      nighttime = True
    elif(light<=1000):
      if not daylight:
        day(user, password, targetip, portnumber)
      daylight =  True
      nighttime = False