From: Vikram Narayanan <vikram186@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] PATCH 4/4] patman: Handle searching of patman config
Date: Wed, 25 Apr 2012 21:15:49 +0530 [thread overview]
Message-ID: <4F981C2D.4080702@gmail.com> (raw)
patman shouts when it couldn't find a $(HOME)/.config/patman file.
Also, it couldn't create patch files without the above config file.
Handle it in a sane way by creating a new one for the user.
Signed-off-by: Vikram Narayanan <vikram186@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
---
tools/patman/settings.py | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 049c709..ea8661b 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -61,6 +61,22 @@ def ReadGitAliases(fname):
fd.close()
+def CreatePatmanConfigFile(config_fname):
+ name = raw_input("Enter name: ")
+ email = raw_input("Enter email: ")
+
+ try:
+ FILE = open(config_fname,"w")
+ except IOError:
+ print "Couldn't create patman config file\n"
+
+ FILE.write("[alias]\nme: ")
+ FILE.write(name);
+ FILE.write(" <");
+ FILE.write(email);
+ FILE.write(">")
+ FILE.close();
+
def Setup(config_fname=''):
"""Set up the settings module by reading config files.
@@ -70,8 +86,14 @@ def Setup(config_fname=''):
settings = ConfigParser.SafeConfigParser()
if config_fname == '':
config_fname = '%s/.config/patman' % os.getenv('HOME')
- if config_fname:
- settings.read(config_fname)
+
+ exists = os.path.exists(config_fname)
+
+ if exists == False:
+ print "No config file found under ~/.config/\nCreating one...\n"
+ CreatePatmanConfigFile(config_fname)
+
+ settings.read(config_fname)
for name, value in settings.items('alias'):
alias[name] = value.split(',')
--
1.7.4.1
next reply other threads:[~2012-04-25 15:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-25 15:45 Vikram Narayanan [this message]
2012-04-26 18:27 ` [U-Boot] PATCH 4/4] patman: Handle searching of patman config Simon Glass
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=4F981C2D.4080702@gmail.com \
--to=vikram186@gmail.com \
--cc=u-boot@lists.denx.de \
/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