Hello community,
here is the log from the commit of package urlwatch for openSUSE:Factory checked in at 2015-12-03 13:32:43
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/urlwatch (Old)
and /work/SRC/openSUSE:Factory/.urlwatch.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "urlwatch"
Changes:
--------
--- /work/SRC/openSUSE:Factory/urlwatch/urlwatch.changes 2014-08-15 09:56:15.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.urlwatch.new/urlwatch.changes 2015-12-03 13:32:44.000000000 +0100
@@ -1,0 +2,12 @@
+Tue Dec 1 23:39:15 UTC 2015 - p.drouand@gmail.com
+
+- Update to version 1.18
+ * Fallback to using pwd if os.getlogin() fails (fixes #2)
+ * Handle HTTP compression (Content-encoding: gzip/deflate)
+ * Add option to suppress output on stdout (-q/--quiet)
+ * Allow customizing subject when sending e-mail (-S/--subject)
+ * Added support for TLS and SMTP auth (-p/--pass, -T/--tls, -A/--auth)
+ * Added support for specifying cache directory (-c/--cache)
+ * Add support for HTTP Auth to urlwatch.handler (fixes #10)
+
+-------------------------------------------------------------------
Old:
----
urlwatch-1.17.tar.gz
New:
----
urlwatch-1.18.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ urlwatch.spec ++++++
--- /var/tmp/diff_new_pack.XUaz1b/_old 2015-12-03 13:32:44.000000000 +0100
+++ /var/tmp/diff_new_pack.XUaz1b/_new 2015-12-03 13:32:44.000000000 +0100
@@ -1,7 +1,7 @@
#
-# spec file for package
+# spec file for package urlwatch
#
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
Name: urlwatch
-Version: 1.17
+Version: 1.18
Release: 0
Summary: A tool for monitoring webpages for updates
License: BSD-3-Clause
@@ -29,7 +29,6 @@
BuildRequires: python-futures
BuildArch: noarch
Requires: python-futures
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
urlwatch is intended to help you watch URLs and get notified (via email
@@ -51,7 +50,7 @@
%files
%defattr(-,root,root)
-%doc ChangeLog COPYING README
+%doc ChangeLog COPYING
%{_bindir}/%{name}
%{python_sitelib}/%{name}*
%{python_sitelib}/%{name}/
++++++ urlwatch-1.17.tar.gz -> urlwatch-1.18.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/COPYING new/urlwatch-1.18/COPYING
--- old/urlwatch-1.17/COPYING 2014-08-01 21:43:00.000000000 +0200
+++ new/urlwatch-1.18/COPYING 2015-02-27 19:25:57.000000000 +0100
@@ -1,4 +1,4 @@
-Copyright (c) 2008-2014 Thomas Perl
+Copyright (c) 2008-2015 Thomas Perl
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/ChangeLog new/urlwatch-1.18/ChangeLog
--- old/urlwatch-1.17/ChangeLog 2014-08-01 21:48:15.000000000 +0200
+++ new/urlwatch-1.18/ChangeLog 2015-02-27 19:37:41.000000000 +0100
@@ -141,3 +141,12 @@
* Fix lynx handing for relative URLs (fixes Debian bug 732112)
* Fix resolving of relative URL filenames (fixes Debian bug 748905)
* urlwatch 1.17 released
+
+2015-02-27 Thomas Perl
+ * Fallback to using pwd if os.getlogin() fails (fixes #2)
+ * Handle HTTP compression (Content-encoding: gzip/deflate)
+ * Add option to suppress output on stdout (-q/--quiet)
+ * Allow customizing subject when sending e-mail (-S/--subject)
+ * Added support for TLS and SMTP auth (-p/--pass, -T/--tls, -A/--auth)
+ * Added support for specifying cache directory (-c/--cache)
+ * Add support for HTTP Auth to urlwatch.handler (fixes #10)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/PKG-INFO new/urlwatch-1.18/PKG-INFO
--- old/urlwatch-1.17/PKG-INFO 2014-08-01 21:49:32.000000000 +0200
+++ new/urlwatch-1.18/PKG-INFO 2015-02-27 19:39:08.000000000 +0100
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: urlwatch
-Version: 1.17
+Version: 1.18
Summary: Watch web pages and arbitrary URLs for changes
Home-page: http://thp.io/2008/urlwatch/
Author: Thomas Perl
Author-email: m@thp.io
License: BSD
-Download-URL: http://thp.io/2008/urlwatch/urlwatch-1.17.tar.gz
+Download-URL: http://thp.io/2008/urlwatch/urlwatch-1.18.tar.gz
Description: This script is intended to help you watch URLs and get notified (via email or
in your terminal) of any changes. The change notification will include the URL
that has changed and a unified diff of what has changed.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/README new/urlwatch-1.18/README
--- old/urlwatch-1.17/README 2013-03-11 10:50:22.000000000 +0100
+++ new/urlwatch-1.18/README 1970-01-01 01:00:00.000000000 +0100
@@ -1,74 +0,0 @@
-URLWATCH README
-===============
-
-ABOUT
------
-
-This is a simple URL watcher, designed to send you diffs of webpages as they
-change. Ideal for watching web pages of university courses, so you always
-know when lecture dates have changed or new tasks are online :)
-
-
-DEPENDENCIES
-------------
-
-This package requires the "concurrent.futures" module as included in Python
-3.2. For Python versions < 3.2, you can install it using:
-
- pip install futures
-
-or download and install it manually from its project page at
-
- http://code.google.com/p/pythonfutures/
-
-
-QUICK START
------------
-
-1. Start "urlwatch"
-2. Edit and rename the examples in ~/.urlwatch/
-3. Add "urlwatch" to your crontab (crontab -e)
-4. Receive change notifications via e-mail
-5. Customize your hooks in ~/.urlwatch/lib/
-
-
-FREQUENTLY ASKED QUESTIONS
---------------------------
-
-Q: How do I add/remove URLs?
-A: Edit ~/.urlwatch/urls.txt
-
-Q: A page changes some content on every reload. How do I prevent urlwatch
- from always displaying these changes?
-A: Edit ~/.urlwatch/lib/hooks.py and implement your filters there. Examples
- are included in the urlwatch source distribution.
-
-Q: How do I configure urlwatch as a cron job?
-A: Use "crontab -e" to add the command "urlwatch" to your crontab. Make sure
- stdout of your cronjobs is mailed to you, so you also get the notifications.
-
-Q: Is there an easy way to show changes of .ics files?
-A: Indeed there is. See the example hooks.py file.
-
-Q: What about badly-formed HTML (long lines, etc..)?
-A: Use python-utidylib. See the example hooks.py file.
-
-Q: Is there a way to make the output more human-readable?
-Q: Is there a way to turn it into a diff of parsed HTML perhaps?
-A: Of course. See the example hooks.py file -> use html2txt.html2text(data)
-
-Q: Why do I get an error with URLs with spaces in them?
-A: Please make sure to URL-encode the URLs properly. Use %20 for spaces.
-
-Q: The website I want to watch requires a POST request. How do I send one?
-A: Add the POST data in the same line, separated by a single space. The format
- in urls.txt is: http://example.org/script.cgi value=5&q=search&button=Go
-
-
-CONTACT
--------
-
-Website: http://thp.io/2008/urlwatch/
-E-Mail: m@thp.io
-Jabber/XMPP: thp@jabber.org
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/lib/urlwatch/handler.py new/urlwatch-1.18/lib/urlwatch/handler.py
--- old/urlwatch-1.17/lib/urlwatch/handler.py 2014-08-01 21:43:55.000000000 +0200
+++ new/urlwatch-1.18/lib/urlwatch/handler.py 2015-02-27 19:30:26.000000000 +0100
@@ -1,14 +1,13 @@
-#!/usr/bin/python
# -*- coding: utf-8 -*-
#
-# urlwatch is a minimalistic URL watcher written in Python
-#
-# Copyright (c) 2008-2014 Thomas Perl
+# This file is part of urlwatch (https://thp.io/2008/urlwatch/).
+# Copyright (c) 2008-2015 Thomas Perl
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
+#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
@@ -27,7 +26,6 @@
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
try:
# Available in Python 2.5 and above and preferred if available
@@ -42,10 +40,22 @@
import subprocess
import email.utils
import urllib2
+import urlparse
import os
import stat
import sys
import re
+import zlib
+
+def get_current_user():
+ try:
+ return os.getlogin()
+ except OSError:
+ # If there is no controlling terminal, because urlwatch is launched by
+ # cron, or by a systemd.service for example, os.getlogin() fails with:
+ # OSError: [Errno 25] Inappropriate ioctl for device
+ import pwd
+ return pwd.getpwuid(os.getuid()).pw_name
class JobBase(object):
def __init__(self, location):
@@ -123,12 +133,27 @@
else:
post_data = None
+ parts = urlparse.urlparse(self.location)
+ if parts.username or parts.password:
+ self.location = urlparse.urlunparse((parts.scheme, parts.hostname, parts.path,
+ parts.params, parts.query, parts.fragment))
+ log.info('Using HTTP basic authentication for %s', self.location)
+ headers['Authorization'] = 'Basic %s' % (':'.join((parts.username,
+ parts.password)).encode('base64').strip())
+
request = urllib2.Request(self.location, post_data, headers)
response = urllib2.urlopen(request)
headers = response.info()
content = response.read()
encoding = 'utf-8'
+ # Handle HTTP compression
+ compression_type = headers.get('Content-Encoding')
+ if compression_type == 'gzip':
+ content = zlib.decompress(content, zlib.MAX_WBITS|32)
+ elif compression_type == 'deflate':
+ content = zlib.decompress(content, -zlib.MAX_WBITS)
+
# Determine content type via HTTP headers
content_type = headers.get('Content-type', '')
content_type_match = self.CHARSET_RE.match(content_type)
@@ -162,7 +187,7 @@
shelljob_errors.append('%s is group/world-writable' % dirname)
allow_shelljobs = False
if dir_st.st_uid != current_uid:
- shelljob_errors.append('%s not owned by %s' % (dirname, os.getlogin()))
+ shelljob_errors.append('%s not owned by %s' % (dirname, get_current_user()))
allow_shelljobs = False
file_st = os.stat(urls_txt)
@@ -170,7 +195,7 @@
shelljob_errors.append('%s is group/world-writable' % urls_txt)
allow_shelljobs = False
if file_st.st_uid != current_uid:
- shelljob_errors.append('%s not owned by %s' % (urls_txt, os.getlogin()))
+ shelljob_errors.append('%s not owned by %s' % (urls_txt, get_current_user()))
allow_shelljobs = False
for line in open(urls_txt).read().splitlines():
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/lib/urlwatch/html2txt.py new/urlwatch-1.18/lib/urlwatch/html2txt.py
--- old/urlwatch-1.17/lib/urlwatch/html2txt.py 2014-08-01 21:43:00.000000000 +0200
+++ new/urlwatch-1.18/lib/urlwatch/html2txt.py 2015-02-27 19:30:42.000000000 +0100
@@ -1,14 +1,13 @@
-#!/usr/bin/python
-# Convert HTML data to plaintext using Lynx, html2text or a regex
-# Requirements: Either lynx (default) or html2text or simply Python (for regex)
-# This file is part of urlwatch
+# -*- coding: utf-8 -*-
#
-# Copyright (c) 2009-2014 Thomas Perl
+# This file is part of urlwatch (https://thp.io/2008/urlwatch/).
+# Copyright (c) 2008-2015 Thomas Perl
# All rights reserved.
-#
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
+#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
@@ -16,7 +15,7 @@
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/lib/urlwatch/ical2txt.py new/urlwatch-1.18/lib/urlwatch/ical2txt.py
--- old/urlwatch-1.17/lib/urlwatch/ical2txt.py 2014-08-01 21:43:00.000000000 +0200
+++ new/urlwatch-1.18/lib/urlwatch/ical2txt.py 2015-02-27 19:29:45.000000000 +0100
@@ -1,14 +1,13 @@
-#!/usr/bin/python
-# Convert iCalendar data to plaintext (very basic, don't rely on it :)
-# Requirements: python-vobject (http://vobject.skyhouseconsulting.com/)
-# This file is part of urlwatch
+# -*- coding: utf-8 -*-
#
-# Copyright (c) 2008-2014 Thomas Perl
+# This file is part of urlwatch (https://thp.io/2008/urlwatch/).
+# Copyright (c) 2008-2015 Thomas Perl
# All rights reserved.
-#
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
+#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
@@ -16,7 +15,7 @@
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/lib/urlwatch/mailer.py new/urlwatch-1.18/lib/urlwatch/mailer.py
--- old/urlwatch-1.17/lib/urlwatch/mailer.py 2013-03-11 10:50:22.000000000 +0100
+++ new/urlwatch-1.18/lib/urlwatch/mailer.py 2015-02-27 19:30:49.000000000 +0100
@@ -1,15 +1,78 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of urlwatch (https://thp.io/2008/urlwatch/).
+# Copyright (c) 2008-2015 Thomas Perl
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
import smtplib
+try:
+ import keyring
+except ImportError:
+ keyring = None
+
from email.mime.text import MIMEText
-def send(smtp_server, from_email, to_email, subject, body):
+
+def send(smtp_server, from_email, to_email, subject, body,
+ tls=False, auth=False):
msg = MIMEText(body, 'plain', 'utf_8')
msg['Subject'] = subject
msg['From'] = from_email
msg['To'] = to_email
+ if ':' in smtp_server:
+ smtp_hostname, smtp_port = smtp_server.split(':')
+ smtp_port = int(smtp_port)
+ else:
+ smtp_port = 25
+ smtp_hostname = smtp_server
+
s = smtplib.SMTP()
- s.connect(smtp_server, 25)
+ s.connect(smtp_hostname, smtp_port)
+ s.ehlo()
+ if tls:
+ s.starttls()
+ if auth and keyring is not None:
+ passwd = keyring.get_password(smtp_server, from_email)
+ if passwd is None:
+ raise ValueError(
+ 'No password available in '
+ 'keyring for {}, {}'.format(smtp_server, from_email))
+ s.login(from_email, passwd)
s.sendmail(from_email, [to_email], msg.as_string())
s.quit()
+
+def set_password(smtp_server, from_email):
+ ''' Set the keyring password for the mail connection. Interactive.'''
+ if keyring is None:
+ raise ImportError('keyring module missing - service unsupported')
+ from getpass import getpass
+ keyring.set_password(smtp_server, from_email,
+ getpass(prompt='Enter password '
+ 'for {} using {}: '.format(
+ from_email, smtp_server)))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/setup.py new/urlwatch-1.18/setup.py
--- old/urlwatch-1.17/setup.py 2014-08-01 21:43:00.000000000 +0200
+++ new/urlwatch-1.18/setup.py 2015-02-27 19:25:32.000000000 +0100
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Minimalistic, automatic setup.py file for Python modules
-# Copyright (c) 2008-2014 Thomas Perl
+# Copyright (c) 2008-2015 Thomas Perl
PACKAGE_NAME = 'urlwatch'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/share/man/man1/urlwatch.1 new/urlwatch-1.18/share/man/man1/urlwatch.1
--- old/urlwatch-1.17/share/man/man1/urlwatch.1 2014-08-01 21:48:31.000000000 +0200
+++ new/urlwatch-1.18/share/man/man1/urlwatch.1 2015-02-27 19:32:11.000000000 +0100
@@ -1,4 +1,4 @@
-.TH URLWATCH "1" "August 2014" "urlwatch 1.17" "User Commands"
+.TH URLWATCH "1" "February 2015" "urlwatch 1.18" "User Commands"
.SH NAME
urlwatch \- Watch web pages and arbitrary URLs for changes
.SH SYNOPSIS
@@ -36,6 +36,9 @@
.TP
\fB\-s\fR, \fB\-\-smtp\fR=\fISERVER\fR
SMTP server for e-mail (--mailto)
+.TP
+\fB\-q\fR, \fB\-\-quiet\fR
+Avoid diff output on stdout (--mailto)
.SH ADVANCED FEATURES
urlwatch includes some advanced features that you have to activate by creating
a hooks.py file that specifies for which URLs to use a specific feature. You
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/share/urlwatch/examples/hooks.py.example new/urlwatch-1.18/share/urlwatch/examples/hooks.py.example
--- old/urlwatch-1.17/share/urlwatch/examples/hooks.py.example 2014-08-01 21:43:00.000000000 +0200
+++ new/urlwatch-1.18/share/urlwatch/examples/hooks.py.example 2015-02-27 19:25:40.000000000 +0100
@@ -1,7 +1,7 @@
#
# Example hooks file for urlwatch
#
-# Copyright (c) 2008-2014 Thomas Perl
+# Copyright (c) 2008-2015 Thomas Perl
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -82,6 +82,18 @@
# using a regular expression and does no formatting)
return html2txt.html2text(data, method='lynx')
+ # In some cases, it might be necessary to decode the data from
+ # bytes to unicode. We don't always know the encoding of the
+ # remote file, so pick the right encoding (maybe depending on
+ # the remote URL), like so:
+
+ if type(data) == bytes:
+ data = data.decode('utf-8')
+
+ # You might want to replace DOS-style line endings (\r\n) with
+ # Unix-style line endings (\n), which is easy to do like so:
+ data = data.replace('\r', '')
+
# The next line is optional - if the filter function returns
# None (or no value at all), the input data will be taken as
# the result -> None as return value means "don't filter".
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlwatch-1.17/urlwatch new/urlwatch-1.18/urlwatch
--- old/urlwatch-1.17/urlwatch 2014-08-01 21:48:39.000000000 +0200
+++ new/urlwatch-1.18/urlwatch 2015-02-27 19:32:50.000000000 +0100
@@ -1,14 +1,14 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
-# urlwatch is a minimalistic URL watcher written in Python
-#
-# Copyright (c) 2008-2014 Thomas Perl
+# This file is part of urlwatch (https://thp.io/2008/urlwatch/).
+# Copyright (c) 2008-2015 Thomas Perl
# All rights reserved.
-#
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
+#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
@@ -16,7 +16,7 @@
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -27,7 +27,6 @@
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
"""Watch web pages and arbitrary URLs for changes
@@ -37,12 +36,12 @@
"""
pkgname = 'urlwatch'
-COPYRIGHT = 'Copyright 2008-2014 Thomas Perl'
+COPYRIGHT = 'Copyright 2008-2015 Thomas Perl'
__author__ = 'Thomas Perl '
__license__ = 'BSD'
__url__ = 'http://thp.io/2008/urlwatch/'
-__version__ = '1.17'
+__version__ = '1.18'
user_agent = '%s/%s (+http://thp.io/2008/urlwatch/info.html)' % (pkgname, __version__)
@@ -111,7 +110,7 @@
log.addHandler(NullHandler())
ERROR_MESSAGE_URLS_TXT = """
-Error: You need to create a urls.txt file first.'
+Error: You need to create a urls.txt file first.
Place it in %s
An example is available in %s
@@ -163,6 +162,12 @@
parser.add_option('-t', '--mailto', dest='email', metavar='ADDRESS', help='Send results via e-mail to ADDRESS')
parser.add_option('-f', '--mailfrom', dest='email_from', metavar='ADDRESS', help='Alternate From: address for e-mail (--mailto)')
parser.add_option('-s', '--smtp', dest='email_smtp', metavar='SERVER', help='SMTP server for e-mail (--mailto)')
+ parser.add_option('-S', '--subject', dest='email_subject', metavar='SUBJECT', help='Alternate Subject: for e-mail (--mailto)')
+ parser.add_option('-p', '--pass', dest='password', action='store_true', help='Interactively set password for SMTP')
+ parser.add_option('-T', '--tls', dest='tls', action='store_true', help='Enable STARTTLS for SMTP')
+ parser.add_option('-q', '--quiet', action='store_true', dest='quiet', help='Avoid diff output on stdout (--mailto)')
+ parser.add_option('-A', '--auth', dest='auth', action='store_true', default=False, help='Enable authentication from keyring for SMTP')
+ parser.add_option('-c', '--cache', dest='cache', metavar='DIR', help='Use specified DIR as cache directory.', default=None)
parser.set_defaults(verbose=False, display_errors=False)
@@ -181,12 +186,19 @@
log.info('turning display of errors ON')
display_errors = True
+ if options.password:
+ mailer.set_password(options.email_smtp, options.email_from)
+ sys.exit(0)
+
if options.email:
log.info('Send emails enabled')
enable_emails = True
email_smtp_server = options.email_smtp or 'localhost'
email_sender_address = options.email_from or options.email
email_receiver_address = options.email
+ email_subject = options.email_subject or 'Changes detected ({count})'
+ email_tls = options.tls
+ email_auth = options.auth
else:
if options.email_from:
log.error('--mailfrom without --mailto')
@@ -200,6 +212,7 @@
enable_emails = False
+
if options.urls:
if os.path.isfile(options.urls):
urls_txt = options.urls
@@ -218,6 +231,12 @@
print 'Error: %s is not a file' % options.hooks
sys.exit(1)
+
+ if options.cache:
+ cache_dir = options.cache
+ log.info('using {} as cache directory'.format(cache_dir))
+
+
# Created all needed folders
for needed_dir in (urlwatch_dir, cache_dir, scripts_dir):
if not os.path.isdir(needed_dir):
@@ -367,23 +386,30 @@
short_summary += '%02d. %s' % (id+1, line) + '\n'
short_summary += '-'*line_length + '\n'
short_summary += '\n\n\n'
- print short_summary
+ if not options.quiet:
+ print short_summary
else:
log.info('summary is too short - not printing')
+
if len(details) > 1:
log.info('printing details with %d items' % len(details))
- print '\n'.join(details)
- print '-- '
- print '%s %s, %s' % (pkgname, __version__, COPYRIGHT)
- print 'Website: %s' % (__url__,)
- print 'watched %d URLs in %d seconds\n' % (count, (end-start).seconds)
+ if not options.quiet:
+ print '\n'.join(details)
+ print '-- '
+ print '%s %s, %s' % (pkgname, __version__, COPYRIGHT)
+ print 'Website: %s' % (__url__,)
+ print 'watched %d URLs in %d seconds\n' % (count, (end-start).seconds)
if enable_emails:
try:
- subject = 'Changes detected (%d)' % len(summary)
+ subject_args = {
+ 'count': len(summary),
+ }
+
mailer.send(email_smtp_server, email_sender_address,
- email_receiver_address, subject,
- short_summary + '\n' + '\n'.join(details))
+ email_receiver_address, email_subject.format(**subject_args),
+ short_summary + '\n' + '\n'.join(details),
+ auth=email_auth, tls=email_tls)
log.info('E-Mail to %s sent.', email_receiver_address)
except Exception, e:
log.warning('E-Mail delivery error: %s', e)