Пример #1
0
    def listFTPJson(self, virtualHostName):
        try:

            records = FTPUtilities.getFTPRecords(virtualHostName)

            json_data = "["
            checker = 0

            for items in records:
                dic = {
                    'id': items.id,
                    'username': items.user,
                    'path': items.dir
                }

                if checker == 0:
                    json_data = json_data + json.dumps(dic)
                    checker = 1
                else:
                    json_data = json_data + ',' + json.dumps(dic)

            json_data = json_data + ']'
            final_json = json.dumps(json_data)
            print final_json

        except BaseException, msg:
            logger.writeforCLI(str(msg), "Error", stack()[0][3])
            print 0
Пример #2
0
    def listFTPPretty(self, virtualHostName):
        try:
            from prettytable import PrettyTable

            records = FTPUtilities.getFTPRecords(virtualHostName)

            table = PrettyTable(['ID', 'User', 'Path'])

            for items in records:
                table.add_row([items.id, items.user, items.dir])
            print table

        except BaseException, msg:
            logger.writeforCLI(str(msg), "Error", stack()[0][3])
            print 0