本文整理汇总了Python中User.list_users方法的典型用法代码示例。如果您正苦于以下问题:Python User.list_users方法的具体用法?Python User.list_users怎么用?Python User.list_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.list_users方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: command
# 需要导入模块: import User [as 别名]
# 或者: from User import list_users [as 别名]
def command(self, c):
c = c.strip()
if c == "help":
print("""Welcome to the Key Server Admin!
** [Verb] [Type] [Optional Param] **
Verbs:
- List = List out all the specified TYPE
ex. list app
- Create = Create a new TYPE
ex. create user
- Update = Update a TYPE, the item to modify is
specified as an additional parameter
ex. update app test
- Delete = Delete a TYPE, the item to delete is
specified as an additional parameter
ex. delete param url
Types:
- app = Applications - Act like folders for Parameters
- key = API Key - used by clients to fetch params
- param = Parameter, requires an app to be selected
- user = Admin User
** select [App_Name] **
Select allows you to select an application to work with.
This is required when you want to modify parameters.
** exit **
If an app is currently selected, goes back to home.
If no app is currently selected, quits the admin CLI
** help **
Lists this help info""")
elif c.lower().__contains__("select"):
try:
target_app = c.split(" ")[1]
except IndexError:
print("Invalid select condition - please specify which app you want to select")
return
if target_app in App.list_apps(self.username, self.password):
CLI.current_app = target_app
else:
print("That is not a valid app name, type 'list apps' to see all the current apps.")
elif c.lower().__contains__("list"):
try:
list_item = c.lower().split(" ")[1]
except IndexError:
print("Invalid list condition - please specify what you want to list")
return
if list_item.__contains__("-h") or list_item.__contains__("help"):
print("""List allows you to list out different applications, keys, users, and parameters.
** list [type] **
type `help` to list out all the types and their roles
In order to list parameters, an application needs to be selected.""")
elif list_item.__contains__("users"):
for u in User.list_users(self.username, self.password):
print("\t%s (%s)" % (u['username'], u['email']))
elif list_item.__contains__("apps"):
for a in App.list_apps(self.username, self.password):
print("\t" + a)
elif list_item.__contains__("key"):
for k in Key.list_keys(self.username, self.password):
print ("\t%s (%s)\n"
"\t\t Permissions: %s" % (k["application_name"], k["application_key"], k["permissions"]))
elif list_item.__contains__("param"):
if CLI.current_app == "":
print("Cannot list params when no app is selected")
else:
for p in Param.list_params(self.username, self.password, CLI.current_app):
print("\t%s = %s" % (p['name'], p['value']))
else:
print("Unknown List Command - type `list -h` or `list help` for help.")
elif c.lower().__contains__("create"):
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
#.........这里部分代码省略.........