• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python generics_utils.order_list_object_by函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ussclicore.utils.generics_utils.order_list_object_by函数的典型用法代码示例。如果您正苦于以下问题:Python order_list_object_by函数的具体用法?Python order_list_object_by怎么用?Python order_list_object_by使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了order_list_object_by函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: do_list

        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        allRepo = self.api.Orgs(org.dbId).Repositories.Getall()

                        if allRepo is None:
                                printer.out("No repositories found in [" + org.name + "].")
                                return 0

                        if doArgs.sort is not None:
                                if doArgs.sort.lower() == "name":
                                        printer.out("Repository list ordered by [name] :")
                                        allRepo = order_list_object_by(allRepo.repositories.repository, "name")
                                elif doArgs.sort.lower() == "id":
                                        printer.out("Repository list ordered by [id] :")
                                        allRepo = sorted(allRepo.repositories.repository, key=lambda x: getattr(x, "dbId"), reverse=False)
                                elif doArgs.sort.lower() == "url":
                                        printer.out("Repository list ordered by [url] :")
                                        allRepo = order_list_object_by(allRepo.repositories.repository, "url")
                                elif doArgs.sort.lower() == "type":
                                        printer.out("Repository list ordered by [type] :")
                                        allRepo = order_list_object_by(allRepo.repositories.repository, "packagingType")
                                else:
                                        printer.out("Sorting parameter filled don't exist.", printer.WARNING)
                                        printer.out("Repository list :")
                                        allRepo = sorted(allRepo.repositories.repository, key=lambda x: getattr(x, "dbId"), reverse=False)
                        else:
                                printer.out("Repository list :")
                                allRepo = sorted(allRepo.repositories.repository, key=lambda x: getattr(x, "dbId"), reverse=False)

                        table = Texttable(200)
                        table.set_cols_align(["c", "c", "l", "l", "c"])
                        table.set_cols_width([5,5,30,80,8])
                        table.header(["Id", "Off. Supported", "Name", "URL", "Type"])

                        for item in allRepo:
                                if item.officiallySupported:
                                        officiallySupported = "X"
                                else:
                                        officiallySupported = ""
                                table.add_row([item.dbId, officiallySupported, item.name, item.url, item.packagingType])

                        print table.draw() + "\n"

                        printer.out("Found " + str(len(allRepo)) + " repositories.")

                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:56,代码来源:org_repo.py


示例2: do_list

    def do_list(self, args):
        try:
            # call UForge API
            # get images
            printer.out("Getting all images and publications for [" + self.login + "] ...", printer.INFO)
            images = self.get_all_images()
            if len(images) == 0 :
                printer.out("No image available", printer.INFO)
            else :
                printer.out("Images:")
                table = self.initialize_text_table(800)
                table.set_cols_dtype(["t", "t", "t", "t", "t", "t", "t", "t", "t"])
                table.header(
                    ["Id", "Name", "Version", "Rev.", "Format", "Created", "Size", "Compressed", "Generation Status"])
                images = generics_utils.order_list_object_by(images, "name")
                for image in images:
                    imgStatus = self.get_image_status(image.status)
                    table.add_row([image.dbId, image.name, image.version, image.revision, image.targetFormat.name,
                               image.created.strftime("%Y-%m-%d %H:%M:%S"), size(image.fileSize),
                               "X" if image.compress else "", imgStatus])
                print table.draw() + "\n"
                printer.out("Found " + str(len(images)) + " images", printer.INFO)

            # get publications
            publish_images = self.api.Users(self.login).Pimages.Getall()
            publish_images = publish_images.publishImages.publishImage

            if publish_images is None or len(publish_images) == 0:
                printer.out("No publication available", printer.INFO)
                return 0

            printer.out("Publications:")
            table = self.initialize_text_table(800)
            table.set_cols_dtype(["t", "t", "t", "t", "t", "t", "t"])
            table.header(["Template name", "Image ID", "Publish ID", "Account name", "Format", "Cloud ID", "Status"])
            publish_images = generics_utils.order_list_object_by(publish_images, "name")
            for publish_image in publish_images:
                pubStatus = get_publish_status(publish_image.status)
                table.add_row([publish_image.name,
                               generics_utils.extract_id(publish_image.imageUri),
                               publish_image.dbId,
                               publish_image.credAccount.name if publish_image.credAccount is not None else "-",
                               publish_image.credAccount.targetPlatform.name,
                               publish_image.cloudId if publish_image.cloudId is not None else "-", pubStatus])
            print table.draw() + "\n"
            printer.out("Found " + str(len(publish_images)) + " publications", printer.INFO)

            return 0
        except ArgumentParserError as e:
            printer.out("In Arguments: " + str(e), printer.ERROR)
            self.help_list()
        except Exception as e:
            return handle_uforge_exception(e)
开发者ID:jgweir,项目名称:hammr,代码行数:53,代码来源:image.py


示例3: do_list

        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        printer.out("Getting user list for ["+org.name+"] . . .")
                        allUsers = self.api.Orgs(org.dbId).Members.Getall()
                        allUsers = order_list_object_by(allUsers.users.user, "loginName")

                        table = Texttable(200)
                        table.set_cols_align(["l", "l", "c"])
                        table.header(["Login", "Email", "Active"])

                        for item in allUsers:
                                if item.active:
                                        active = "X"
                                else:
                                        active = ""
                                table.add_row([item.loginName, item.email, active])

                        print table.draw() + "\n"
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:29,代码来源:org_user.py


示例4: do_list

        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))
                        org = org_utils.org_get(self.api, doArgs.org)

                        # call UForge API
                        printer.out("Getting all the subscription profiles for organization ...")
                        subscriptions = self.api.Orgs(org.dbId).Subscriptions().Getall(Search=None)
                        subscriptions = generics_utils.order_list_object_by(subscriptions.subscriptionProfiles.subscriptionProfile, "name")
                        if subscriptions is None or len(subscriptions) == 0:
                                printer.out("There is no subscriptions in [" + org.name + "] ")
                                return 0
                        printer.out("List of subscription profiles in [" + org.name + "] :")
                        table = Texttable(200)
                        table.set_cols_align(["c", "c", "c", "c"])
                        table.header(["Name", "Code", "Active", "description"])
                        for subscription in subscriptions:
                                if subscription.active:
                                        active = "X"
                                else:
                                        active = ""
                                table.add_row([subscription.name, subscription.code, active, subscription.description])
                        print table.draw() + "\n"
                        printer.out("Foumd " + str(len(subscriptions)) + " subscription profile(s).")
                        return 0

                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:32,代码来源:subscription.py


示例5: do_list

    def do_list(self, args):
        try:
            #call UForge API
            printer.out("Getting generation formats for ["+self.login+"] ...")
            targetFormatsUser = self.api.Users(self.login).Targetformats.Getall()
            if targetFormatsUser is None or len(targetFormatsUser.targetFormats.targetFormat) == 0:
                printer.out("No generation formats available")
                return 0
            else:
                targetFormatsUser = generics_utils.order_list_object_by(targetFormatsUser.targetFormats.targetFormat,"name")
                table = Texttable(200)
                table.set_cols_align(["l", "l", "l", "l", "l", "c"])
                table.header(["Name", "Format", "Category", "Type", "CredAccountType", "Access"])
                for item in targetFormatsUser:
                    if item.access:
                        access = "X"
                    else:
                        access = ""
                    if item.credAccountType is None:
                        credAccountType = ""
                    else:
                        credAccountType = item.credAccountType
                    table.add_row(
                        [item.name, item.format.name, item.category.name, item.type, credAccountType,
                         access])
                print table.draw() + "\n"
            return 0

        except ArgumentParserError as e:
            printer.out("In Arguments: " + str(e), printer.ERROR)
            self.help_list()
        except Exception as e:
            return handle_uforge_exception(e)
开发者ID:hidakanoko,项目名称:hammr,代码行数:33,代码来源:format.py


示例6: do_list

    def do_list(self, args):
        try:
            printer.out("Getting target platform :")
            targetPlatformsUser = self.api.Users(self.login).Targetplatforms.Getall()
            if targetPlatformsUser is None or len(targetPlatformsUser.targetPlatforms.targetPlatform) == 0:
                printer.out("There is no target platform")
                return 0
            else:
                targetPlatformsUser = generics_utils.order_list_object_by(
                    targetPlatformsUser.targetPlatforms.targetPlatform, "name")
                printer.out("Target platform list:")
                table = Texttable(200)
                table.set_cols_align(["c", "c", "c", "c"])
                table.header(["Id", "Name", "Type", "Access"])
                for item in targetPlatformsUser:
                    if item.access:
                        access = "X"
                    else:
                        access = ""
                    table.add_row([item.dbId, item.name, item.type, access])
                print table.draw() + "\n"
            return 0

        except ArgumentParserError as e:
            printer.out("In Arguments: " + str(e), printer.ERROR)
            self.help_list()
        except Exception as e:
            return handle_uforge_exception(e)
开发者ID:cinlloc,项目名称:hammr,代码行数:28,代码来源:platform.py


示例7: do_list

 def do_list(self, args):
     try:
         #call UForge API
         printer.out("Getting distributions for ["+self.login+"] ...")
         distributions = self.api.Users(self.login).Distros.Getall()
         distributions = distributions.distributions
         if distributions is None or not hasattr(distributions, "distribution"):
             printer.out("No distributions available")
         else:
             table = Texttable(800)
             table.set_cols_dtype(["t","t","t","t","t", "t"])
             table.header(["Id", "Name", "Version", "Architecture", "Release Date", "Profiles"])
             distributions = generics_utils.order_list_object_by(distributions.distribution, "name")
             for distribution in distributions:
                 profiles = self.api.Distributions(distribution.dbId).Profiles.Getall()
                 profiles = profiles.distribProfiles.distribProfile
                 if len(profiles) > 0:
                     profile_text=""
                     for profile in profiles:
                         profile_text+=profile.name+"\n"
                     table.add_row([distribution.dbId, distribution.name, distribution.version, distribution.arch, distribution.releaseDate.strftime("%Y-%m-%d %H:%M:%S") if distribution.releaseDate is not None else "", profile_text])
                 else:
                     table.add_row([distribution.dbId, distribution.name, distribution.version, distribution.arch, distribution.releaseDate.strftime("%Y-%m-%d %H:%M:%S") if distribution.releaseDate is not None else "", "-"])
             print table.draw() + "\n"
             printer.out("Found "+str(len(distributions))+" distributions")
         return 0
     except ArgumentParserError as e:
         printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
         self.help_list()
     except Exception as e:
         return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:hammr,代码行数:31,代码来源:os.py


示例8: do_list

        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        printer.out("Getting category list for ["+org.name+"] . . .")
                        allCategory = self.api.Orgs(org.dbId).Categories.Getall()
                        allCategory = order_list_object_by(allCategory.categories.category, "name")

                        if len(allCategory) is 0:
                                printer.out("["+org.name+"] has no categories.")
                                return 0

                        table = Texttable(200)
                        table.set_cols_align(["l", "l", "l"])
                        table.header(["Id", "Category", "type"])

                        for item in allCategory:
                                table.add_row([item.dbId, item.name, item.type])
                        print table.draw() + "\n"
                        printer.out("Found " + str(len(allCategory)) + " categories.")
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:29,代码来源:org_category.py


示例9: do_search

    def do_search(self, args):
        try:
            #add arguments
            doParser = self.arg_search()
            doArgs = doParser.parse_args(shlex.split(args))

            #if the help command is called, parse_args returns None object
            if not doArgs:
                    return 2

            #call UForge API
            printer.out("Search package '"+doArgs.pkg+"' ...")
            distribution = self.api.Distributions(doArgs.id).Get()
            printer.out("for OS '"+distribution.name+"', version "+distribution.version)
            pkgs = self.api.Distributions(distribution.dbId).Pkgs.Getall(Query="name=="+doArgs.pkg)
            pkgs = pkgs.pkgs.pkg
            if pkgs is None or len(pkgs) == 0:
                printer.out("No package found")
            else:
                table = Texttable(800)
                table.set_cols_dtype(["t","t","t","t","t","t","t"])
                table.header(["Name", "Version", "Arch", "Release", "Build date", "Size", "FullName"])
                pkgs = generics_utils.order_list_object_by(pkgs, "name")
                for pkg in pkgs:
                    table.add_row([pkg.name, pkg.version, pkg.arch, pkg.release, pkg.pkgBuildDate.strftime("%Y-%m-%d %H:%M:%S"), size(pkg.size), pkg.fullName])
                print table.draw() + "\n"
                printer.out("Found "+str(len(pkgs))+" packages")
        except ArgumentParserError as e:
            printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
            self.help_search()
        except Exception as e:
            return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:hammr,代码行数:32,代码来源:os.py


示例10: do_list

        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))

                        printer.out("Getting entitlements list of the UForge :")
                        entList = self.api.Entitlements.Getall()
                        if entList is None:
                                printer.out("No entitlements found.", printer.OK)
                        else:
                                entList=generics_utils.order_list_object_by(entList.entitlements.entitlement, "name")
                                printer.out("Entitlement list for the UForge :")
                                table = Texttable(200)
                                table.set_cols_align(["l", "l"])
                                table.header(["Name", "Description"])
                                table.set_cols_width([30,60])
                                for item in entList:
                                        table.add_row([item.name, item.description])
                                print table.draw() + "\n"
                        return 0

                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:26,代码来源:entitlement.py


示例11: do_list

 def do_list(self, args):
     try:
         #call UForge API
         printer.out("Getting templates for ["+self.login+"] ...")
         appliances = self.api.Users(self.login).Appliances().Getall()
         appliances = appliances.appliances
         if appliances is None or not hasattr(appliances, 'appliance'):
             printer.out("No template")
         else:
             images = self.api.Users(self.login).Images.Get()
             images = images.images
             table = Texttable(800)
             table.set_cols_dtype(["t","t","t","t","t","t","t","t","t","t"])
             table.header(["Id", "Name", "Version", "OS", "Created", "Last modified", "# Imgs", "Updates", "Imp", "Shared"])
             appliances = generics_utils.order_list_object_by(appliances.appliance, "name")
             for appliance in appliances:
                 nbImage=0
                 if images is not None and hasattr(images, 'image'):
                     for image in images.image:
                         if hasattr(image, 'applianceUri') and image.applianceUri == appliance.uri:
                             nbImage+=1
                 table.add_row([appliance.dbId, appliance.name, str(appliance.version), appliance.distributionName+" "+appliance.archName,
                                appliance.created.strftime("%Y-%m-%d %H:%M:%S"), appliance.lastModified.strftime("%Y-%m-%d %H:%M:%S"), nbImage, appliance.nbUpdates, "X" if appliance.imported else "", "X" if appliance.shared else ""])
             print table.draw() + "\n"
             printer.out("Found "+str(len(appliances))+" templates")
         return 0
     except ArgumentParserError as e:
         printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
         self.help_list()
     except Exception as e:
         return handle_uforge_exception(e)
开发者ID:ShigeruIchihashi,项目名称:hammr,代码行数:31,代码来源:template.py


示例12: do_enable

        def do_enable(self, args):
                try:
                        doParser = self.arg_enable()
                        doArgs = doParser.parse_args(shlex.split(args))
                        org = org_utils.org_get(self.api, doArgs.org)
                        if org is None:
                                printer.out("There is no organization matching ["+doArgs.org+"].", printer.OK)
                                return 0

                        targetPlatformsOrg = self.api.Orgs(org.dbId).Targetplatforms.Getall()
                        if targetPlatformsOrg is None or len(targetPlatformsOrg.targetPlatforms.targetPlatform) == 0:
                                printer.out("There is no target platform for the user \""+doArgs.account+"\" in [" + org.name + "].")
                                return 0
                        else:
                                targetPlatformsOrg = targetPlatformsOrg.targetPlatforms.targetPlatform

                                targetPlatformsList = targetPlatforms()
                                targetPlatformsList.targetPlatforms = pyxb.BIND()

                                targetPlatformsOrg = compare(targetPlatformsOrg, doArgs.targetPlatforms, "name")

                                if len(targetPlatformsOrg) == 0:
                                        listName = ""
                                        for tpname in doArgs.targetPlatforms:
                                                listName = listName + tpname + " "
                                        printer.out("There is no target platforms matching ["+listName+"].")
                                        return 0

                                for item in targetPlatformsOrg:
                                        targetPlatformToEnable = targetPlatform()
                                        targetPlatformToEnable = item
                                        targetPlatformToEnable.active = True
                                        targetPlatformToEnable.access = True
                                        printer.out("Enabling ["+item.name+"].")
                                        targetPlatformsList.targetPlatforms.append(targetPlatformToEnable)

                                result = self.api.Users(doArgs.account).Targetplatforms.Update(Org=org.name,body=targetPlatformsList)
                                result =generics_utils.order_list_object_by(result.targetPlatforms.targetPlatform, "name")

                                table = Texttable(200)
                                table.set_cols_align(["c", "c", "c", "c"])
                                table.header(["Id", "Name", "Type", "Access"])

                                for item in result:
                                        if item.access:
                                                access = "X"
                                        else:
                                                access = ""
                                        table.add_row([item.dbId, item.name, item.type, access])

                                printer.out("Target Platform list for user \""+doArgs.account+"\" :")
                                print table.draw() + "\n"
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_enable()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:59,代码来源:user_targetPlatform.py


示例13: do_images

        def do_images(self, args):
                try:
                        doParser = self.arg_images()
                        doArgs = doParser.parse_args(shlex.split(args))

                        printer.out("Getting images list...")
                        allImages = self.api.Users(doArgs.account).Appliances(doArgs.id).Images.Getall()

                        appliancesList = self.api.Users(doArgs.account).Appliances.Getall()
                        appliancesList = appliancesList.appliances.appliance

                        if allImages is None or len(allImages.images.image) == 0:
                                printer.out("No images found for user [" + doArgs.account + "].")
                                return 0

                        allImages = generics_utils.order_list_object_by(allImages.images.image, "name")

                        if doArgs.name is not None:
                                allImages = compare(allImages, doArgs.name, "name")
                        if doArgs.format is not None:
                                allImages = compare(allImages, doArgs.format, "format", "name")
                        if doArgs.os is not None:
                                allImages = compare(list=allImages, values=doArgs.os, attrName='distributionName', subattrName=None, otherList=appliancesList, linkProperties=['applianceUri', 'uri'])

                        if allImages is None or len(allImages) == 0:
                                printer.out("No images found for user [" + doArgs.account + "] with these filters.")
                                return 0

                        printer.out("Images list :")
                        table = Texttable(200)
                        table.set_cols_align(["l", "l", "l", "l", "l", "l", "l", "l", "l", "l"])
                        table.header(["ID", "Name", "Version", "Rev", "OS", "Format", "Created", "Size", "Compressed", "Status"])
                        for image in allImages:
                                created = image.created.strftime("%Y-%m-%d %H:%M:%S")
                                if image.compress:
                                        compressed = "X"
                                else:
                                        compressed = ""
                                if image.status.error:
                                        status = "Error"
                                elif image.status.cancelled:
                                        status = "Cancelled"
                                elif image.status.complete:
                                        status = "Done"
                                else:
                                        status = "Generating"
                                appliance = self.api.Users(doArgs.account).Appliances(doArgs.id).Get()
                                osImage = appliance.distributionName + " " + appliance.archName
                                table.add_row([image.dbId, image.name, image.version, image.revision, osImage, image.format.name, created, size(image.size), compressed, status])
                        print table.draw() + "\n"

                        printer.out("Found " + str(len(allImages)) + " images.")
                        return 0

                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_images()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:hugo6,项目名称:uforge-cli,代码行数:59,代码来源:template.py


示例14: do_modify

        def do_modify(self, args):
                try:
                        doParser = self.arg_modify()
                        doArgs = doParser.parse_args(shlex.split(args))

                        if not doArgs.unlimited and doArgs.limit is None and doArgs.nb is None:
                                printer.out("You must specify a modification (unlimited|limit|nb).", printer.ERROR)
                                return 0
                        printer.out("Getting quotas for ["+doArgs.account+"] ...")
                        quotas = self.api.Users(doArgs.account).Quotas.Get()

                        if quotas is None or len(quotas.quotas.quota) == 0 :
                                printer.out("No quotas available for ["+doArgs.account+"].", printer.ERROR)
                        else:
                                typeExist = False
                                for item in quotas.quotas.quota:
                                        if item.type == doArgs.type:
                                                typeExist = True
                                                if doArgs.nb is not None:
                                                        item.nb = doArgs.nb
                                                if doArgs.unlimited and doArgs.limit is None:
                                                        item.limit = -1
                                                elif doArgs.limit is not None and not doArgs.unlimited:
                                                        item.limit = doArgs.limit
                                                elif doArgs.limit is not None and doArgs.unlimited:
                                                        printer.out("You can't set a defined limit and on the other hand set an unlimited limit.", printer.ERROR)
                                                        return 2

                                if not typeExist:
                                        printer.out("Type is not defined or correct.", printer.ERROR)
                                        return 2
                                else:
                                        quotas = self.api.Users(doArgs.account).Quotas.Update(body=quotas)
                                        printer.out("Changes done.", printer.OK)

                                        quotas = generics_utils.order_list_object_by(quotas.quotas.quota, "type")
                                        table = Texttable(200)
                                        table.set_cols_align(["c", "c", "c"])
                                        table.header(["Type", "Consumed", "Limit"])
                                        for item in quotas:
                                                if item.limit == -1:
                                                        limit = "unlimited"
                                                else:
                                                        limit = item.limit
                                                if item.nb > 1:
                                                        name = item.type+"s"
                                                else:
                                                        name = item.type
                                                table.add_row([name, item.nb, limit])
                                        print table.draw() + "\n"
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_modify()
                        return 0
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:58,代码来源:user_quota.py


示例15: scan_table

def scan_table(scanInstances, scan = None):
    table = Texttable(800)
    table.set_cols_dtype(["t","t","t","t"])
    table.header(["Id", "Name", "Status", "Distribution"])
    if scan:
        table.add_row([scan.dbId, "\t"+scan.name, scan_status(scan), "" ])
        return table
    for myScannedInstance in scanInstances:
        table.add_row([myScannedInstance.dbId, myScannedInstance.name, "", myScannedInstance.distribution.name + " "+ myScannedInstance.distribution.version + " " + myScannedInstance.distribution.arch])
        scans = generics_utils.order_list_object_by(myScannedInstance.scans.scan, "name")
        for lscan in scans:
            table.add_row([lscan.dbId, "\t"+lscan.name, scan_status(lscan), "" ])
    return table
开发者ID:DimitriSCOLE,项目名称:hammr,代码行数:13,代码来源:scan_utils.py


示例16: do_listTargetFormat

        def do_listTargetFormat(self, args):
                try:
                        doParser = self.arg_listTargetFormat()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        if org is None:
                                printer.out("There is no organization matching ["+doArgs.org+"].", printer.OK)
                                return 0

                        printer.out("Getting target platform with id ["+doArgs.id+"] for ["+org.name+"] . . .")
                        targetPlatform = self.api.Orgs(org.dbId).Targetplatforms(doArgs.id).Get()
                        if targetPlatform is None:
                                printer.out("TargetPlatform with id "+ doArgs.id +" does not exist", printer.ERROR)
                                return 2
                        else:
                                printer.out("Getting target format list for target platform ["+targetPlatform.name+"] . . .")
                                allTargetFormats = self.api.Orgs(org.dbId).Targetplatforms(targetPlatform.dbId).Targetformats.Getalltargetformats()
                                allTargetFormats = order_list_object_by(allTargetFormats.targetFormats.targetFormat, "name")

                                if len(allTargetFormats) == 0:
                                        printer.out("There is no target formats in target platform ["+targetPlatform.name+"].", printer.OK)
                                        return 0

                        printer.out("Found "+str(len(allTargetFormats))+" target formats in target platform ["+targetPlatform.name+"].", printer.OK)
                        table = Texttable(200)
                        table.set_cols_align(["c", "l", "l", "l", "l", "l", "c"])
                        table.header(["Id", "Name", "Format", "Category", "Type", "CredAccountType", "Access"])

                        for item in allTargetFormats:
                                if item.access:
                                        access = "X"
                                else:
                                        access = ""
                                if item.credAccountType is None:
                                        credAccountType = ""
                                else:
                                        credAccountType = item.credAccountType
                                table.add_row([item.dbId, item.name, item.format.name, item.category.name, item.type, credAccountType, access])

                        print table.draw() + "\n"
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_listTargetFormat()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:48,代码来源:org_targetPlatform.py


示例17: do_list

    def do_list(self, args):
        try:
            printer.out("Getting all deployments for [" + self.login + "] ...")
            deployments = self.api.Users(self.login).Deployments.Getall()
            deployments = deployments.deployments.deployment

            if deployments is None or len(deployments) == 0:
                printer.out("No deployment available")
            else:
                printer.out("Deployments:")
                table = print_deploy_header()
                deployments = generics_utils.order_list_object_by(deployments, "name")
                for deployment in deployments:
                    deployment_id = deployment.applicationId
                    deployment_name = deployment.name
                    deployment_status = deployment.state
                    instances = deployment.instances.instance
                    instance = instances[-1]
                    source_type = source_id = source_name = hostname = location = cloud_provider = str(None)
                    if instance:
                        if instance.sourceSummary and type(instance.sourceSummary) == ScanSummaryLight:
                            source_type = "Scan"
                            source_id = str(extract_scannedinstance_id(instance.sourceSummary.uri))
                            source_name = instance.sourceSummary.name
                        elif ins 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python generics_utils.query_yes_no函数代码示例发布时间:2022-05-27
下一篇:
Python argumentParser.ArgumentParser类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap