diff --git a/libemail.py b/libemail.py index 8e4c599..a886880 100644 --- a/libemail.py +++ b/libemail.py @@ -12,6 +12,10 @@ from email.mime.text import MIMEText def sendemail(settingsfilename, subject, body): + """ + Send an email using the settings defined in settingsfilename + """ + settings = EmailSettings(settingsfilename) msg = MIMEText(body, "plain") @@ -19,10 +23,10 @@ def sendemail(settingsfilename, subject, body): msg["From"] = settings.getfromaddress() msg["To"] = settings.gettoaddress() - s = smtplib.SMTP(settings.getsmtpserver()) - s.ehlo() - s.starttls() - s.login(settings.getsmtpuser(), settings.getsmtppassword()) - s.sendmail(settings.getfromaddress(), [settings.gettoaddress()], - msg.as_string()) - s.quit() + smtp = smtplib.SMTP(settings.getsmtpserver()) + smtp.ehlo() + smtp.starttls() + smtp.login(settings.getsmtpuser(), settings.getsmtppassword()) + smtp.sendmail(settings.getfromaddress(), [settings.gettoaddress()], + msg.as_string()) + smtp.quit() diff --git a/libfilemanager.py b/libfilemanager.py index 1171d5e..0b03fb9 100644 --- a/libfilemanager.py +++ b/libfilemanager.py @@ -112,7 +112,8 @@ class FileManager: #will reach here if there were less than numberofFiles found return showstoprocess - def checkduplicates(self, filename): + @staticmethod + def checkduplicates(filename): """ Check to see if there are any other video files existing for the episode @@ -121,7 +122,7 @@ class FileManager: dirname = os.path.dirname(filename) filename = os.path.basename(filename)[:6] - for dirpath, dirnames, filenames in os.walk(dirname): + for filenames in os.walk(dirname)[2]: for show in filenames: extension = os.path.splitext(show)[1] if (extension in [".avi", ".mpg", ".mpeg", "mp4"] and diff --git a/libsettings.py b/libsettings.py index f5ef69a..7e69edf 100644 --- a/libsettings.py +++ b/libsettings.py @@ -227,8 +227,6 @@ class Settings: else: return show["SickbeardPrefix"] - # TODO check if this is actually doing anything. it seems like it - # just returns what is input def getshow(self, showname): """ Get the name of the show, showname. diff --git a/pep8.sh b/pep8.sh index 73bdc68..ce2b244 100755 --- a/pep8.sh +++ b/pep8.sh @@ -1,3 +1,3 @@ #!/bin/bash -pep8 TVEncoder.py libfilemanager.py libhandbrake.py libmythtv.py libsettings.py libsickbeard.py libtvdatasource.py libtvshow.py \ No newline at end of file +pep8 libemail.py TVEncoder.py libfilemanager.py libhandbrake.py libmythtv.py libsettings.py libsickbeard.py libtvdatasource.py libtvshow.py diff --git a/pylint.sh b/pylint.sh index 60da4bf..5204ecc 100755 --- a/pylint.sh +++ b/pylint.sh @@ -1,3 +1,3 @@ #!/bin/bash -pylint TVEncoder.py libfilemanager.py libhandbrake.py libmythtv.py libsettings.py libsickbeard.py libtvdatasource.py libtvshow.py \ No newline at end of file +pylint TVEncoder.py libfilemanager.py libhandbrake.py libmythtv.py libsettings.py libsickbeard.py libtvdatasource.py libtvshow.py libemail.py