当前位置: 首页>>代码示例>>Python>>正文


Python User.delete_user方法代码示例

本文整理汇总了Python中User.delete_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.delete_user方法的具体用法?Python User.delete_user怎么用?Python User.delete_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


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

示例1: command

# 需要导入模块: import User [as 别名]
# 或者: from User import delete_user [as 别名]

#.........这里部分代码省略.........
                                             permissions=permissions)
                        print("Updated Key: %s" % key['application_key'])

                        break

            elif update_item.__contains__("param"):
                if CLI.current_app == "":
                    print("Cannot update param when no app is selected")
                else:
                    while True:
                        param_value = raw_input("\tNew Value Value: ").strip()

                        conf = raw_input("\n\tParameter Value: %s\n\tIs this correct [Y/n]" % param_value).strip()

                        if conf.lower() == "y" or conf == "":
                            param = Param.update_param(self.username, self.password, CLI.current_app, update_item_name,
                                                       param_value)
                            print("Updated Parameter: %s" % param["name"])

                            break
            else:
                print("Unknown Update Command - type `update -h` or `update help` for help.")

        elif c.lower().__contains__("delete"):
            try:
                delete_item = c.lower().split(" ")[1]
            except IndexError:
                print("Invalid delete condition - please specify what you want to delete")
                return

            try:
                delete_item_name = c.split(" ")[2]
            except IndexError:
                print("Invalid delete condition - please specify which %s you want to delete." % delete_item)
                return

            if delete_item.__contains__("-h") or delete_item.__contains__("help"):
                print("""Delete allows you to remove applications, users, and parameters.
Delete revokes keys, which is the only delete action that can be undone; to
reactivate a revoked key, update the permissions of the key.

** update [type] [username/applicationName/applicationKey/parameterName]**
type `help` to list out all the types and their roles

In order to create parameters, an application needs to be selected.""")

            elif delete_item.__contains__("user"):
                conf = raw_input("\n\tUsername to remove: %s\n\tIs this correct [Y/n]" % delete_item_name).strip()

                if conf.lower() == "y" or conf == "":
                    status = User.delete_user(self.username, self.password, delete_item_name)
                    if status:
                        print("User was deleted Successfully")
                    else:
                        print("Problem deleting user, check server logs for details")

            elif delete_item.__contains__("app"):
                conf = raw_input("\n\tApplication to remove: %s\n\tIs this correct [Y/n]" % delete_item_name).strip()

                if conf.lower() == "y" or conf == "":
                    status = App.delete_app(self.username, self.password, delete_item_name)
                    if status:
                        print("App was deleted Successfully")
                    else:
                        print("Problem deleting app, check server logs for details")

            elif delete_item.__contains__("key"):
                conf = raw_input("\n\tKey to remove: %s\n\tIs this correct [Y/n]" % delete_item_name).strip()

                if conf.lower() == "y" or conf == "":
                    status = Key.delete_key(self.username, self.password, delete_item_name)
                    if status:
                        print("Key was Revoked Successfully - to reactivate the Key, update its permissions")
                    else:
                        print("Problem revoking key, check server logs for details")

            elif delete_item.__contains__("param"):
                if CLI.current_app == "":
                    print("Cannot delete param when no app is selected")
                else:
                    conf = raw_input("\n\tParam to remove: %s\n\tIs this correct [Y/n]" % delete_item_name).strip()

                    if conf.lower() == "y" or conf == "":
                        status = Param.delete_param(self.username, self.password, CLI.current_app, delete_item_name)
                        if status:
                            print("Param was deleted Successfully")
                        else:
                            print("Problem deleting param, check server logs for details")

            else:
                print("Unknown Delete Command - type `delete -h` or `delete help` for help.")

        elif c.lower().__contains__("exit"):
            if CLI.current_app == "":
                exit(0)
            else:
                CLI.current_app = ""

        else:
            print("Command not recognized")
开发者ID:sdsu-its,项目名称:key-server-admin,代码行数:104,代码来源:CLI.py


注:本文中的User.delete_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。