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

Python xattr.removexattr函数代码示例

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

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



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

示例1: main

def main():
    banner()
    p = raw_input("Please provide the BAD back-end file system folder NOT the mountpoint: ")
    while not os.path.isdir(p):
       p = raw_input("Invalid input %s is not a directory, please enter the correct path: "%p)
    a = raw_input("Last chance to back out, are you sure you want me to walk %s and remove all gluster xattrs I find? (y/n): "%p)
    while a.lower() not in ('y','n'):
        a = raw_input("Invalid input %s, please specify y or n: "%a)
    if a.lower() == 'n':
        sys.exit(0)
    '''
        Now we have a valid path, and user concent
    '''
    
    for root, dirs, files in os.walk(p):
        '''
            At the time of writing gluster only sets xarrts on directories
        '''
        xattrs = xattr.listxattr(root)
        if len(xattrs) > 0:
            if 'trusted.gfid' in xattrs:
                print("Found trusted.gfid set on %s"%root)
                xattr.removexattr(root,'trusted.gfid')
            for attr in xattrs:
                if reAFR.search(attr):
                    print("Found truster.afr.* set on %s"%root)
                    xattr.removexattr(root,attr)
开发者ID:Oneiroi,项目名称:sysadmin,代码行数:27,代码来源:stripxattr.py


示例2: remove_remote_id

 def remove_remote_id(self, ref, name='ndrive'):
     # Can be move to another class
     path = self._abspath(ref)
     log.trace('Removing xattr %s from %s', name, path)
     locker = self.unlock_path(path, False)
     if AbstractOSIntegration.is_windows():
         pathAlt = path + ":" + name
         try:
             if os.path.exists(pathAlt):
                 os.remove(pathAlt)
         except WindowsError as e:
             if e.errno == os.errno.EACCES:
                 self.unset_path_readonly(path)
                 os.remove(pathAlt)
                 self.set_path_readonly(path)
             else:
                 raise e
         finally:
             self.lock_path(path, locker)
     else:
         try:
             import xattr
             if AbstractOSIntegration.is_mac():
                 xattr.removexattr(path, name)
             else:
                 xattr.removexattr(path, 'user.' + name)
         except IOError as e:
             # Ignore IOError: [Errno 93] Attribute not found ( Mac )
             # IOError: [Errno 61] No data available ( Linux )
             if e.errno == 93 or e.errno == 61:
                 pass
             else:
                 raise
         finally:
             self.lock_path(path, locker)
开发者ID:mkeshava,项目名称:nuxeo-drive,代码行数:35,代码来源:local_client.py


示例3: _checkDeprecated

 def _checkDeprecated(self, item, symlink=False):
     """check deprecated list, set, get operations against an item"""
     self.assertEqual(self._ignore(xattr.listxattr(item, symlink)),
                      [])
     self.assertRaises(EnvironmentError, xattr.setxattr, item,
                       self.USER_ATTR, self.USER_VAL,
                       XATTR_REPLACE)
     try:
         xattr.setxattr(item, self.USER_ATTR, self.USER_VAL, 0, symlink)
     except IOError:
         err = sys.exc_info()[1]
         if err.errno == errno.EPERM and symlink:
             # symlinks may fail, in which case we abort the rest
             # of the test for this case
             return
         raise
     self.assertRaises(EnvironmentError, xattr.setxattr, item,
                       self.USER_ATTR, self.USER_VAL, XATTR_CREATE)
     self.assertEqual(self._ignore(xattr.listxattr(item, symlink)),
                      [self.USER_ATTR])
     self.assertEqual(xattr.getxattr(item, self.USER_ATTR, symlink),
                      self.USER_VAL)
     self.assertEqual(self._ignore_tuples(xattr.get_all(item,
                                                        nofollow=symlink)),
                      [(self.USER_ATTR, self.USER_VAL)])
     xattr.removexattr(item, self.USER_ATTR)
     self.assertEqual(self._ignore(xattr.listxattr(item, symlink)),
                      [])
     self.assertEqual(self._ignore_tuples(xattr.get_all(item,
                                                        nofollow=symlink)),
                      [])
     self.assertRaises(EnvironmentError, xattr.removexattr,
                       item, self.USER_ATTR)
开发者ID:quantheory,项目名称:pyxattr,代码行数:33,代码来源:test_xattr.py


示例4: remove_remote_id

 def remove_remote_id(self, ref, name='ndrive'):
     # Can be move to another class
     path = self._abspath(ref)
     log.trace('Removing xattr %s from %s', name, path)
     locker = self.unlock_path(path, False)
     if AbstractOSIntegration.is_windows():
         pathAlt = path + ":" + name
         try:
             os.remove(pathAlt)
         except WindowsError as e:
             if e.errno == os.errno.EACCES:
                 self.unset_path_readonly(path)
                 os.remove(pathAlt)
                 self.set_path_readonly(path)
             else:
                 raise e
         finally:
             self.lock_path(path, locker)
     else:
         try:
             import xattr
             if AbstractOSIntegration.is_mac():
                 xattr.removexattr(path, name)
             else:
                 xattr.removexattr(path, 'user.' + name)
         finally:
             self.lock_path(path, locker)
开发者ID:Bindupriya,项目名称:nuxeo-drive,代码行数:27,代码来源:local_client.py


示例5: is_partition_supported

 def is_partition_supported(self, folder):
     if folder is None:
         return False
     result = False
     to_delete = not os.path.exists(folder)
     try:
         if to_delete:
             os.mkdir(folder)
         if not os.access(folder, os.W_OK):
             import stat
             os.chmod(folder, stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP |
                             stat.S_IRUSR | stat.S_IWGRP | stat.S_IWUSR)
         import xattr
         attr = "drive-test"
         xattr.setxattr(folder, attr, attr)
         if xattr.getxattr(folder, attr) == attr:
             result = True
         xattr.removexattr(folder, attr)
     finally:
         try:
             if to_delete:
                 os.rmdir(folder)
         except:
             pass
     return result
开发者ID:Bindupriya,项目名称:nuxeo-drive,代码行数:25,代码来源:darwin.py


示例6: check_user_xattr

def check_user_xattr(path):
    if not os.path.exists(path):
        return False
    do_setxattr(path, 'user.test.key1', 'value1')
    try:
        removexattr(path, 'user.test.key1')
    except Exception, err:
        logging.exception("removexattr failed on %s err: %s", path, str(err))
开发者ID:Gaurav-Gangalwar,项目名称:swift_plugin,代码行数:8,代码来源:utils.py


示例7: delete

 def delete(self, name):
     try:
         xattr.removexattr(self._path, name)
     except IOError as e:
         if e.errno == errno.ENODATA or e.errno == errno.EOPNOTSUPP or e.errno == errno.ENOENT:
             raise KeyError(name)
         else:
             raise
开发者ID:javawizard,项目名称:fileutils,代码行数:8,代码来源:local.py


示例8: clean_metadata

def clean_metadata(path):
    key = 0
    while True:
        try:
            value = getxattr(path, '%s%s' % (METADATA_KEY, (key or '')))
        except IOError:
            break;
        removexattr(path, '%s%s' % (METADATA_KEY, (key or '')))
        key += 1
开发者ID:vbellur,项目名称:UFO,代码行数:9,代码来源:utils.py


示例9: clean_metadata

def clean_metadata(path):
    key = 0
    while True:
        try:
            xattr.removexattr(path, '%s%s' % (METADATA_KEY, (key or '')))
        except IOError as err:
            if err.errno == errno.ENODATA:
                break
            raise
        key += 1
开发者ID:kylejs,项目名称:gluster-swift,代码行数:10,代码来源:utils.py


示例10: comment_set

def comment_set(path, comment=None):
    assert_exists(path)
    if comment is None:
        xattr.removexattr(path, kMDItemFinderComment)
        return
    old = comment_get(path)
    if comment != old:
        if comment is not None and hasattr(comment, "encode"):
            comment = comment.encode("utf-8")  # str/bytes required
        xattr.setxattr(path, kMDItemFinderComment, comment)
开发者ID:russianidiot,项目名称:comment.py,代码行数:10,代码来源:comment.py


示例11: clean_metadata

def clean_metadata(path_or_fd):
    key = 0
    while True:
        try:
            xattr.removexattr(path_or_fd, '%s%s' % (METADATA_KEY, (key or '')))
        except IOError as err:
            if err.errno == errno.ENODATA:
                break
            raise GlusterFileSystemIOError(
                err.errno, 'xattr.removexattr("%s", %s)' % (path_or_fd, key))
        key += 1
开发者ID:prmarino1,项目名称:gluster-swift,代码行数:11,代码来源:utils.py


示例12: testSymlinkOpsDeprecated

 def testSymlinkOpsDeprecated(self):
     """test symlink operations (deprecated functions)"""
     _, sname = self._getsymlink()
     self.assertRaises(EnvironmentError, xattr.listxattr, sname)
     self._checkDeprecated(sname, symlink=True)
     target, sname = self._getsymlink(dangling=False)
     xattr.setxattr(target, self.USER_ATTR, self.USER_VAL)
     self.assertEqual(xattr.listxattr(target), [self.USER_ATTR])
     self.assertEqual(xattr.listxattr(sname, True), [])
     self.assertRaises(EnvironmentError, xattr.removexattr, sname, self.USER_ATTR, True)
     xattr.removexattr(sname, self.USER_ATTR, False)
开发者ID:floppym,项目名称:pyxattr,代码行数:11,代码来源:test_xattr.py


示例13: testBinaryPayloadDeprecated

 def testBinaryPayloadDeprecated(self):
     """test binary values (deprecated functions)"""
     fh, fname = self._getfile()
     os.close(fh)
     BINVAL = "abc" + "\0" + "def"
     if PY3K:
         BINVAL = BINVAL.encode()
     xattr.setxattr(fname, self.USER_ATTR, BINVAL)
     self.assertEqual(xattr.listxattr(fname), [self.USER_ATTR])
     self.assertEqual(xattr.getxattr(fname, self.USER_ATTR), BINVAL)
     self.assertEqual(xattr.get_all(fname), [(self.USER_ATTR, BINVAL)])
     xattr.removexattr(fname, self.USER_ATTR)
开发者ID:floppym,项目名称:pyxattr,代码行数:12,代码来源:test_xattr.py


示例14: test_index_chunk_missing_xattr

    def test_index_chunk_missing_xattr(self):
        rawx_conf = self.conf["rawx"][0]

        # create a fake chunk
        chunk_path, container_id, content_id, chunk_id = self._create_chunk(rawx_conf["path"])

        # remove mandatory xattr
        xattr.removexattr(chunk_path, "user.grid.chunk.hash")

        # try to index the chunk
        indexer = BlobIndexerWorker(self.gridconf, None, rawx_conf["path"])

        self.assertRaises(FaultyChunk, indexer.update_index, chunk_path)
开发者ID:lzmths,项目名称:oio-sds,代码行数:13,代码来源:test_indexer.py


示例15: do_removexattr

def do_removexattr(path, key):
    fd = None
    if not os.path.isdir(path):
        fd = do_open(path, 'rb')
    else:
        fd = path
    if fd or os.path.isdir(path):
        try:
            removexattr(fd, key)
        except Exception, err:
            logging.exception("removexattr failed on %s key %s err: %s", path, key, str(err))
            raise
        finally:
开发者ID:Gaurav-Gangalwar,项目名称:swift_plugin,代码行数:13,代码来源:utils.py


示例16: check_user_xattr

def check_user_xattr(path):
    if not os.path.exists(path):
        return False
    try:
        setxattr(path, 'user.key1', 'value1')
    except:
        raise
        return False
    try:
        removexattr(path, 'user.key1')
    except:
        raise
        return False
    return True
开发者ID:vbellur,项目名称:UFO,代码行数:14,代码来源:utils.py


示例17: check_user_xattr

def check_user_xattr(path):
    if not os_path.exists(path):
        return False
    try:
        xattr.setxattr(path, 'user.test.key1', 'value1')
    except IOError as err:
        logging.exception("check_user_xattr: set failed on %s err: %s", path, str(err))
        raise
    try:
        xattr.removexattr(path, 'user.test.key1')
    except IOError as err:
        logging.exception("check_user_xattr: remove failed on %s err: %s", path, str(err))
        #Remove xattr may fail in case of concurrent remove.
    return True
开发者ID:kururu-lu,项目名称:swift-lfs,代码行数:14,代码来源:utils.py


示例18: check_user_xattr

def check_user_xattr(path):
    if not os_path.exists(path):
        return False
    try:
        xattr.setxattr(path, 'user.test.key1', 'value1')
    except IOError as err:
        raise GlusterFileSystemIOError(
            err.errno,
            'xattr.setxattr("%s", "user.test.key1", "value1")' % (path,))
    try:
        xattr.removexattr(path, 'user.test.key1')
    except IOError as err:
        logging.exception("check_user_xattr: remove failed on %s err: %s",
                          path, str(err))
        #Remove xattr may fail in case of concurrent remove.
    return True
开发者ID:prmarino1,项目名称:gluster-swift,代码行数:16,代码来源:utils.py


示例19: unlink

  def unlink(self, path):
    print 'unlink', path
    tags = path.split("/")[1:-1] # hmmm
    fname = path.split("/")[-1]
    full = fullpath[fname]

    print tags
    xalist = xattr.listxattr(full)

    for tag in tags:
      xa = "user.%s" % tag

      if xa in xalist:
        xattr.removexattr(full, xa)

      if full in backend[tag]:
        backend[tag].remove(full)

    return 0
开发者ID:muromec,项目名称:fuse-tagfs,代码行数:19,代码来源:tagfs.py


示例20: test_xattr

 def test_xattr(self):
     fn = os.path.join(self.mount_point, str(uuid.uuid4()))
     try:
         with open(fn, 'wb') as f:
             f.write('hello\n')
         x = xattr.xattr(fn)
         x.set('abc', 'def')
         x.set('123', '456')
         self.unmount()
         self.mount()
         self.assertEqual(x.get('abc'), 'def')
         self.assertEqual(set(x.list()), {'abc', '123'})
         xattr.removexattr(fn, 'abc')
         self.assertEqual(set(x.list()), {'123'})
     finally:
         try:
             os.remove(fn)
         except EnvironmentError:
             pass
开发者ID:netheril96,项目名称:securefs,代码行数:19,代码来源:simple_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python xattr.set函数代码示例发布时间:2022-05-26
下一篇:
Python xattr.remove函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap