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

Python org_utils.org_get函数代码示例

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

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



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

示例1: do_list

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

                        allUsergrp = self.api.Usergroups.Getall(Name=org.name)

                        if allUsergrp is None:
                                printer.out("No user groups found.")
                                return 0

                        allUsergrp = allUsergrp.userGroups.userGroup

                        table = Texttable(200)
                        table.set_cols_align(["l", "r"])
                        table.header(["Name", "# Members"])
                        for item in allUsergrp:
                                table.add_row([item.admin.name, str(len(item.members.member))])
                        print table.draw() + "\n"

                        printer.out("Found " + str(len(allUsergrp)) + " user group in [" + org.name + "].")

                        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,代码行数:30,代码来源:usergrp.py


示例2: do_delete

        def do_delete(self, args):
                try:
                        doParser = self.arg_delete()
                        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:
                                result = self.api.Orgs(org.dbId).Targetplatforms(doArgs.id).Delete()
                                printer.out("Target Platform ["+targetPlatform.name+"] has successfully been deleted.", printer.OK)

                        return 0

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


示例3: do_create

        def do_create(self, args):
                try:
                        doParser = self.arg_create()
                        doArgs = doParser.parse_args(shlex.split(args))
                        org = org_get(self.api, doArgs.org)

                        newUsergrp = userGroup()
                        newUser = user()
                        newUser.loginName = doArgs.name
                        newUser.email = doArgs.email
                        newUser.password = doArgs.usergrpPassword
                        newUsergrp.admin = newUser

                        newUsergrp.members = pyxb.BIND()
                        if doArgs.accounts is not None:
                                for item in doArgs.accounts:
                                        addNewUser = user()
                                        addNewUser.loginName = item
                                        newUsergrp.members.append(addNewUser)
                                        printer.out("[" + addNewUser.loginName + "] has been added to user group.")

                        result = self.api.Usergroups.Create(Org=org.name,body=newUsergrp)
                        printer.out("User group [" + newUser.loginName + "] has been successfully created", printer.OK)
                        return 0

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


示例4: do_delete

        def do_delete(self, args):
                try:
                        doParser = self.arg_delete()
                        doArgs = doParser.parse_args(shlex.split(args))
                        org = org_get(self.api, doArgs.org)

                        allUsergrp = self.api.Usergroups.Getall(Name=org.name)

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

                        allUsergrp = allUsergrp.userGroups.userGroup
                        for item in allUsergrp:
                                if item.admin.name == doArgs.name:
                                        result = self.api.Usergroups(item.dbId).Delete()
                                        printer.out("[" + item.admin.name + "] has been successfully deleted.", printer.OK)
                                        return 0

                        printer.out("[" + doArgs.name + "] was not found in [" + org.name + "].")

                        return 0

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


示例5: do_create

        def do_create(self, args):
                try:
                        doParser = self.arg_create()
                        doArgs = doParser.parse_args(shlex.split(args))

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

                        for item in allRepo:
                                if doArgs.repoUrl == item.url:
                                        printer.out("The repository with URL [" + item.url + "] already exist in [" + org.name + "].", printer.ERROR)
                                        return 0

                        newRepository = repository()
                        newRepository.url = doArgs.repoUrl
                        newRepository.packagingType = doArgs.type
                        newRepository.name = doArgs.name
                        newRepository.officiallySupported = doArgs.officiallySupported

                        result = self.api.Orgs(org.dbId).Repositories.Create(body=newRepository)
                        printer.out("Successfully created repository with URL [" + doArgs.repoUrl + "] in [" + org.name + "].", printer.OK)
                        return 0

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


示例6: do_disable

        def do_disable(self, args):
                try:
                        doParser = self.arg_enable()
                        doArgs = doParser.parse_args(shlex.split(args))

                        printer.out("Getting subscription profile with name [" + doArgs.name + "]...")
                        org = org_utils.org_get(self.api, doArgs.org)
                        subscriptions = self.api.Orgs(org.dbId).Subscriptions().Getall(Search=doArgs.name)

                        exist = False
                        for item in subscriptions.subscriptionProfiles.subscriptionProfile:
                                if item.name == doArgs.name:
                                        exist = True
                                        updated_subscription = subscriptionProfile()
                                        updated_subscription.name = item.name
                                        updated_subscription.code = item.code
                                        if item.active:
                                                updated_subscription.active = False
                                                printer.out("Disabling subscription profile with name [" + doArgs.name + "] ...")
                                                # call UForge API
                                                self.api.Orgs(org.dbId).Subscriptions(item.dbId).Update(updated_subscription)
                                                printer.out("Subscription [" + doArgs.name + "] is disabled.", printer.OK)
                                        else:
                                                printer.out("Subscription [" + doArgs.name + "] is already disabled", printer.WARNING)
                        if not exist:
                                printer.out("Subscription profile requested don't exist in [" + org.name + "]")
                                return 0
                        return 0

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


示例7: do_create

        def do_create(self, args):
                try:
                        doParser = self.arg_create()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        allCategory = self.api.Orgs(org.dbId).Categories.Getall()
                        allCategory = allCategory.categories.category

                        Exist = False
                        for item in allCategory:
                                if doArgs.name == item.name:
                                        Exist = True
                                        printer.out("A category already have the name ["+doArgs.name+"].", printer.ERROR)
                                        return 0

                        if not Exist:
                                newCategory = category()
                                newCategory.name = doArgs.name
                                newCategory.type = doArgs.type

                                result = self.api.Orgs(org.dbId).Categories.Create(body=newCategory)
                                printer.out("Category ["+newCategory.name+"] has successfully been created.", printer.OK)

                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_create()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:31,代码来源:org_category.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)

                        # 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


示例9: do_delete

        def do_delete(self, args):
                try:
                        doParser = self.arg_delete()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        allCategory = self.api.Orgs(org.dbId).Categories.Getall()
                        allCategory = allCategory.categories.category

                        deleteList = []
                        if doArgs.name is not None:
                                for arg1 in doArgs.name:
                                        for item in allCategory:
                                                if arg1 == item.name:
                                                        deleteList.append(item)
                                                        break
                        if doArgs.ids is not None:
                                for arg2 in doArgs.ids:
                                        for item2 in allCategory:
                                                if long(arg2) == item2.dbId:
                                                        deleteList.append(item2)
                                                        break

                        for item3 in deleteList:
                                result = self.api.Orgs(org.dbId).Categories.Delete(Id=item3.dbId)
                                printer.out("Category ["+item3.name+"] has been deleted.", printer.OK)
                        return 0

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


示例10: 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


示例11: do_create

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

                        printer.out("Creating role [" + doArgs.name + "] ...")
                        org = org_utils.org_get(self.api, doArgs.org)

                        new_role = role()
                        new_role.name = doArgs.name
                        if doArgs.description:
                                new_role.description = doArgs.description
                        if doArgs.entitlements:
                                if doArgs.entitlements is not None:
                                        new_role.entitlements = pyxb.BIND()
                                        entList = self.api.Entitlements.Getall()
                                        entList = entList.entitlements.entitlement
                                        entList = compare(entList, doArgs.entitlements, "name")
                                        for ent in entList:
                                                add_entitlement = entitlement()
                                                add_entitlement.name = ent.name
                                                add_entitlement.description = ent.description
                                                new_role.entitlements.append(add_entitlement)
                                                printer.out("Entitlement " + ent.name + " added to the role")

                        self.api.Orgs(org.dbId).Roles().Create(new_role)
                        printer.out("Role [" + new_role.name + "] was correctly created", printer.OK)
                        return 0
                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_create()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:34,代码来源:role.py


示例12: 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


示例13: do_create

        def do_create(self, args):
                try:
                        doParser = self.arg_create()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        allDist = self.api.Orgs(org.dbId).Distributions.Getall()
                        allDist = allDist.distributions.distribution

                        goldenId = None
                        for distrib in allDist:
                                if distrib.name == doArgs.name and distrib.version == doArgs.version and distrib.arch == doArgs.arch:
                                        goldenId = distrib.dbId

                        if goldenId is None:
                                printer.out("No distributions found with the arguments entered.")
                                return 0

                        result = self.api.Orgs(org.dbId).Distributions(goldenId).Goldens.Create(Language=doArgs.language, Edition=doArgs.edition, Type=doArgs.type, Goldendate=doArgs.goldenDate, Filename=doArgs.goldenName, body=None)
                        printer.out("Golden image [" + result.name + "] has been created", printer.OK)
                        return 0

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


示例14: do_delete

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

                        printer.out("Deleting subscription profile [" + doArgs.name + "] ...")
                        org = org_utils.org_get(self.api, doArgs.org)

                        # call UForge API
                        subscriptions = self.api.Orgs(org.dbId).Subscriptions().Getall(Search=None)

                        exist = False
                        for item in subscriptions.subscriptionProfiles.subscriptionProfile:
                                if item.name == doArgs.name:
                                        exist = True
                                        subscription = subscriptions.subscriptionProfiles.subscriptionProfile[0]
                                        self.api.Orgs(org.dbId).Subscriptions(subscription.dbId).Remove(None)
                                        printer.out("Subscription profile [" + doArgs.name + "] deleted", printer.OK)

                        if not exist:
                                printer.out("Subscription profile requested don't exist in [" + org.name + "]")
                                return 0
                        return 0

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


示例15: 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


示例16: do_remove

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

                        printer.out("Getting subscription profile with name [" + doArgs.name + "]...")
                        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

                        subscriptions = self.api.Orgs(org.dbId).Subscriptions().Getall(Search=None)

                        exist = False
                        subProfileSelected = None
                        for item in subscriptions.subscriptionProfiles.subscriptionProfile:
                                if item.name == doArgs.name:
                                        subProfileSelected = item
                                        exist = True
                                        all_targetFormats = targetFormats()
                                        all_targetFormats.targetFormats = pyxb.BIND()

                                        newTargetFormats = compare(item.targetFormats.targetFormat, doArgs.targetFormats, "name")

                                        if len(newTargetFormats) == 0:
                                                listName = ""
                                                for tfname in doArgs.targetFormats:
                                                        listName = listName + tfname + " "
                                                printer.out("There is no target formats matching ["+listName+"].")
                                                return 0

                                        for targetFormatItem in item.targetFormats.targetFormat:
                                                for deleteList in newTargetFormats:
                                                        if targetFormatItem.name == deleteList.name:
                                                                already_targetFormat = targetFormat()
                                                                already_targetFormat.access = targetFormatItem.access
                                                                already_targetFormat.active = False
                                                                already_targetFormat.preselected = targetFormatItem.preselected
                                                                already_targetFormat.name = targetFormatItem.name
                                                                already_targetFormat.uri = targetFormatItem.uri
                                                                all_targetFormats.targetFormats.append(already_targetFormat)
                                                                printer.out("Removed target format " + targetFormatItem.name + " for subscription.")

                                        # call UForge API
                                        self.api.Orgs(org.dbId).Subscriptions(subProfileSelected.dbId).Targetformats.Orgsubscriptionprofiletargetformatupdate(Allusers=doArgs.allusers, body=all_targetFormats)
                                        printer.out("Somes target formats removed from subscription profile [" + doArgs.name + "]...", printer.OK)

                        if not exist:
                                printer.out("Subscription profile requested don't exist in [" + org.name + "]")
                        return 0

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


示例17: do_create

        def do_create(self, args):
                try:
                        doParser = self.arg_create()
                        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

                        newTargetFormat = targetFormat()
                        newTargetFormat.name = doArgs.name
                        field = fieldImageFormat
                        format = imageFormat()
                        format.name = doArgs.format
                        newTargetFormat.format = format
                        targetFormatCategory = category()
                        targetFormatCategory.name = doArgs.category
                        targetFormatCategory.type = categoryImageFormat
                        newTargetFormat.category = targetFormatCategory
                        field = fieldType
                        newTargetFormat.type = doArgs.type
                        if doArgs.credAccountType is not None:
                                field = fieldCredAccountType
                                newTargetFormat.credAccountType = doArgs.credAccountType
                        if doArgs.credInfos is not None:
                                newTargetFormat.credInfos = doArgs.credInfos
                        if doArgs.imageInfos is not None:
                                newTargetFormat.imageInfos = doArgs.imageInfos
                        if doArgs.publishInfos is not None:
                                newTargetFormat.publishInfos = doArgs.publishInfos

                        result = self.api.Orgs(org.dbId).Targetformats.Create(body=newTargetFormat)
                        if doArgs.file is not None and result is not None:
                                fileName = os.path.basename(doArgs.file)
                                file = open(doArgs.file, "r")
                                self.api.Orgs(org.dbId).Targetformats(result.dbId).Logo(Logoid=result.logo.dbId, Filename=fileName).Upload(body=file)

                        printer.out("Target Format ["+newTargetFormat.name+"] has successfully been created.", printer.OK)

                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_create()
                except pyxb.SimpleFacetValueError as e:
                        printer.out("Unknown " + field + " ["+str(e.value)+"] for target format." , printer.ERROR)
                        values = None
                        for value in e.type.values():
                                if values is None:
                                        values = value
                                else:
                                        values = values + ", " + value
                        printer.out("Please change for one of these values: " + values, printer.ERROR)
                        return 2
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:57,代码来源:org_targetFormat.py


示例18: do_disable

        def do_disable(self, args):
                try:
                        doParser = self.arg_disable()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_get(api=self.api,name=doArgs.org)
                        printer.out("Getting distributions list for user \""+doArgs.account+"\".")

                        distrosUser = self.api.Users(doArgs.account).Distros.Getall()
                        distrosUser = distrosUser.distributions.distribution

                        distrosUser = compare(distrosUser, doArgs.name, "name")
                        if doArgs.version is not None:
                                distrosUser = compare(distrosUser, doArgs.version, "version")
                        if doArgs.arch is not None:
                                distrosUser = compare(distrosUser, doArgs.arch, "arch")

                        distribs = distributions()
                        distribs.distributions = pyxb.BIND()
                        for item in distrosUser:
                                newDistro = distribution()
                                newDistro = item
                                newDistro.active = False
                                distribs.distributions.append(newDistro)

                        printer.out("Updating distributions list for user \""+doArgs.account+"\" :")
                        returnList = self.api.Users(doArgs.account).Distros.Update(Org=org.name,body=distribs)
                        printer.out("List for user \""+doArgs.account+"\" updated :", printer.OK)

                        table = Texttable(200)
                        table.set_cols_align(["c", "c", "c", "c", "c", "c"])
                        table.header(["Distribution", "Version", "Architecture", "Access", "Visible", "Release Date"])
                        for item in returnList.distributions.distribution:
                                if item.active:
                                        active = "X"
                                else:
                                        active = ""

                                if item.visible:
                                        visible = "X"
                                else:
                                        visible = ""

                                if item.releaseDate is None:
                                        releaseDate = "Unknown"
                                else:
                                        releaseDate = item.releaseDate
                                table.add_row([item.name, item.version, item.arch, active, visible, releaseDate])
                        print table.draw() + "\n"
                        return 0

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


示例19: do_list


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python backend.tr函数代码示例发布时间:2022-05-27
下一篇:
Python test.PerformanceTestReporter类代码示例发布时间: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