예제 #1
0
 def get_entryinfo(path):
     '''
     get entry info object for path, populated
     '''
     finfo = EntryInfo(path)
     finfo.produce_json()
     return finfo.json
 def get_entryinfo(path):
     '''
     get entry info object for path, populated
     '''
     finfo = EntryInfo(path)
     finfo.produce_json()
     return finfo.json
    def run(self, quiet=False):
        '''
        do all the work

        note that 'quiet' applies only to remotely
        run, and the same is true for returning the contents.
        maybe we want to fix that
        '''

        while True:
            client = LocalClient()
            module_args = [self.path, self.batchno,
                           self.batchsize, quiet]

            result = client.cmd([self.host],
                                "retentionaudit.examine_dir",
                                module_args, expr_form='list',
                                timeout=self.timeout)

            if self.host in result:
                lines = result[self.host].split("\n")

                maxlen = 0
                for line in lines:
                    if (line.startswith("WARNING:") or
                            line.startswith("INFO:")):
                        continue
                    else:
                        try:
                            entry = json.loads(
                                line, object_hook=JsonHelper.decode_dict)
                            if len(entry['path']) > maxlen:
                                maxlen = len(entry['path'])
                        except:
                            continue

                if not quiet:
                    for line in lines:
                        if (line.startswith("WARNING:") or
                                line.startswith("INFO:")):
                            print line
                        else:
                            try:
                                entry = json.loads(
                                    line,
                                    object_hook=JsonHelper.decode_dict)
                                EntryInfo.display_from_dict(
                                    entry, True, maxlen)
                            except:
                                print line
                return result[self.host]
            else:
                print "Failed to retrieve dir content for", self.path, "on", self.host
                continuing = ("Try again? Y/N [N]: ")
                if continuing == "":
                    continuing = "N"
                if continuing.upper() != "Y":
                    return None
    def run(self, quiet=False):
        '''
        do all the work

        note that 'quiet' applies only to remotely
        run, and the same is true for returning the contents.
        maybe we want to fix that
        '''

        while True:
            client = LocalClient()
            module_args = [self.path, self.batchno, self.batchsize, quiet]

            result = client.cmd([self.host],
                                "retentionaudit.examine_dir",
                                module_args,
                                expr_form='list',
                                timeout=self.timeout)

            if self.host in result:
                lines = result[self.host].split("\n")

                maxlen = 0
                for line in lines:
                    if (line.startswith("WARNING:")
                            or line.startswith("INFO:")):
                        continue
                    else:
                        try:
                            entry = json.loads(
                                line, object_hook=JsonHelper.decode_dict)
                            if len(entry['path']) > maxlen:
                                maxlen = len(entry['path'])
                        except:
                            continue

                if not quiet:
                    for line in lines:
                        if (line.startswith("WARNING:")
                                or line.startswith("INFO:")):
                            print line
                        else:
                            try:
                                entry = json.loads(
                                    line, object_hook=JsonHelper.decode_dict)
                                EntryInfo.display_from_dict(
                                    entry, True, maxlen)
                            except:
                                print line
                return result[self.host]
            else:
                print "Failed to retrieve dir content for", self.path, "on", self.host
                continuing = ("Try again? Y/N [N]: ")
                if continuing == "":
                    continuing = "N"
                if continuing.upper() != "Y":
                    return None