code quality changes to the remaining scripts

bss/dr.botzo#17
This commit is contained in:
Brian S. Stephan 2017-02-11 17:09:24 -06:00
parent 23007ec8f9
commit c04445dfff
2 changed files with 6 additions and 9 deletions

View File

@ -47,6 +47,7 @@ last_np = ''
def notify_song(): def notify_song():
"""React to mpd event, send a now playing dispatch message if relevant."""
global last_np global last_np
status = client.status() status = client.status()
logger.debug(status) logger.debug(status)

View File

@ -1,7 +1,4 @@
""" """Use dr.botzo's Dispatch to send mail notifications"""
procmail-to-dispatch.py --- use dr.botzo's Dispatch to send mail notifications
"""
import argparse import argparse
import getpass import getpass
@ -27,8 +24,7 @@ parser.add_argument('-l', '--location')
parser.add_argument('-u', '--user') parser.add_argument('-u', '--user')
args = parser.parse_args() args = parser.parse_args()
if (args.filename == None or args.user == None or if args.filename is None or args.user is None or args.location is None:
args.location == None):
print("script needs -f/--filename (location of .procmailrc.log) " print("script needs -f/--filename (location of .procmailrc.log) "
"-l/--location (url to connect to) -u/--user (user to authenticate to XML-RPC as)") "-l/--location (url to connect to) -u/--user (user to authenticate to XML-RPC as)")
sys.exit(2) sys.exit(2)
@ -48,7 +44,9 @@ st_results = os.stat(args.filename)
st_size = st_results[6] st_size = st_results[6]
file.seek(st_size) file.seek(st_size)
def get_mail_items(filename): def get_mail_items(filename):
"""Get info to notify about from an email in the maildir."""
sender = None sender = None
subject = None subject = None
@ -66,7 +64,7 @@ def get_mail_items(filename):
if sender: if sender:
return (sender, "[no subject]") return (sender, "[no subject]")
while 1: while True:
try: try:
filename = None filename = None
@ -117,5 +115,3 @@ while 1:
except UnicodeDecodeError as e: except UnicodeDecodeError as e:
logger.error("Error: " + str(e) + ", skipping") logger.error("Error: " + str(e) + ", skipping")
pass pass
# vi:tabstop=4:expandtab:autoindent