def main(): global verbose verbose = False global debug debug = False helpMessage = 'Usage: sudo ./pumpkinPi [hh:mm] {-d -v}\n\nPARAMETERS:\n hh:mm - Duration in hours:minutes (not required with -d)\n\nOPTIONS:\n -d Debug mode\n -v Verbose' if len(sys.argv) == 1: print helpMessage sys.exit(0) if '-v' in sys.argv: verbose = True if '-d' in sys.argv: debug_function() if len(sys.argv[1]) != 5: print helpMessage sys.exit(1) else: hour = int(sys.argv[1][:2]) minute = int(sys.argv[1][-2:]) # Convert the duration to seconds and add stopTime = time.time() + (hour * 3600 + minute * 60) # the current time to find the stop time. print 'Jack-O\'-Lantern will go out at', time.strftime('%H:%M, %B %d, %Y', time.localtime(stopTime)) print '\033[1;31mUse Ctrl+C to exit early.\033[0m' for line in pumpkin: # Print a pumpkin to the console. print line bigletters.write(r'pumpkin *', 'purple', 'bold') # stopTime = time.time() + 5 #debug pumpkin_pi(stopTime)
def pumpkin_pi_quit(): print 'Exit PumpkinPi\n\n' bigletters.write(' happy', 'yellow', 'normal') # Print an adorable exit message bigletters.write('halloween!', 'yellow', 'normal') for i in range(4): pumpkin_pi_on() time.sleep(1) pumpkin_pi_off() time.sleep(.5) GPIO.cleanup() if not debug: sys.exit(0)
def main(): global verbose verbose = False global debug debug = False helpMessage = 'Usage: sudo ./pumpkinPi [hh:mm] {-d -v}\n\nPARAMETERS:\n hh:mm - Duration in hours:minutes (not required with -d)\n\nOPTIONS:\n -d Debug mode\n -v Verbose' if len(sys.argv) == 1: print helpMessage sys.exit(0) if '-v' in sys.argv: verbose = True if '-d' in sys.argv: debug_function() if len(sys.argv[1]) != 5: print helpMessage sys.exit(1) else: hour = int(sys.argv[1][:2]) minute = int( sys.argv[1][-2:]) # Convert the duration to seconds and add stopTime = time.time() + (hour * 3600 + minute * 60 ) # the current time to find the stop time. print 'Jack-O\'-Lantern will go out at', time.strftime( '%H:%M, %B %d, %Y', time.localtime(stopTime)) print '\033[1;31mUse Ctrl+C to exit early.\033[0m' for line in pumpkin: # Print a pumpkin to the console. print line bigletters.write(r'pumpkin *', 'purple', 'bold') # stopTime = time.time() + 5 #debug pumpkin_pi(stopTime)