Bug#805224: Overwrites config file

2015-11-23 Thread Etienne Millon
tags 805224 + upstream patch
forwarded 805224 https://github.com/wking/rss2email/pull/72
thanks

Hi Martin,

Thanks for reporting this bug. I informed upstream of this issue and
prepare a patch. I will upload a fixed version shortly.

Have a nice day!

-- 
Etienne Millon
From 6ce465dac257c29a9f43fe16fd3bafd6a383a445 Mon Sep 17 00:00:00 2001
From: Etienne Millon 
Date: Mon, 23 Nov 2015 20:45:02 +0100
Subject: [PATCH] r2e new: do not overwrite existing config
Bug-Debian: https://bugs.debian.org/805224
Forwarded: https://github.com/wking/rss2email/pull/72

If a configuration file already exists, "r2e new" will overwrite it.
This was reported in the following bug report:

https://bugs.debian.org/805224

This adds a check when running "r2e new" that will exit if the configuration
file already exists.

Signed-off-by: Etienne Millon 
---
 rss2email/command.py | 2 ++
 rss2email/error.py   | 6 ++
 rss2email/feeds.py   | 3 +++
 3 files changed, 11 insertions(+)

--- a/rss2email/command.py
+++ b/rss2email/command.py
@@ -31,6 +31,8 @@
 if args.email:
 _LOG.info('set the default target email to {}'.format(args.email))
 feeds.config['DEFAULT']['to'] = args.email
+if feeds.configfile_exists():
+raise _error.ConfigAlreadyExistsError(feeds=feeds)
 feeds.save()
 
 def email(feeds, args):
--- a/rss2email/error.py
+++ b/rss2email/error.py
@@ -258,3 +258,9 @@
 def __init__(self, **kwargs):
 message = 'error reading OPML'
 super(OPMLReadError, self).__init__(message=message, **kwargs)
+
+
+class ConfigAlreadyExistsError (FeedsError):
+def __init__(self, feeds=None):
+message = 'configuration file already exists'
+super().__init__(feeds=feeds, message=message)
--- a/rss2email/feeds.py
+++ b/rss2email/feeds.py
@@ -337,6 +337,9 @@
 'cannot convert data file from version {} to {}'.format(
 version, self.datafile_version))
 
+def configfile_exists(self):
+return _os.path.exists(self.configfiles[-1])
+
 def save(self):
 _LOG.debug('save feed configuration to {}'.format(self.configfiles[-1]))
 for feed in self:


signature.asc
Description: Digital signature


Processed: Re: Bug#805224: Overwrites config file

2015-11-23 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

> tags 805224 + upstream patch
Bug #805224 [rss2email] Overwrites config file
Added tag(s) upstream and patch.
> forwarded 805224 https://github.com/wking/rss2email/pull/72
Bug #805224 [rss2email] Overwrites config file
Set Bug forwarded-to-address to 'https://github.com/wking/rss2email/pull/72'.
> thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
805224: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=805224
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#805224: Overwrites config file

2015-11-15 Thread martin f krafft
Package: rss2email
Version: 1:3.9-1
Severity: grave

After drafting ~/.config/rss2email.cfg and running rss2email new,
I find that it overwrote the configuration file *and* didn't even
keep my choices:

  ambassador:~% printf '[DEFAULT]\nfrom = 
rss2em...@madduck.net\nuse-publisher-email = True' >| .config/rss2email.cfg
  ambassador:~% r2e new madd...@r2e.madduck.net
  ambassador:~% head .config/rss2email.cfg
  [DEFAULT]
  from = user@rss2email.invalid
  use-publisher-email = False
  […]

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.2.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_NZ, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)


-- 
 .''`.   martin f. krafft  @martinkrafft
: :'  :  proud Debian developer
`. `'`   http://people.debian.org/~madduck
  `-  Debian - when you have better things to do than fixing systems


digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current)