Exemple #1
0
    def __init__(self, base, conf=None, path=None, task=None, wait=None):
        cmd.Cmd.__init__(self)

        self.base = urlparse.urlparse(base)
        self.user = getpass.getuser()
        self.hdfs = WebHDFSClient(
            self.base._replace(path='').geturl(), self.user, conf, wait)

        self.do_cd(path or self.base.path)

        if task:
            self.onecmd(' '.join(task))
            sys.exit(0)

        try:
            self.hist = os.path.join(
                os.path.expanduser('~'),
                os.environ.get('WEBHDFS_HISTFILE', '.webhdfs_history'))
            readline.read_history_file(self.hist)

        except IOError:
            pass

        try:
            readline.set_history_length(
                int(os.environ.get('WEBHDFS_HISTSIZE', 3)))
        except ValueError:
            readline.set_history_length(0)

        if os.access(self.hist, os.W_OK):
            atexit.register(readline.write_history_file, self.hist)
Exemple #2
0
    def __init__(self, base, conf=None, path=None, task=None, wait=None):
        cmd.Cmd.__init__(self)

        self.base = urlparse.urlparse(base)
        self.user = getpass.getuser()
        self.hdfs = WebHDFSClient(base, self.user, conf, wait)

        self.do_cd(path)

        if task:
            self.onecmd(' '.join(task))
            sys.exit(0)