mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-24 08:58:49 -05:00
commit
28e062bd44
@ -222,7 +222,7 @@ def check_email_thread():
|
|||||||
return
|
return
|
||||||
|
|
||||||
if 'gmail' in CONFIG['imap']['host'].lower():
|
if 'gmail' in CONFIG['imap']['host'].lower():
|
||||||
server.select_folder('INBOX', readonly=True)
|
server.select_folder('INBOX')
|
||||||
|
|
||||||
messages = server.search(['SINCE', today])
|
messages = server.search(['SINCE', today])
|
||||||
LOG.debug("%d messages received today" % len(messages))
|
LOG.debug("%d messages received today" % len(messages))
|
||||||
@ -365,12 +365,14 @@ def send_email(to_addr, content):
|
|||||||
|
|
||||||
msg = MIMEText(content)
|
msg = MIMEText(content)
|
||||||
msg['Subject'] = subject
|
msg['Subject'] = subject
|
||||||
msg['From'] = "KM6XXX@yourdomain.org"
|
msg['From'] = CONFIG['smtp']['login']
|
||||||
msg['To'] = to_addr
|
msg['To'] = to_addr
|
||||||
s = smtplib.SMTP_SSL('smtp.yourdomain.com', 465)
|
s = smtplib.SMTP_SSL(CONFIG['smtp']['host'],
|
||||||
s.login("KM6XXX@yourdomain.org", "yourpassword")
|
CONFIG['smtp']['port'])
|
||||||
|
s.login(CONFIG['smtp']['login'],
|
||||||
|
CONFIG['smtp']['password'])
|
||||||
try:
|
try:
|
||||||
s.sendmail("KM6XXX@yourdomain.org", [to_addr], msg.as_string())
|
s.sendmail(CONFIG['smtp']['login'], [to_addr], msg.as_string())
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception("Sendmail Error!!!!!!!!!")
|
LOG.exception("Sendmail Error!!!!!!!!!")
|
||||||
s.quit()
|
s.quit()
|
||||||
@ -399,7 +401,7 @@ def setup_logging(args):
|
|||||||
date_format = '%m/%d/%Y %I:%M:%S %p'
|
date_format = '%m/%d/%Y %I:%M:%S %p'
|
||||||
log_formatter = logging.Formatter(fmt=log_format,
|
log_formatter = logging.Formatter(fmt=log_format,
|
||||||
datefmt=date_format)
|
datefmt=date_format)
|
||||||
fh = RotatingFileHandler('aprsd.log',
|
fh = RotatingFileHandler(CONFIG['aprs']['logfile'],
|
||||||
maxBytes=(10248576*5),
|
maxBytes=(10248576*5),
|
||||||
backupCount=4)
|
backupCount=4)
|
||||||
fh.setFormatter(log_formatter)
|
fh.setFormatter(log_formatter)
|
||||||
@ -414,12 +416,12 @@ def setup_logging(args):
|
|||||||
### main() ###
|
### main() ###
|
||||||
def main(args=args):
|
def main(args=args):
|
||||||
global CONFIG
|
global CONFIG
|
||||||
setup_logging(args)
|
|
||||||
|
|
||||||
LOG.info("APRSD Started")
|
|
||||||
CONFIG = utils.parse_config(args)
|
CONFIG = utils.parse_config(args)
|
||||||
LOG.debug("Signal handler setup")
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
LOG.info("APRSD Started")
|
||||||
|
LOG.debug(CONFIG)
|
||||||
|
setup_logging(args)
|
||||||
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
setup_connection()
|
setup_connection()
|
||||||
|
@ -15,6 +15,7 @@ aprs:
|
|||||||
password: password
|
password: password
|
||||||
host: noam.aprs2.net
|
host: noam.aprs2.net
|
||||||
port: 14580
|
port: 14580
|
||||||
|
logfile: /tmp/aprsd.log
|
||||||
|
|
||||||
shortcuts:
|
shortcuts:
|
||||||
'aa': '5551239999@vtext.com'
|
'aa': '5551239999@vtext.com'
|
||||||
@ -24,10 +25,13 @@ shortcuts:
|
|||||||
smtp:
|
smtp:
|
||||||
login: something
|
login: something
|
||||||
password: some lame password
|
password: some lame password
|
||||||
|
host: imap.gmail.com
|
||||||
|
port: 465
|
||||||
|
|
||||||
imap:
|
imap:
|
||||||
login: imapuser
|
login: imapuser
|
||||||
password: something dumb
|
password: something dumb
|
||||||
|
host: imap.gmail.com
|
||||||
'''
|
'''
|
||||||
|
|
||||||
log = logging.getLogger('APRSD')
|
log = logging.getLogger('APRSD')
|
||||||
@ -67,13 +71,17 @@ def parse_config(args):
|
|||||||
LOG.critical(msg)
|
LOG.critical(msg)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
def check_option(config, section, name=None):
|
def check_option(config, section, name=None, default=None):
|
||||||
if section in config:
|
if section in config:
|
||||||
if name and name not in config[section]:
|
if name and name not in config[section]:
|
||||||
fail("'%s' was not in '%s' section of config file" %
|
if not default:
|
||||||
(name, section))
|
fail("'%s' was not in '%s' section of config file" %
|
||||||
|
(name, section))
|
||||||
|
else:
|
||||||
|
config[section][name] = default
|
||||||
else:
|
else:
|
||||||
fail("'%s' section wasn't in config file" % section)
|
fail("'%s' section wasn't in config file" % section)
|
||||||
|
return config
|
||||||
|
|
||||||
# Now read the ~/.aprds/config.yml
|
# Now read the ~/.aprds/config.yml
|
||||||
config = get_config()
|
config = get_config()
|
||||||
@ -83,9 +91,14 @@ def parse_config(args):
|
|||||||
check_option(config, 'aprs', 'password')
|
check_option(config, 'aprs', 'password')
|
||||||
check_option(config, 'aprs', 'host')
|
check_option(config, 'aprs', 'host')
|
||||||
check_option(config, 'aprs', 'port')
|
check_option(config, 'aprs', 'port')
|
||||||
|
config = check_option(config, 'aprs', 'logfile', './aprsd.log')
|
||||||
check_option(config, 'imap', 'host')
|
check_option(config, 'imap', 'host')
|
||||||
check_option(config, 'imap', 'login')
|
check_option(config, 'imap', 'login')
|
||||||
check_option(config, 'imap', 'password')
|
check_option(config, 'imap', 'password')
|
||||||
|
check_option(config, 'smtp', 'host')
|
||||||
|
check_option(config, 'smtp', 'port')
|
||||||
|
check_option(config, 'smtp', 'login')
|
||||||
|
check_option(config, 'smtp', 'password')
|
||||||
|
|
||||||
return config
|
return config
|
||||||
LOG.info("aprsd config loaded")
|
LOG.info("aprsd config loaded")
|
||||||
|
Loading…
Reference in New Issue
Block a user