"""
+# functions in this module need to have a given name structure, so:
+# pylint: disable-msg=C0103
+
-import os
-import sys
import optparse
-import time
import cmd
try:
"""
cmd.Cmd.__init__(self)
- self.cfg = self.cluster_name = None
+ self.cfg = None
self.parents = []
self.path = []
if cfg_file:
if self.cfg is None:
self.prompt = "(#no config) "
else:
- self.prompt = "(%s:/%s) " % (self.cluster_name, "/".join(self.path))
+ self.prompt = "(/%s) " % ("/".join(self.path),)
return stop
def do_load(self, line):
arg = None
try:
self.cfg = config.ConfigWriter(cfg_file=arg, offline=True)
- self.cfg._OpenConfig()
self.parents = [self.cfg._config_data]
self.path = []
- self.cluster_name = self.cfg.GetClusterName()
except errors.ConfigurationError, err:
print "Error: %s" % str(err)
return False
def do_cd(self, line):
"""Changes the current path.
- Valid arguments: either .. or a child of the current object.
+ Valid arguments: either .., /, "" (no argument) or a child of the current
+ object.
"""
if line == "..":
else:
print "Already at top level"
return False
+ elif len(line) == 0 or line == "/":
+ self.parents = self.parents[0:1]
+ self.path = []
+ return False
pointer = self.parents[-1]
dirs, entries = self._get_entries(pointer)
print "Invalid node name"
def do_EOF(self, line):
+ """Exit the application.
+
+ """
print
return True
print
return True
+
class Error(Exception):
"""Generic exception"""
pass