From 44864324e39b1610f6ce371b20b523c006779a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 7 May 2017 20:57:36 +0200 Subject: new 0115-Add_header.patch --- debian/changelog | 10 +++ debian/patches/001-config.diff | 115 ----------------------------------- debian/patches/002-try_mail.diff | 51 ---------------- debian/patches/003-syslog.diff | 96 ----------------------------- debian/patches/0100-config.diff | 115 +++++++++++++++++++++++++++++++++++ debian/patches/0105-try_mail.diff | 51 ++++++++++++++++ debian/patches/0110-syslog.diff | 96 +++++++++++++++++++++++++++++ debian/patches/0115-Add_header.patch | 34 +++++++++++ debian/patches/series | 7 ++- 9 files changed, 310 insertions(+), 265 deletions(-) delete mode 100644 debian/patches/001-config.diff delete mode 100644 debian/patches/002-try_mail.diff delete mode 100644 debian/patches/003-syslog.diff create mode 100644 debian/patches/0100-config.diff create mode 100644 debian/patches/0105-try_mail.diff create mode 100644 debian/patches/0110-syslog.diff create mode 100644 debian/patches/0115-Add_header.patch diff --git a/debian/changelog b/debian/changelog index 3716b91..a7e508c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +mwc (1.7.2-4) UNRELEASED; urgency=medium + + * Renumbering patches. + * debian/patches/0105-try_mail.diff: + - Replace undefined printf with print (Closes: #860494). + * New debian/patches/0115-Add_header.patch: + - Add header to fix missing User-agent und Access. + + -- Jörg Frings-Fürst Tue, 18 Apr 2017 11:06:04 +0200 + mwc (1.7.2-3) unstable; urgency=medium * Work for the python3.5 transition (Closes: #799232): diff --git a/debian/patches/001-config.diff b/debian/patches/001-config.diff deleted file mode 100644 index 7ccca33..0000000 --- a/debian/patches/001-config.diff +++ /dev/null @@ -1,115 +0,0 @@ -Description: add loading config from every path - Add loading config from ervery path - Separation data / program -Author: Jörg Frings-Fürst -Last-Update: 2014-05-12 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ -Index: trunk/mwc.py -=================================================================== ---- trunk.orig/mwc.py 2014-09-18 14:47:28.315407312 +0200 -+++ trunk/mwc.py 2014-09-18 14:49:11.000000000 +0200 -@@ -305,7 +305,7 @@ - - if __name__ == "__main__": - -- configMod = 'config' -+ configMod = '/etc/mwc/mwc-config' - dryrun = None - - try: -@@ -321,9 +321,24 @@ - configMod = arg - elif opt in ('-d', '--dry-run'): - dryrun = arg -- -- config = importlib.import_module(configMod) -- -+ # -+ # add code to load config from nonsystem path -+ # and change to datadir -+ # -+ try: -+ path = os.path.dirname(configMod) -+ fullname = os.path.basename(configMod) -+ sys.path.append(path) -+ config = importlib.import_module(fullname) -+ except: -+ print('Error: loading config') -+ sys.exit(2) -+ try: -+ os.chdir(config.datadir) -+ except: -+ print('Error: datadir not found') -+ sys.exit(3) -+ - if dryrun: - for site in config.sites: - if site['shortname'] == dryrun: -Index: trunk/config_template.py -=================================================================== ---- trunk.orig/config_template.py 2014-09-18 14:47:28.315407312 +0200 -+++ trunk/config_template.py 2014-09-18 14:47:28.271406411 +0200 -@@ -1,5 +1,3 @@ --import os.path -- - # Copyright: (2013-2014) Michael Till Beck - # License: GPL-2.0+ - -@@ -44,11 +42,11 @@ - smtphost = 'mysmtpprovider.com' - useTLS = True - smtpport = 587 --smtpusername = sender -+smtpusername = 'sender' - smtppwd = 'mypassword' - receiver = 'me2@mymail.com' - --os.chdir('/var/cache/mwc') -+datadir'/var/cache/mwc' - - enableRSSFeed = True - rssfile = 'feed.xml' -Index: trunk/mwcfeedserver.py -=================================================================== ---- trunk.orig/mwcfeedserver.py 2014-09-18 14:47:28.315407312 +0200 -+++ trunk/mwcfeedserver.py 2014-09-18 14:49:24.125775123 +0200 -@@ -6,6 +6,7 @@ - import http.server - import socketserver - import importlib -+import os - import sys - import getopt - -@@ -31,13 +32,26 @@ - elif opt in ('-p', '--port'): - port = int(arg) - --config = importlib.import_module(configMod) -- -+# -+# add code to load config from nonsystem path -+# and change to datadir -+# -+try: -+ path = os.path.dirname(configMod) -+ fullname = os.path.basename(configMod) -+ sys.path.append(path) -+ config = importlib.import_module(fullname) -+except: -+ print('Error: loading config') -+ sys.exit(2) - - handler = http.server.SimpleHTTPRequestHandler - - httpd = socketserver.TCPServer((bind, port), handler) - - print('Bond to ' + bind + ', listening on port ' + str(port)) --httpd.serve_forever() -- -+try: -+ httpd.serve_forever() -+except KeyboardInterrupt: -+ pass -+httpd.server_close() diff --git a/debian/patches/002-try_mail.diff b/debian/patches/002-try_mail.diff deleted file mode 100644 index 2372d76..0000000 --- a/debian/patches/002-try_mail.diff +++ /dev/null @@ -1,51 +0,0 @@ -Description: try / except around mail functions - add try / except around mail functions to - prevent python errors messages -Author: Jörg Frings-Fürst -Forwarded: via mail -Applied-Upstream: -Reviewed-by: -Last-Update: 2014-05-22 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ -Index: trunk/mwc.py -=================================================================== ---- trunk.orig/mwc.py 2014-05-22 08:43:11.758523862 +0200 -+++ trunk/mwc.py 2014-05-22 08:50:09.336051435 +0200 -@@ -212,15 +212,27 @@ - mail['Subject'] = Header(subject, defaultEncoding) - - # initialize session once, not each time this method gets called -- if mailsession is None: -- mailsession = smtplib.SMTP(config.smtphost, config.smtpport) -- if config.useTLS: -- mailsession.ehlo() -- mailsession.starttls() -- mailsession.login(config.smtpusername, config.smtppwd) -- -- mailsession.sendmail(config.sender, receiver.split(','), mail.as_string()) -- -+ # -+ # add try / except to open mailsession -+ # -+ try: -+ if mailsession is None: -+ mailsession = smtplib.SMTP(config.smtphost, config.smtpport) -+ if config.useTLS: -+ mailsession.ehlo() -+ mailsession.starttls() -+ mailsession.login(config.smtpusername, config.smtppwd) -+ # -+ # add try / except to send mail -+ # -+ except: -+ printf('Error: Open smtp-session') -+ exit(4) -+ try: -+ mailsession.sendmail(config.sender, receiver.split(','), mail.as_string()) -+ except: -+ printf('Error: sendmail') -+ exit(5) - - # returns a list of all content that is stored locally for a specific site - def getFileContents(shortname): diff --git a/debian/patches/003-syslog.diff b/debian/patches/003-syslog.diff deleted file mode 100644 index 4cab507..0000000 --- a/debian/patches/003-syslog.diff +++ /dev/null @@ -1,96 +0,0 @@ -Description: add syslog messages on errors -Author: Jörg Frings-Fürst -Forwarded: via mail -Last-Update: 2014-05-22 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ -Index: trunk/mwc.py -=================================================================== ---- trunk.orig/mwc.py 2014-09-18 14:47:28.427409601 +0200 -+++ trunk/mwc.py 2014-09-18 14:47:28.411409275 +0200 -@@ -19,6 +19,7 @@ - import sys - import getopt - import traceback -+import syslog - - import subprocess - -@@ -214,25 +215,28 @@ - # initialize session once, not each time this method gets called - # - # add try / except to open mailsession -- # -+ # -+ - try: -- if mailsession is None: -- mailsession = smtplib.SMTP(config.smtphost, config.smtpport) -- if config.useTLS: -- mailsession.ehlo() -- mailsession.starttls() -- mailsession.login(config.smtpusername, config.smtppwd) -- # -+ if mailsession is None: -+ mailsession = smtplib.SMTP(config.smtphost, config.smtpport) -+ if config.useTLS: -+ mailsession.ehlo() -+ mailsession.starttls() -+ mailsession.login(config.smtpusername, config.smtppwd) -+ except: -+ printf('Error: Open smtp-session') -+ syslog.syslog(syslog.LOG_ERR, 'can not open smtp session') -+ exit(4) -+ # - # add try / except to send mail - # -+ try: -+ mailsession.sendmail(config.sender, receiver.split(','), mail.as_string()) - except: -- printf('Error: Open smtp-session') -- exit(4) -- try: -- mailsession.sendmail(config.sender, receiver.split(','), mail.as_string()) -- except: -- printf('Error: sendmail') -- exit(5) -+ printf('Error: sendmail') -+ syslog.syslog(syslog.LOG_ERR, 'error on sendmail') -+ exit(5) - - # returns a list of all content that is stored locally for a specific site - def getFileContents(shortname): -@@ -319,7 +323,11 @@ - - configMod = '/etc/mwc/mwc-config' - dryrun = None -- -+ -+ # -+ # add syslog open -+ # -+ syslog.openlog() - try: - opts, args = getopt.getopt(sys.argv[1:], 'hc:d:', ['help', 'config=', 'dry-run=']) - except getopt.GetoptError: -@@ -344,11 +352,13 @@ - config = importlib.import_module(fullname) - except: - print('Error: loading config') -+ syslog.syslog(syslog.LOG_ERR, 'can not found / load mwc-config') - sys.exit(2) - try: - os.chdir(config.datadir) - except: - print('Error: datadir not found') -+ syslog.syslog(syslog.LOG_ERR, 'datadir not found') - sys.exit(3) - - if dryrun: -@@ -370,3 +380,5 @@ - mailsession.quit() - mailsession = None - -+ syslog.closelog() -+ -\ No newline at end of file diff --git a/debian/patches/0100-config.diff b/debian/patches/0100-config.diff new file mode 100644 index 0000000..7ccca33 --- /dev/null +++ b/debian/patches/0100-config.diff @@ -0,0 +1,115 @@ +Description: add loading config from every path + Add loading config from ervery path + Separation data / program +Author: Jörg Frings-Fürst +Last-Update: 2014-05-12 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: trunk/mwc.py +=================================================================== +--- trunk.orig/mwc.py 2014-09-18 14:47:28.315407312 +0200 ++++ trunk/mwc.py 2014-09-18 14:49:11.000000000 +0200 +@@ -305,7 +305,7 @@ + + if __name__ == "__main__": + +- configMod = 'config' ++ configMod = '/etc/mwc/mwc-config' + dryrun = None + + try: +@@ -321,9 +321,24 @@ + configMod = arg + elif opt in ('-d', '--dry-run'): + dryrun = arg +- +- config = importlib.import_module(configMod) +- ++ # ++ # add code to load config from nonsystem path ++ # and change to datadir ++ # ++ try: ++ path = os.path.dirname(configMod) ++ fullname = os.path.basename(configMod) ++ sys.path.append(path) ++ config = importlib.import_module(fullname) ++ except: ++ print('Error: loading config') ++ sys.exit(2) ++ try: ++ os.chdir(config.datadir) ++ except: ++ print('Error: datadir not found') ++ sys.exit(3) ++ + if dryrun: + for site in config.sites: + if site['shortname'] == dryrun: +Index: trunk/config_template.py +=================================================================== +--- trunk.orig/config_template.py 2014-09-18 14:47:28.315407312 +0200 ++++ trunk/config_template.py 2014-09-18 14:47:28.271406411 +0200 +@@ -1,5 +1,3 @@ +-import os.path +- + # Copyright: (2013-2014) Michael Till Beck + # License: GPL-2.0+ + +@@ -44,11 +42,11 @@ + smtphost = 'mysmtpprovider.com' + useTLS = True + smtpport = 587 +-smtpusername = sender ++smtpusername = 'sender' + smtppwd = 'mypassword' + receiver = 'me2@mymail.com' + +-os.chdir('/var/cache/mwc') ++datadir'/var/cache/mwc' + + enableRSSFeed = True + rssfile = 'feed.xml' +Index: trunk/mwcfeedserver.py +=================================================================== +--- trunk.orig/mwcfeedserver.py 2014-09-18 14:47:28.315407312 +0200 ++++ trunk/mwcfeedserver.py 2014-09-18 14:49:24.125775123 +0200 +@@ -6,6 +6,7 @@ + import http.server + import socketserver + import importlib ++import os + import sys + import getopt + +@@ -31,13 +32,26 @@ + elif opt in ('-p', '--port'): + port = int(arg) + +-config = importlib.import_module(configMod) +- ++# ++# add code to load config from nonsystem path ++# and change to datadir ++# ++try: ++ path = os.path.dirname(configMod) ++ fullname = os.path.basename(configMod) ++ sys.path.append(path) ++ config = importlib.import_module(fullname) ++except: ++ print('Error: loading config') ++ sys.exit(2) + + handler = http.server.SimpleHTTPRequestHandler + + httpd = socketserver.TCPServer((bind, port), handler) + + print('Bond to ' + bind + ', listening on port ' + str(port)) +-httpd.serve_forever() +- ++try: ++ httpd.serve_forever() ++except KeyboardInterrupt: ++ pass ++httpd.server_close() diff --git a/debian/patches/0105-try_mail.diff b/debian/patches/0105-try_mail.diff new file mode 100644 index 0000000..6e11916 --- /dev/null +++ b/debian/patches/0105-try_mail.diff @@ -0,0 +1,51 @@ +Description: try / except around mail functions + add try / except around mail functions to + prevent python errors messages +Author: Jörg Frings-Fürst +Forwarded: via mail +Applied-Upstream: +Reviewed-by: +Last-Update: 2014-05-22 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: trunk/mwc.py +=================================================================== +--- trunk.orig/mwc.py ++++ trunk/mwc.py +@@ -212,15 +212,27 @@ def sendmail(receiver, subject, content, + mail['Subject'] = Header(subject, defaultEncoding) + + # initialize session once, not each time this method gets called +- if mailsession is None: +- mailsession = smtplib.SMTP(config.smtphost, config.smtpport) +- if config.useTLS: +- mailsession.ehlo() +- mailsession.starttls() +- mailsession.login(config.smtpusername, config.smtppwd) +- +- mailsession.sendmail(config.sender, receiver.split(','), mail.as_string()) +- ++ # ++ # add try / except to open mailsession ++ # ++ try: ++ if mailsession is None: ++ mailsession = smtplib.SMTP(config.smtphost, config.smtpport) ++ if config.useTLS: ++ mailsession.ehlo() ++ mailsession.starttls() ++ mailsession.login(config.smtpusername, config.smtppwd) ++ # ++ # add try / except to send mail ++ # ++ except: ++ print('Error: Open smtp-session') ++ exit(4) ++ try: ++ mailsession.sendmail(config.sender, receiver.split(','), mail.as_string()) ++ except: ++ print('Error: sendmail') ++ exit(5) + + # returns a list of all content that is stored locally for a specific site + def getFileContents(shortname): diff --git a/debian/patches/0110-syslog.diff b/debian/patches/0110-syslog.diff new file mode 100644 index 0000000..cffffb4 --- /dev/null +++ b/debian/patches/0110-syslog.diff @@ -0,0 +1,96 @@ +Description: add syslog messages on errors +Author: Jörg Frings-Fürst +Forwarded: via mail +Last-Update: 2014-05-22 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: trunk/mwc.py +=================================================================== +--- trunk.orig/mwc.py 2014-09-18 14:47:28.427409601 +0200 ++++ trunk/mwc.py 2014-09-18 14:47:28.411409275 +0200 +@@ -19,6 +19,7 @@ + import sys + import getopt + import traceback ++import syslog + + import subprocess + +@@ -214,25 +215,28 @@ + # initialize session once, not each time this method gets called + # + # add try / except to open mailsession +- # ++ # ++ + try: +- if mailsession is None: +- mailsession = smtplib.SMTP(config.smtphost, config.smtpport) +- if config.useTLS: +- mailsession.ehlo() +- mailsession.starttls() +- mailsession.login(config.smtpusername, config.smtppwd) +- # ++ if mailsession is None: ++ mailsession = smtplib.SMTP(config.smtphost, config.smtpport) ++ if config.useTLS: ++ mailsession.ehlo() ++ mailsession.starttls() ++ mailsession.login(config.smtpusername, config.smtppwd) ++ except: ++ print('Error: Open smtp-session') ++ syslog.syslog(syslog.LOG_ERR, 'can not open smtp session') ++ exit(4) ++ # + # add try / except to send mail + # ++ try: ++ mailsession.sendmail(config.sender, receiver.split(','), mail.as_string()) + except: +- print('Error: Open smtp-session') +- exit(4) +- try: +- mailsession.sendmail(config.sender, receiver.split(','), mail.as_string()) +- except: +- print('Error: sendmail') +- exit(5) ++ print('Error: sendmail') ++ syslog.syslog(syslog.LOG_ERR, 'error on sendmail') ++ exit(5) + + # returns a list of all content that is stored locally for a specific site + def getFileContents(shortname): +@@ -319,7 +323,11 @@ + + configMod = '/etc/mwc/mwc-config' + dryrun = None +- ++ ++ # ++ # add syslog open ++ # ++ syslog.openlog() + try: + opts, args = getopt.getopt(sys.argv[1:], 'hc:d:', ['help', 'config=', 'dry-run=']) + except getopt.GetoptError: +@@ -344,11 +352,13 @@ + config = importlib.import_module(fullname) + except: + print('Error: loading config') ++ syslog.syslog(syslog.LOG_ERR, 'can not found / load mwc-config') + sys.exit(2) + try: + os.chdir(config.datadir) + except: + print('Error: datadir not found') ++ syslog.syslog(syslog.LOG_ERR, 'datadir not found') + sys.exit(3) + + if dryrun: +@@ -370,3 +380,5 @@ + mailsession.quit() + mailsession = None + ++ syslog.closelog() ++ +\ No newline at end of file diff --git a/debian/patches/0115-Add_header.patch b/debian/patches/0115-Add_header.patch new file mode 100644 index 0000000..b9fc54e --- /dev/null +++ b/debian/patches/0115-Add_header.patch @@ -0,0 +1,34 @@ +Description: Add Header User-agent and Accept +Author: Jörg Frings-Fürst +Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862004 +Forwarded: https://github.com/Debianguru/MailWebsiteChanges/issues/11 +Last-Update: 2017-05-07 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: trunk/mwc.py +=================================================================== +--- trunk.orig/mwc.py ++++ trunk/mwc.py +@@ -68,6 +68,8 @@ def parseSite(site): + contenttype = site.get('type', 'html') + contentregex = site.get('contentregex', '') + titleregex = site.get('titleregex', '') ++ UserAgent = site.get('User-agent', '') ++ Accept = site.get('Accept', '') + enc = site.get('encoding', defaultEncoding) + + contentxpath = site.get('contentxpath', '') +@@ -86,7 +88,12 @@ def parseSite(site): + file = process.stdout + else: + # open website +- file = urllib.request.urlopen(uri) ++ req = urllib.request.Request(uri) ++ if UserAgent != '': ++ req.add_header('User-agent', UserAgent) ++ if Accept != '': ++ req.add_header('Accept', Accept) ++ file = urllib.request.urlopen(req) + + + if contenttype == 'text' or (contentxpath == '' and titlexpath == ''): diff --git a/debian/patches/series b/debian/patches/series index 75c3c95..f44e7e1 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,4 @@ -001-config.diff -002-try_mail.diff -003-syslog.diff +0100-config.diff +0105-try_mail.diff +0110-syslog.diff +0115-Add_header.patch -- cgit v1.2.3