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


Python xattr.removexattr函数代码示例

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


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


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