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

Python objects.File类代码示例

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

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



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

示例1: test_single_change

    def test_single_change(self): 
        name = "/file/name"
        old_base = "/OLD"
        new_base = "/NEW"
        data = "/etc/group"

        key = old_base + data
        file1 = File.create_file(self.db, name, self.user1, key, pynimbusauthz.object_type_s3)
        self.db.commit()

        rc = pynimbusauthz.rebase.main([old_base, new_base])
        self.assertEqual(rc, 0, "rc should be 0, is %d" % (rc))

        f2a = File.find_files_from_data(self.db, key)
        f2a = list(f2a)
        self.assertEqual(len(f2a), 0, "should be no values with key %s len is %d" % (old_base, len(f2a)))
        key = new_base + data
        f2a = File.find_files_from_data(self.db, key)
        f2a = list(f2a)
        self.assertNotEqual(len(f2a), 0, "length should be greater than 0 is %d" % (len(f2a)))

        found = False
        for f2 in f2a:
            tst_key = f2.get_data_key()
            if tst_key == key:
                found = True
        self.assertTrue(found, "key not found")
开发者ID:Annatara,项目名称:nimbus,代码行数:27,代码来源:test_rebase.py


示例2: main

def main(argv=sys.argv[1:]):
    
    try:
        con_str = pynimbusauthz.get_db_connection_string()
        db_obj = DB(con_str=con_str)

        (opts,args) = setup_options(argv)

        if len(args) > 0:
            u_pattern = args[0]
        else:
            u_pattern = ""
        parent = None
        if opts.parent != None:
            parent = File.get_file(db_obj, opts.parent, opts.type)
            if parent == None:
                raise AuthzException(['FILE_EXISTS'], "parent %s not found" % (opts.parent))

        if opts.type == "all":
            types = pynimbusauthz.object_types.keys()
        else:
            types = [opts.type]

        for t in types:
            files = File.find_files(db_obj, u_pattern, t, parent)

            for f in files:
                print_file(opts, f)

    except AuthzException, ae:
        print ae
        return ae.get_rc()
开发者ID:Annatara,项目名称:nimbus,代码行数:32,代码来源:ls.py


示例3: main

def main(argv=sys.argv[1:]):
    
    try:
        con_str = pynimbusauthz.get_db_connection_string()
        db_obj = DB(con_str=con_str)

        (opts,args) = setup_options(argv)

        if len(args) != 3:
            raise AuthzException('CLI_PARAMETER', "You must specify a username filename permssions")
        user_name = args[0]
        object_name = args[1]
        requested_perms = args[2]

        parent = None
        if opts.parent != None:
            parent = File.get_file(db_obj, opts.parent, opts.type)
            if parent == None:
                raise AuthzException('FILE_EXISTS', "parent %s not found" % (opts.parent))

        file1 = File.get_file(db_obj, object_name, opts.type, parent=parent)
        if file1 == None:
            raise AuthzException('FILE_EXISTS', "file %s:%s not found" % (opts.type, object_name))
        user = User(db_obj, uu=user_name)
        uf = UserFile(file1) # create a uesrfile with owner so we can chmod
        uf.chmod(requested_perms, user=user)
        pynimbusauthz.print_msg(opts, 0, "changed %s to %s for %s" % (str(file1), requested_perms, str(user)))
        db_obj.commit()

    except AuthzException, ae:
        print ae
        return ae.get_rc()
开发者ID:Annatara,项目名称:nimbus,代码行数:32,代码来源:chmod.py


示例4: main

def main(argv=sys.argv[1:]):

    try:
        con_str = pynimbusauthz.get_db_connection_string()
        db_obj = DB(con_str=con_str)

        (opts, args) = setup_options(argv)

        if len(args) != 3:
            raise AuthzException("CLI_PARAMETER", "You must specify a username filename and a datakey\nTry --help")
        user_name = args[0]
        object_name = args[1]
        data = args[2]

        user = User(db_obj, uu=user_name)
        parent = None
        if opts.parent != None:
            parent = File.get_file(db_obj, opts.parent, opts.type)
            if parent == None:
                raise AuthzException("FILE_EXISTS", "parent %s not found" % (opts.parent))
        File.create_file(db_obj, object_name, user, data, opts.type, parent=parent)

    except AuthzException, ae:
        print ae
        return ae.get_rc()
开发者ID:oldpatricka,项目名称:nimbus,代码行数:25,代码来源:touch.py


示例5: get_file_obj

 def get_file_obj(self, bucketName, objectName=None):
     file = File.get_file(self.db_obj, bucketName, pynimbusauthz.object_type_s3)
     if file == None:
         return None
     if objectName != None:
         file = File.get_file(self.db_obj, objectName, pynimbusauthz.object_type_s3, file)
     return file
开发者ID:oldpatricka,项目名称:nimbus,代码行数:7,代码来源:cbAuthzSecurity.py


示例6: test_basic_touch

 def test_basic_touch(self):
     fname = str(uuid.uuid1())
     data = str(uuid.uuid1())
     f = File.get_file(self.db, fname, pynimbusauthz.object_type_s3)
     self.assertEqual(f, None)
     rc = pynimbusauthz.touch.main([self.user1.get_id(), fname, data])
     self.assertEqual(rc, 0, "CLI should return success %d" % (rc))
     f = File.get_file(self.db, fname, pynimbusauthz.object_type_s3)
     self.assertNotEqual(f, None)
开发者ID:Annatara,项目名称:nimbus,代码行数:9,代码来源:test_touch.py


示例7: test_bucket

    def test_bucket(self):
        # create a file and a bucket
        b1 = File.create_file(self.db, "bucket", self.user1, self.data, pynimbusauthz.object_type_s3)
        f2 = File.create_file(self.db, self.name, self.user1, self.data, pynimbusauthz.object_type_s3, parent=b1)
        self.db.commit()

        new_perms = "WR"
        rc = pynimbusauthz.chmod.main(["-t", f2.get_object_type(), "-p", b1.get_name(), self.user1.get_id(), f2.get_name(), new_perms])
        self.assertEqual(rc, 0, "CLI should return success %d" % (rc))
开发者ID:Annatara,项目名称:nimbus,代码行数:9,代码来源:test_chmod.py


示例8: get_file_obj

 def get_file_obj(self, bucketName, objectName=None):
     pycb.log(logging.INFO, "===== def get_file_obj of cbAuthzSecurity.py")
     file = File.get_file(self.db_obj, bucketName, pynimbusauthz.object_type_s3)
     pycb.log(logging.INFO, "=====## file is %s"%file)
     if file == None:
         return None
     if objectName != None:
         file = File.get_file(self.db_obj, objectName, pynimbusauthz.object_type_s3, file)
         pycb.log(logging.INFO, "=====## file is %s"%file)
     return file
开发者ID:xxy-php,项目名称:code,代码行数:10,代码来源:cbAuthzSecurity.py


示例9: test_under_bucket_touch

    def test_under_bucket_touch(self):
        bname = str(uuid.uuid1())
        fname = str(uuid.uuid1())
        data = str(uuid.uuid1())
        rc = pynimbusauthz.touch.main(["-t", pynimbusauthz.object_type_s3, self.user1.get_id(), bname, data])
        self.assertEqual(rc, 0, "CLI should return success %d" % (rc))
        rc = pynimbusauthz.touch.main(["-p", bname, self.user1.get_id(), fname, data])
        self.assertEqual(rc, 0, "CLI should return success %d" % (rc))

        b1 = File.get_file(self.db, bname, pynimbusauthz.object_type_s3)
        f1 = File.get_file(self.db, fname, pynimbusauthz.object_type_s3, parent=b1)

        self.assertNotEqual(b1, None)
        self.assertNotEqual(f1, None)
开发者ID:Annatara,项目名称:nimbus,代码行数:14,代码来源:test_touch.py


示例10: test_find_by_key

    def test_find_by_key(self):
        user1 = User(self.db)
        name = "/file/name"
        key = "/old/path/base"
        f = File.create_file(self.db, name, user1, key, pynimbusauthz.object_type_s3)
        self.db.commit()

        f2a = File.find_files_from_data(self.db, key)

        found = False
        for f2 in f2a:
            tst_key = f2.get_data_key()
            if tst_key == key:
                found = True
        self.assertTrue(found, "key not found")
开发者ID:ketancmaheshwari,项目名称:nimbus,代码行数:15,代码来源:file_test.py


示例11: validate_perms

 def validate_perms(self, new):
     f = File.get_file_from_db_id(self.db, self.file1.get_id())
     uf = UserFile(f, self.user1)
     perms = uf.get_perms(force=True)
     for p in new:
         self.assertTrue(p in perms, "bad perms set %s != %s" % (new, perms))
     self.assertEqual(len(perms), len(new), "perms dont match %s != %s" % (new, perms))
开发者ID:Annatara,项目名称:nimbus,代码行数:7,代码来源:test_chmod.py


示例12: get_my_buckets

 def get_my_buckets(self):
     try:
         file_iterater = File.get_user_files(self.db_obj, self.user, root=True)
         new_it = itertools.imap(lambda r: _convert_bucket_to_cbObject(self, r), file_iterater)
         return list(new_it)
     finally:
         self.db_obj.commit()
开发者ID:oldpatricka,项目名称:nimbus,代码行数:7,代码来源:cbAuthzSecurity.py


示例13: list_bucket

    def list_bucket(self, bucketName, args):

        clause = " ORDER BY name"
        prefix = None
        if 'prefix' in args:
            prefix = args['prefix'][0]
            prefix = "%s%%" % (prefix)

        limit = None
        if 'max-keys' in args:
            max_a = args['max-keys']
            limit = int(max_a[0])

        if 'delimiter' in args:
            pass
        if 'key-marker' in args:
            km = args['key-marker'][0]
            clause = " and name > '%s'" % (km)

        try:
            bucket = File.get_file(self.db_obj, bucketName, pynimbusauthz.alias_type_s3)
            iter = bucket.get_all_children(limit=limit, match_str=prefix, clause=clause)
            new_it = itertools.imap(lambda r: _convert_File_to_cbObject(self, r), iter)
            return list(new_it)
        finally:
            self.db_obj.commit()
开发者ID:oldpatricka,项目名称:nimbus,代码行数:26,代码来源:cbAuthzSecurity.py


示例14: get_my_buckets

 def get_my_buckets(self):
     pycb.log(logging.INFO, "===== def get_my_buckets of cbAuthzSecurity.py")
     try:
         file_iterater = File.get_user_files(self.db_obj, self.user, root=True)
         new_it = itertools.imap(lambda r: _convert_bucket_to_cbObject(self, r), file_iterater)
         return list(new_it)
     finally:
         self.db_obj.commit()
开发者ID:xxy-php,项目名称:code,代码行数:8,代码来源:cbAuthzSecurity.py


示例15: main

def main(argv=sys.argv[1:]):

    try:
        repo_dir = argv[0]
        con_str = pynimbusauthz.get_db_connection_string()
        db_obj = DB(con_str=con_str)

        user = User(db_obj, uu="CumulusPublicUser")
        if user == None:
            raise Exception("No public user")

        File.create_file(db_obj, repo_dir, user, repo_dir, pynimbusauthz.alias_type_s3)
        db_obj.commit()
    except:
        raise

    return 0
开发者ID:pauloricardomg,项目名称:nimbus,代码行数:17,代码来源:base_repo.py


示例16: test_file_and_bucket

    def test_file_and_bucket(self):
        user1 = User(self.db)
        fname = "NAME"
        data = "data"
        b1 = File.create_file(self.db, "bucket", user1, data, pynimbusauthz.object_type_s3)
        f1 = File.create_file(self.db, fname, user1, data, pynimbusauthz.object_type_s3, parent=b1)
        f2 = File.create_file(self.db, fname, user1, data, pynimbusauthz.object_type_s3)
        self.db.commit()

        self.assertNotEqual(f1.get_id(), f2.get_id())

        f3 = File.get_file(self.db, fname, pynimbusauthz.object_type_s3, parent=b1)
        f4 = File.get_file(self.db, fname, pynimbusauthz.object_type_s3)
        self.assertEqual(f1.get_id(), f3.get_id())
        self.assertEqual(f2.get_id(), f4.get_id())
        self.assertNotEqual(f3.get_id(), f4.get_id())
        self.db.commit()
开发者ID:ketancmaheshwari,项目名称:nimbus,代码行数:17,代码来源:file_test.py


示例17: test_many_change

    def test_many_change(self):
        name = "/file/name"
        old_base = "/OLD"
        new_base = "/NEW"
        count = 10

        for i in range(0, count): 
            keyname = str(uuid.uuid1())
            oldkey = old_base + "/" + keyname
            File.create_file(self.db, name+oldkey, self.user1, oldkey, pynimbusauthz.object_type_s3)
        self.db.commit()

        rc = pynimbusauthz.rebase.main([old_base, new_base])
        self.assertEqual(rc, 0, "rc should be 0, is %d" % (rc))

        f2a = File.find_files_from_data(self.db, new_base + "%")
        f2a = list(f2a)
        self.assertEqual(len(f2a), count, "length of the new items should be %d is %s" % (count, len(f2a)))
开发者ID:Annatara,项目名称:nimbus,代码行数:18,代码来源:test_rebase.py


示例18: setUp

    def setUp(self):
#        os.environ['CUMULUS_AUTHZ_DDL'] = "/home/bresnaha/Dev/Nimbus/nimbus/cumulus/authz/etc/acl.sql"
        con = pynimbusauthz.db.make_test_database()
        self.db = DB(con=con)
        self.user1 = User(self.db)
        self.name = "/file/name"
        self.data = "/etc/group"
        self.file1 = File.create_file(self.db, self.name, self.user1, self.data, pynimbusauthz.object_type_s3)
        self.uf = UserFile(self.file1)
开发者ID:Annatara,项目名称:nimbus,代码行数:9,代码来源:userfile_test.py


示例19: test_add_file_usage_one_file

    def test_add_file_usage_one_file(self):
        size1 = 100
        name = "/file/name"
        data = "/etc/group"

        file1 = File.create_file(self.db, name, self.user, data, pynimbusauthz.object_type_s3, size=size1)
        self.db.commit()

        u = self.user.get_quota_usage()
        self.assertEqual(u, size1)
开发者ID:Annatara,项目名称:nimbus,代码行数:10,代码来源:rebase_test.py


示例20: test_change_key

    def test_change_key(self):
        user1 = User(self.db)
        name = "/file/name"
        old_base = "/old/path/base"
        fname = "/etc/group"
        new_base = "/new/base/location/dir"
        f = File.create_file(self.db, name, user1, old_base + fname, pynimbusauthz.object_type_s3)

        self.assertEqual(old_base + fname, f.get_data_key(), "old value not euqal")

        new_key = new_base + fname
        f.set_data_key(new_key)
        self.db.commit()

        tst_new_key = f.get_data_key()
        self.assertEqual(tst_new_key, new_key, "%s should equal %s" % (tst_new_key, new_key))

        f2 = File.get_file(self.db, name, pynimbusauthz.object_type_s3)

        tst_new_key = f2.get_data_key()
        self.assertEqual(tst_new_key, new_key, "%s should equal %s" % (tst_new_key, new_key))
开发者ID:ketancmaheshwari,项目名称:nimbus,代码行数:21,代码来源:file_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pynipap.Pool类代码示例发布时间:2022-05-27
下一篇:
Python db.DB类代码示例发布时间: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