[Et-mgmt-commits-list] [SCM] virt-factory branch, master now at v0.0.3-213-gff5d048
Adrian Likins
alikins at redhat.com
Fri Aug 24 19:41:29 UTC 2007
Hello,
This is an automated email from the git hooks/update script, it was
generated because a ref change was pushed to the repository.
Updating branch, master,
via ff5d048a172950a363d7c1286e58a29d9a18b2b4 (commit)
from 9ded7b36c1736531cce6e7491c669f77dba13795 (commit)
- Log -----------------------------------------------------------------
commit ff5d048a172950a363d7c1286e58a29d9a18b2b4
Author: Adrian Likins <alikins at grimlock.devel.redhat.com>
Date: Fri Aug 24 15:33:09 2007 -0400
config.py:
handle default configs in a sane way, for handling cases
when no config file is found
ampm_cli.py:
add global commandline options for server, username, password
-----------------------------------------------------------------------
Diffstat:
ampm/client/ampm_cli.py | 40 +++++++++++++++++++++++++++++++++-------
ampm/client/config.py | 11 ++++++++++-
2 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/ampm/client/ampm_cli.py b/ampm/client/ampm_cli.py
index e17050b..cb81e57 100644
--- a/ampm/client/ampm_cli.py
+++ b/ampm/client/ampm_cli.py
@@ -20,13 +20,16 @@ import os
import sys
import config
-cfg = config.AmpmConfig()
+
+defaults = {"server":"http://127.0.0.1:5150",
+ "user": "",
+ "username": "admin",
+ "password": "fedora" }
+
+cfg = config.AmpmConfig(defaults)
cfg.load()
-api = ampmlib.Api(url=cfg.get("server", "url"),
- username=cfg.get("user", "username"),
- password=cfg.get("user", "password"))
from command_modules import list
@@ -40,25 +43,42 @@ def print_help():
print "== This is a useless help string blurb =="
print
-
+
def main():
+
+ username = cfg.get("user", "username")
+ password = cfg.get("user", "password")
+ server = cfg.get("server", "url")
+
try:
- opts, args = getopt.getopt(sys.argv[1:], "hv", [
+ opts, args = getopt.getopt(sys.argv[1:],
+ "hvu:p:s:", [
"help",
"verbose",
+ "username=",
+ "password=",
+ "server=",
])
except getopt.error, e:
print _("Error parsing command list arguments: %s") % e
showHelp()
sys.exit(1)
- for (opt, vals) in opts:
+ for (opt, val) in opts:
if opt in ["-h", "--help"]:
print_help()
sys.exit()
if opt in ["-v", "--verbose"]:
verbose = 1
+ if opt in ["-u", "--username"]:
+ username = val
+ if opt in ["-p", "--password"]:
+ password = val
+ # munge sys.argv so password doesn't show up in ps, etc listings
+ if opt in ["-s", "--server"]:
+ server = val
+
try:
mode = args[0]
@@ -72,6 +92,12 @@ def main():
sys.exit()
modeargs = args[args.index(mode)+1:]
+
+
+ api = ampmlib.Api(url=server,
+ username=username,
+ password=password)
+
if mode == "list":
list.run(modeargs, api=api)
diff --git a/ampm/client/config.py b/ampm/client/config.py
index 00c313a..18d14bf 100644
--- a/ampm/client/config.py
+++ b/ampm/client/config.py
@@ -10,6 +10,9 @@ class AmpmConfig(ConfigParser.SafeConfigParser):
def __init__(self, defaults=None):
ConfigParser.SafeConfigParser.__init__(self, defaults)
+ # I'm not a fan of the configParser default stuff
+ self.set_ampm_defaults()
+
def load(self):
filename = os.path.expanduser("~/.ampm_config")
if os.access(filename, os.R_OK):
@@ -17,7 +20,13 @@ class AmpmConfig(ConfigParser.SafeConfigParser):
else:
print "no config file found"
-
+ def set_ampm_defaults(self):
+ self.add_section("server")
+ self.add_section("user")
+ self.set("server", "url", "http://127.0.0.1:5150")
+ self.set("user", "username", "admin")
+ self.set("user", "password", "fedora")
+
if __name__ == "__main__":
hooks/update
---
Git Source Code Management System
hooks/update refs/heads/master \
9ded7b36c1736531cce6e7491c669f77dba13795 \
ff5d048a172950a363d7c1286e58a29d9a18b2b4
More information about the Et-mgmt-commits-list
mailing list