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

Python utils.get_name函数代码示例

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

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



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

示例1: test_get_name

    def test_get_name(self):
        nm = utils.random_name()

        class ObjWithName(object):
            name = nm

        obj = ObjWithName()
        self.assertEqual(utils.get_name(obj), nm)
        self.assertEqual(utils.get_name(obj.name), nm)
        self.assertRaises(exc.MissingName, utils.get_name, object())
开发者ID:naterh,项目名称:pyrax,代码行数:10,代码来源:test_utils.py


示例2: delete_user

 def delete_user(self, user):
     """
     Deletes the specified user. If no user by that name
     exists, no exception will be raised; instead, nothing at all
     is done.
     """
     name = utils.get_name(user)
     self._user_manager.delete(name)
开发者ID:216software,项目名称:pyrax,代码行数:8,代码来源:clouddatabases.py


示例3: delete_database

 def delete_database(self, name_or_obj):
     """
     Deletes the specified database. If no database by that name
     exists, no exception will be raised; instead, nothing at all
     is done.
     """
     name = utils.get_name(name_or_obj)
     self._database_manager.delete(name)
开发者ID:216software,项目名称:pyrax,代码行数:8,代码来源:clouddatabases.py


示例4: _get_db_names

 def _get_db_names(self, dbs, strict=True):
     """
     Accepts a single db (name or object) or a list of dbs, and returns a
     list of database names. If any of the supplied dbs do not exist, a
     NoSuchDatabase exception will be raised, unless you pass strict=False.
     """
     dbs = utils.coerce_string_to_list(dbs)
     db_names = [utils.get_name(db) for db in dbs]
     if strict:
         good_dbs = self.instance.list_databases()
         good_names = [utils.get_name(good_db) for good_db in good_dbs]
         bad_names = [db_name for db_name in db_names
                 if db_name not in good_names]
         if bad_names:
             bad = ", ".join(bad_names)
             raise exc.NoSuchDatabase("The following database(s) were not "
                     "found: %s" % bad)
     return db_names
开发者ID:216software,项目名称:pyrax,代码行数:18,代码来源:clouddatabases.py


示例5: _create_body

 def _create_body(self, name, img=None, cont=None, img_format=None, img_name=None):
     """
     Used to create a new task. Since tasks don't have names, the required
     'name' parameter is used for the type of task: 'import' or 'export'.
     """
     img = utils.get_id(img)
     cont = utils.get_name(cont)
     body = {"type": name}
     if name == "export":
         body["input"] = {"image_uuid": img, "receiving_swift_container": cont}
     else:
         nm = "%s/%s" % (cont, utils.get_name(img))
         body["input"] = {
             "image_properties": {"name": img_name or img},
             "import_from": nm,
             "import_from_format": img_format or DEFAULT_FORMAT,
         }
     return body
开发者ID:coreypobrien,项目名称:pyrax,代码行数:18,代码来源:image.py


示例6: revoke_user_access

    def revoke_user_access(self, user, db_names, strict=True):
        """
        Revokes access to the databases listed in `db_names` for the user.

        If any of the databases do not exist, a NoSuchDatabase exception will
        be raised, unless you specify `strict=False` in the call.
        """
        user = utils.get_name(user)
        db_names = self._get_db_names(db_names, strict=strict)
        bad_names = []
        for db_name in db_names:
            uri = "/%s/%s/databases/%s" % (self.uri_base, user, db_name)
            resp, resp_body = self.api.method_delete(uri)
开发者ID:216software,项目名称:pyrax,代码行数:13,代码来源:clouddatabases.py


示例7: list_user_access

 def list_user_access(self, user):
     """
     Returns a list of all database names for which the specified user
     has access rights.
     """
     user = utils.get_name(user)
     uri = "/%s/%s/databases" % (self.uri_base, user)
     try:
         resp, resp_body = self.api.method_get(uri)
     except exc.NotFound as e:
         raise exc.NoSuchDatabaseUser("User '%s' does not exist." % user)
     dbs = resp_body.get("databases", {})
     return [CloudDatabaseDatabase(self, db) for db in dbs]
开发者ID:216software,项目名称:pyrax,代码行数:13,代码来源:clouddatabases.py


示例8: change_user_password

    def change_user_password(self, user, new_pass):
        """
        Changes the password for the user to the supplied value.

        Returns None upon success; raises PasswordChangeFailed if the call
        does not complete successfully.
        """
        user = utils.get_name(user)
        body = {"users": [{"name": user, "password": new_pass}]}
        uri = "/%s" % self.uri_base
        resp, resp_body = self.api.method_put(uri, body=body)
        if resp.status > 299:
            raise exc.PasswordChangeFailed("Password for '%s' was not changed"
                    % user)
        return None
开发者ID:216software,项目名称:pyrax,代码行数:15,代码来源:clouddatabases.py


示例9: grant_user_access

    def grant_user_access(self, user, db_names, strict=True):
        """
        Gives access to the databases listed in `db_names` to the user. You may
        pass in either a single db or a list of dbs.

        If any of the databases do not exist, a NoSuchDatabase exception will
        be raised, unless you specify `strict=False` in the call.
        """
        user = utils.get_name(user)
        uri = "/%s/%s/databases" % (self.uri_base, user)
        db_names = self._get_db_names(db_names, strict=strict)
        dbs = [{"name": db_name} for db_name in db_names]
        body = {"databases": dbs}
        try:
            resp, resp_body = self.api.method_put(uri, body=body)
        except exc.NotFound as e:
            raise exc.NoSuchDatabaseUser("User '%s' does not exist." % user)
开发者ID:216software,项目名称:pyrax,代码行数:17,代码来源:clouddatabases.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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