aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom <tom@ritter.vg>2016-09-14 11:59:16 -0500
committerTom <tom@ritter.vg>2016-09-14 11:59:16 -0500
commit4426633a8120926f05ee8818c22d962f76f99a69 (patch)
treea442c837ad2689ef1e53f9bffc23095256704fb0
parent407bcc112e1a0eabe8c35076210519eed9607804 (diff)
Add a new nomail commandline option for debugging
-rwxr-xr-xjobmanager.py1
-rwxr-xr-xjobs/EmailChecker.py4
-rwxr-xr-xjobs/JobBase.py4
-rwxr-xr-xmain.py9
-rwxr-xr-xsettings.cfg.example1
5 files changed, 17 insertions, 2 deletions
diff --git a/jobmanager.py b/jobmanager.py
index 05481f6..d77bfb0 100755
--- a/jobmanager.py
+++ b/jobmanager.py
@@ -30,6 +30,7 @@ class JobManager:
f.close()
def _save_state(self):
+ logging.info("Saving State...")
f = open(self.statefile, "w")
for i in self.state:
f.write(self.state[i].serialize())
diff --git a/jobs/EmailChecker.py b/jobs/EmailChecker.py
index 939d5b8..818600d 100755
--- a/jobs/EmailChecker.py
+++ b/jobs/EmailChecker.py
@@ -15,6 +15,10 @@ class EmailChecker(JobBase.JobBase):
def notifyOnFailureEvery(self):
return JobBase.JobFailureNotificationFrequency.EVERYTIME
def execute(self):
+ if self.config.getboolean('email', 'nomail'):
+ logging.debug("Pretending the EmailChecker job succeeded.")
+ return True
+
USER = self.config.get('email', 'user')
PASS = self.config.get('email', 'pass')
diff --git a/jobs/JobBase.py b/jobs/JobBase.py
index 09a8333..9ea31a4 100755
--- a/jobs/JobBase.py
+++ b/jobs/JobBase.py
@@ -110,6 +110,10 @@ class JobBase(object):
return True
def sendEmail(config, subject, body, to=""):
+ if config.getboolean('email', 'nomail'):
+ logging.info("Not sending email with subject '" + subject + '" but pretending we did.')
+ return True
+
FROM = config.get('email', 'user')
PASS = config.get('email', 'pass')
if not to:
diff --git a/main.py b/main.py
index aee4264..30c285f 100755
--- a/main.py
+++ b/main.py
@@ -24,6 +24,7 @@ if __name__ == "__main__":
parser.add_argument('-m', '--mode', choices=['daemon', 'cron'], required=True, help='The mode the application will run it.')
parser.add_argument('-c', '--crontime', choices=['minute', 'hour', 'day', 'day_noon'], help='When in cron mode, the increment of cron.')
parser.add_argument('-v', action="store_true", help="Print verbose debugging information to stderr")
+ parser.add_argument('--nomail', action="store_true", help="Do everything except sending email")
args = parser.parse_args()
@@ -32,11 +33,15 @@ if __name__ == "__main__":
if args.v:
print "[Pre-Logging] Reading config from", configfile
config.read(configfile)
- if not config.get('email', 'user') or \
+ if args.nomail:
+ config.set('email', 'nomail', "True")
+
+ if not config.getboolean('email', 'nomail') and (\
+ not config.get('email', 'user') or \
not config.get('email', 'pass') or \
not config.get('email', 'smtpserver') or \
not config.get('email', 'smtpport') or \
- not config.get('email', 'imapserver'):
+ not config.get('email', 'imapserver')):
print "Sending email address is not configured"
sys.exit(1)
if not config.get('general', 'servername') or \
diff --git a/settings.cfg.example b/settings.cfg.example
index ffac31e..9cced74 100755
--- a/settings.cfg.example
+++ b/settings.cfg.example
@@ -4,6 +4,7 @@ alertcontact=youremail@example.com
statefile=jobrunhistory.db
[email]
+nomail=False
user=agmailaccountyoucreate@gmail.com
pass=yourpassword
smtpserver=smtp.gmail.com