[node-patches] Change in ovirt-node[node-3.0]: Use optparse instead of argparse

mburns at redhat.com mburns at redhat.com
Thu May 23 20:53:31 UTC 2013


Michael Burns has uploaded a new change for review.

Change subject: Use optparse instead of argparse
......................................................................

Use optparse instead of argparse

Python 2.6 has optparse, but no argparse.  This patch attempts
to try argparse first, but fall back to optparse if it isn't
available.

Change-Id: Id9fdc1062f0dfbb1f7c8807981acdbf3fd805792
Signed-off-by: Mike Burns <mburns at redhat.com>
---
M src/ovirt/node/app.py
1 file changed, 9 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/43/15043/1

diff --git a/src/ovirt/node/app.py b/src/ovirt/node/app.py
index 8ffc8f2..811a2c5 100644
--- a/src/ovirt/node/app.py
+++ b/src/ovirt/node/app.py
@@ -22,11 +22,11 @@
 from ovirt.node.config import defaults
 from ovirt.node.ui import urwid_builder
 from ovirt.node.utils import system, Timer, console
-import argparse
 import logging
 import logging.config
 import sys
 import traceback
+from optparse import OptionParser
 
 """
 Representing the whole application (not just the TUI).
@@ -127,14 +127,17 @@
         self.plugin_base = plugin_base
 
     def __parse_cmdline(self):
-        parser = argparse.ArgumentParser(description='oVirt Node Utility')
-        parser.add_argument("--defaults",
-                            type=str,
+        parser = OptionParser()
+        parser.add_option("--defaults",
+                            dest="defaults",
                             help="Central oVirt Node configuration file")
-        parser.add_argument("--dry",
+        parser.add_option("--dry",
                             action='store_true',
+                            dest="dry",
+                            default=False,
                             help="Just write defaults, nothing else")
-        self.args = parser.parse_args()
+        (self.args, argcount) = parser.parse_args()
+
         self.logger.debug("Parsed args: %s" % self.args)
         if self.args.defaults:
             # FIXME Should be read by clients


--
To view, visit http://gerrit.ovirt.org/15043
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id9fdc1062f0dfbb1f7c8807981acdbf3fd805792
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: node-3.0
Gerrit-Owner: Michael Burns <mburns at redhat.com>



More information about the node-patches mailing list