aboutsummaryrefslogtreecommitdiffstats
path: root/minidinstall/tweet.py
diff options
context:
space:
mode:
Diffstat (limited to 'minidinstall/tweet.py')
-rw-r--r--minidinstall/tweet.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/minidinstall/tweet.py b/minidinstall/tweet.py
index 7106085..3a4a4ef 100644
--- a/minidinstall/tweet.py
+++ b/minidinstall/tweet.py
@@ -1,8 +1,8 @@
-# mail -*- mode: python; coding: utf-8 -*-
+# tweet -*- mode: python; coding: utf-8 -*-
-"""Simple tweet support for mini-dinstall."""
+# Simple tweet support for mini-dinstall.
-# Copyright © 2010 Christopher R. Gabriel <cgabriel@truelite.it>
+# Copyright (c) 2010 Christopher R. Gabriel <cgabriel@truelite.it>
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -18,10 +18,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
import logging
import urllib.request
-import base64
def send(tweet_body, tweet_server, tweet_user, tweet_password):
"""Send tweet; on error, log and continue."""
@@ -37,8 +35,8 @@ def send(tweet_body, tweet_server, tweet_user, tweet_password):
if not post_url:
logger.exception("Unknown tweet site")
- if not tweet_user or not tweet_password:
- logger.exception("Missing username or password for twitting")
+ if not (tweet_user and tweet_password):
+ logger.exception("Missing username or password for tweeting")
auth_handler = urllib.request.HTTPBasicAuthHandler()
auth_handler.add_password(realm=auth_realm,
@@ -49,10 +47,9 @@ def send(tweet_body, tweet_server, tweet_user, tweet_password):
req = urllib.request.Request(post_url)
req.add_data("status=%s" % tweet_body)
- handle = None
try:
handle = m_http_opener.open(req)
- a = handle.read()
+ result = handle.read()
logger.info("Tweet sent to %s (%s)" % (tweet_server, tweet_user))
except Exception as e:
- logger.exception("Error sending tweet to %s ('%s') via %s: %s: %s", tweet_server, tweet_body, tweet_user, type(e), e.args)
+ logger.exception("Error sending tweet to %s ('%s') via %s: %s: %s" % (tweet_server, tweet_body, tweet_user, type(e), e.args))