From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys-ldap/gkeyldap/, gkeys/gkeys/
Date: Mon, 5 Jan 2015 23:12:37 +0000 (UTC) [thread overview]
Message-ID: <1420496513.ccb9e31c253a0f4ae9c096ce571a7c7109a33fd0.dolsen@gentoo> (raw)
commit: ccb9e31c253a0f4ae9c096ce571a7c7109a33fd0
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 5 08:56:12 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jan 5 22:21:53 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ccb9e31c
gkeys, gkeyldap: Update updatefiles() config handling
Add category and filename options, ensure 1 of them is passed in.
Fix logic error that did not report the failure to find the file to update.
---
gkeys-ldap/gkeyldap/actions.py | 2 +-
gkeys/gkeys/fileops.py | 55 ++++++++++++++++++++++++------------------
2 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/gkeys-ldap/gkeyldap/actions.py b/gkeys-ldap/gkeyldap/actions.py
index dde2bc8..4a3db84 100644
--- a/gkeys-ldap/gkeyldap/actions.py
+++ b/gkeys-ldap/gkeyldap/actions.py
@@ -107,7 +107,7 @@ class Actions(object):
self.logger.error("Developer seed file update failure: "
"Original seed file is intact & untouched.")
self.output('', "Backing up existing file...")
- status = updatefiles(self.config, self.logger)
+ status = updatefiles(self.config, self.logger, args.category)
if not status:
self.output('', "Develope seed failed to update!")
return False
diff --git a/gkeys/gkeys/fileops.py b/gkeys/gkeys/fileops.py
index 7cb244f..5b89ea8 100644
--- a/gkeys/gkeys/fileops.py
+++ b/gkeys/gkeys/fileops.py
@@ -30,27 +30,34 @@ def ensure_dirs(path, gid=-1, uid=-1, mode=0o700, minimal=True, failback=None, f
return succeeded
-def updatefiles(config, logger):
- filename = config['dev-seedfile']
- old = filename + '.old'
- try:
- logger.info("Backing up existing file...")
- if os.path.exists(old):
- logger.debug(
- "MAIN: _action_updatefile; Removing 'old' seed file: %s"
- % old)
- os.unlink(old)
- if os.path.exists(filename):
- logger.debug(
- "MAIN: _action_updatefile; Renaming current seed file to: "
- "%s" % old)
- os.rename(filename, old)
- if os.path.exists(filename + '.new'):
- logger.debug(
- "MAIN: _action_updatefile; Renaming '.new' seed file to: %s"
- % filename)
- os.rename(filename + '.new', filename)
- except IOError:
- raise
- return False
- return True
+def updatefiles(config, logger, category=None, filename = None):
+ if category and not filename:
+ filename = config.get_key('seeds', category)
+ elif not filename:
+ logger.error("MAIN: updatefiles(); category or filename not supplied")
+ return False
+ old = filename + '.old'
+ try:
+ logger.info("Backing up existing file...")
+ if os.path.exists(old):
+ logger.debug(
+ "MAIN: updatefiles(); Removing 'old' seed file: %s"
+ % old)
+ os.unlink(old)
+ if os.path.exists(filename):
+ logger.debug(
+ "MAIN: updatefiles(); Renaming current seed file to: "
+ "%s" % old)
+ os.rename(filename, old)
+ if os.path.exists(filename + '.new'):
+ logger.debug(
+ "MAIN: updatefiles(); Renaming '.new' seed file to: %s"
+ % filename)
+ os.rename(filename + '.new', filename)
+ else:
+ logger.error("MAIN: updatefiles(); Renaming "
+ "'%s.new' seed DOES NOT EXIST!" % filename)
+ except IOError:
+ raise
+ return False
+ return True
next reply other threads:[~2015-01-05 23:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-05 23:12 Brian Dolbec [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-01-05 23:12 [gentoo-commits] proj/gentoo-keys:master commit in: gkeys-ldap/gkeyldap/, gkeys/gkeys/ Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420496513.ccb9e31c253a0f4ae9c096ce571a7c7109a33fd0.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox