Commit aac3ab2b authored by Seblu's avatar Seblu
Browse files

command expert

parent 9d1e1e22
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -135,10 +135,10 @@ try:
except BadArgument as e:
    printer.error("Bad Argument: %s"%str(e))
    oparser.print_help()
except cliError as e:
    printer.error(str(e))
except KeyboardInterrupt:
    exit(1)
except cliError as e:
    printer.error(str(e))
except Exception as e:
    if cccli.debug:
        printer.fatal(str(e), quit=False)
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ from cccli.printer import Printer, color
from cccli.exception import *

from sjrpc.client import SimpleRpcClient
from sjrpc.utils import RpcHandler, ConnectionProxy, pure
from sjrpc.utils import RpcHandler, pure
from sjrpc.core.exceptions import *

class Cli(object):
+16 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import sys
import re
import pprint
import ConfigParser
import code
from optparse import OptionParser

import cccli
@@ -17,6 +18,7 @@ from cccli.exception import *
from cccli.printer import color

from sjrpc.client import SimpleRpcClient
from sjrpc.utils import ConnectionProxy
from sjrpc.core.exceptions import *

class Command(object):
@@ -367,6 +369,20 @@ class Command(object):
            raise cmdError("RPCError: %s"%str(e))
    cmd_passwd.usage = "passwd <account> [password]"

    def cmd_expert(self, argv):
        '''Switch in expert mode'''
        self.printer.history.save(self.cli.settings.get("history", ""))
        try:
            local = dict()
            local["cli"] = self.cli
            local["rpc"] = self.cli.rpc
            local["proxy"] = ConnectionProxy(self.cli.rpc)
            c = code.InteractiveConsole(local)
            c.interact("Use Ctrl+D to go back in CLI")
        finally:
            self.printer.history.load(self.cli.settings.get("history", ""))
    cmd_expert.usage = "expert"


class Alias(dict):
    ''' Alias wrapper'''
+2 −2
Original line number Diff line number Diff line
@@ -106,8 +106,8 @@ class Printer(object):
            raise
        except KeyboardInterrupt:
            raise
        except:
            raise cliError
        except Exception as e:
            raise cliError(str(e))
        if not history and s:
            self.history.removelast()
        return s