Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GNU nano 2.2.6 File: Gmailnot.py
- #!/usr/bin/env python
- from imapclient import IMAPClient
- from piglow import PiGlow
- from time import sleep
- import time
- piglow = PiGlow()
- DEBUG = True
- HOSTNAME = 'imap.gmail.com'
- USERNAME = '***********@gmail.com'
- PASSWORD = '********'
- MAILBOX = 'Inbox'
- NEWMAIL_OFFSET = 0 # Unread offset
- MAIL_CHECK_FREQ = 30 # Frequency
- def loop():
- server = IMAPClient(HOSTNAME, use_uid=True, ssl=True)
- server.login(USERNAME, PASSWORD)
- if DEBUG:
- print('Logging in as ' + USERNAME)
- select_info = server.select_folder(MAILBOX)
- print('%d messages in INBOX' % select_info['EXISTS'])
- folder_status = server.folder_status(MAILBOX, 'UNSEEN')
- newmails = int(folder_status['UNSEEN'])
- if DEBUG:
- print "You have", newmails, "new emails!"
- if newmails > NEWMAIL_OFFSET:
- piglow.all(1)
- sleep(1)
- piglow.all(50)
- sleep(1)
- piglow.all(1)
- sleep(1)
- piglow.all(50)
- sleep(1)
- piglow.all(1)
- else:
- piglow.all(0)
- time.sleep(MAIL_CHECK_FREQ)
- if __name__ == '__main__':
- try:
- print 'Press Ctrl-C to quit.'
- while True:
- loop()
- finally:
- print("loop")
- #Alfie T Tuesday 6th October
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement