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


Python User.create_new方法代码示例

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


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

示例1: command

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

#.........这里部分代码省略.........
            try:
                create_item = c.lower().split(" ")[1]
            except IndexError:
                print("Invalid create condition - please specify what you want to create")
                return

            if create_item.__contains__("-h") or create_item.__contains__("help"):
                print("""Create allows you to create new applications, keys, users, and parameters

** create [type] **
type `help` to list out all the types and their roles

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

            elif create_item.__contains__("user"):
                while True:
                    username = raw_input("\tUsername: ").strip()
                    password = None

                    while True:
                        password = getpass.getpass("\tPassword: ")
                        password_conf = getpass.getpass("\tConfirm Password: ")
                        if password == password_conf:
                            break
                        else:
                            print("Passwords do not match. Try Again.")

                    email = raw_input("\tEmail: ").strip()

                    conf = raw_input("\n\tUsername: %s\n\tPassword: %s\n\tEmail: %s\n\tIs this correct [Y/n]" %
                                     (username, password, email)).strip()

                    if conf.lower() == "y" or conf == "":
                        user = User.create_new(self.username, self.password, username, password, email)
                        print("Created New User: %s" % user["username"])

                        break

            elif create_item.__contains__("app"):
                while True:
                    app_name = raw_input("\tApplication Name: ").strip()

                    conf = raw_input("\n\tApplication Name: %s\n\tIs this correct [Y/n]" % app_name).strip()
                    if conf.lower() == "y" or conf == "":
                        app = App.create_app(self.username, self.password, app_name)
                        print("Created New App: %s" % app["name"])

                        break

            elif create_item.__contains__("key"):
                while True:
                    application_name = raw_input("\tApplication Name: ").strip()
                    print("\tIn case you need a refresher... Application permissions are as follows:\n"
                          "\t\t* use +app_name to whitelist the key for that app\n"
                          "\t\t* use -app_name to blacklist the key for that app\n"
                          "\t\t* use NO to revoke the key\n"
                          "\t\t* or use ALL to grant the key access to all apps")
                    permissions = raw_input("\tApplication Permissions: ").strip()
                    if permissions == "":
                        permissions = "ALL"

                    conf = raw_input("\n\tName: %s\n\tPermissions: %s\n\tIs this correct [Y/n]" % (
                        application_name, permissions)).strip()

                    if conf.lower() == "y" or conf == "":
                        key = Key.create_key(self.username, self.password, application_name, permissions)
开发者ID:sdsu-its,项目名称:key-server-admin,代码行数:70,代码来源:CLI.py


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