Skip to content
This repository was archived by the owner on Dec 30, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions siricontrol.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
import imaplib
import imaplib2
import email
import os
import pkgutil
Expand Down Expand Up @@ -28,7 +28,7 @@ def __init__(self, username, password):

try:
self.last_checked = -1
self.mail = imaplib.IMAP4_SSL("imap.gmail.com", 993)
self.mail = imaplib2.IMAP4_SSL("imap.gmail.com", 993)
self.mail.login(username, password)
self.mail.list()
self.mail.select("Notes")
Expand All @@ -42,7 +42,7 @@ def __init__(self, username, password):

self.load()
self.handle()
except imaplib.IMAP4.error:
except imaplib2.IMAP4.error:
print("Your username and password is incorrect")
print("Or IMAP is not enabled.")

Expand Down Expand Up @@ -92,13 +92,14 @@ def fetch_command(self):
def handle(self):
"""Handle new commands

Poll continuously every second and check for new commands.
Idle until there is a server side update to email
"""
print("Fetching commands...")
print("\n")

while True:
try:
self.mail.idle()
command = self.fetch_command()
if not command:
raise ControlException("No command found.")
Expand Down Expand Up @@ -126,7 +127,6 @@ def handle(self):
print("Received an exception while running: {exc}".format(
**locals()))
print("Restarting...")
time.sleep(1)


if __name__ == '__main__':
Expand Down