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


Python xattr.listxattr函数代码示例

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


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

示例1: _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

示例2: test_purge_lock

    def test_purge_lock(self):
        resp = self.test_file.write(data='test',
                                    hdrs={'X-Hpss-Purgelock-Status': 'true',
                                          'X-Hpss-Class-Of-Service-Id': '1'},
                                    return_resp=True)

        print resp.status
        print resp.getheaders()
        print resp.read()

        test_file_name = os.path.join(self.hpss_dir,
                                      self.account.name,
                                      self.container.name,
                                      'testfile')

        print test_file_name

        print os.stat(test_file_name)

        print xattr.listxattr(test_file_name)

        self.assertEqual(xattr.get(test_file_name,
                                   'system.hpss.purgelock'),
                         '1')

        self.test_file.post(hdrs={'X-Hpss-Purgelock-Status': 'false'})

        self.assertEqual(xattr.get(test_file_name,
                                   'system.hpss.purgelock'), '0')
开发者ID:openstack,项目名称:swiftonhpss,代码行数:29,代码来源:swift_on_hpss_tests.py

示例3: testMixedAccessDeprecated

 def testMixedAccessDeprecated(self):
     """test mixed access to file (deprecated functions)"""
     fh, fname = self._getfile()
     fo = os.fdopen(fh)
     self.assertEqual(xattr.listxattr(fname), [])
     xattr.setxattr(fname, self.USER_ATTR, self.USER_VAL)
     self.assertEqual(xattr.listxattr(fh), [self.USER_ATTR])
     self.assertEqual(xattr.getxattr(fo, self.USER_ATTR), self.USER_VAL)
     self.assertEqual(xattr.get_all(fo), [(self.USER_ATTR, self.USER_VAL)])
     self.assertEqual(xattr.get_all(fname), [(self.USER_ATTR, self.USER_VAL)])
     fo.close()
开发者ID:floppym,项目名称:pyxattr,代码行数:11,代码来源:test_xattr.py

示例4: 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

示例5: testNoXattrDeprecated

 def testNoXattrDeprecated(self):
     """test no attributes (deprecated functions)"""
     fh, fname = self._getfile()
     self.assertEqual(xattr.listxattr(fname), [])
     self.assertEqual(xattr.get_all(fname), [])
     dname = self._getdir()
     self.assertEqual(xattr.listxattr(dname), [])
     self.assertEqual(xattr.get_all(dname), [])
     _, sname = self._getsymlink()
     self.assertEqual(xattr.listxattr(sname, True), [])
     self.assertEqual(xattr.get_all(sname, nofollow=True), [])
开发者ID:floppym,项目名称:pyxattr,代码行数:11,代码来源:test_xattr.py

示例6: __applyxattr

	def __applyxattr(self, fullPath, info, reportProblems= True):
		if kXattrAvailable and info[1].has_key('xattr'):
			try:
				existingAttributes= xattr.listxattr(fullPath)
			except KeyboardInterrupt,e:
				raise e
			except: # Can't list existing attributes on the file
开发者ID:marcpage,项目名称:build,代码行数:7,代码来源:bArchive.py

示例7: 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

示例8: get_raw_tags

def get_raw_tags(path):
    if 'com.apple.metadata:_kMDItemUserTags' in xattr.listxattr(path):
        d = xattr.getxattr(path, 'com.apple.metadata:_kMDItemUserTags')
        d = biplist.readPlistFromString(d)
        return d
    else:
        return []
开发者ID:kdbdallas,项目名称:half-moon-tagging,代码行数:7,代码来源:tag.py

示例9: list_xattr

    def list_xattr(self, filepath):
        logger.info("list_xattr - %s" % filepath)

        with self._get_lock():
            ascii_path = filepath.encode('ascii', 'ignore')
            localfs_path = self._make_localfs_path(ascii_path)
            return xattr.listxattr(localfs_path)
开发者ID:syndicate-storage,项目名称:syndicate-fs-driver,代码行数:7,代码来源:local_plugin.py

示例10: GetExtAttrs

def GetExtAttrs(filepath):
  """Fetches extended file attributes.

  Args:
    filepath: A path to the file.

  Yields:
    `ExtAttr` pairs.
  """
  path = CanonicalPathToLocalPath(filepath)

  try:
    attr_names = xattr.listxattr(path)
  except (IOError, OSError) as error:
    msg = "Failed to retrieve extended attributes for '%s': %s"
    logging.error(msg, path, error)
    return

  for attr_name in attr_names:
    try:
      attr_value = xattr.getxattr(path, attr_name)
    except (IOError, OSError) as error:
      msg = "Failed to retrieve attribute '%s' for '%s': %s"
      logging.error(msg, attr_name, path, error)
      continue

    yield rdf_client.ExtAttr(name=attr_name, value=attr_value)
开发者ID:bhyvex,项目名称:grr,代码行数:27,代码来源:client_utils_osx_linux.py

示例11: copy_xattr

 def copy_xattr(self, src, dest):
     attrs = xattr.listxattr(src)
     for k in attrs:
         try:
             val = xattr.getxattr(src, k)
             xattr.setxattr(dest, k, val)
         except IOError as e:
             log.warn(e, extra=self.d)
开发者ID:verolero86,项目名称:pcircle,代码行数:8,代码来源:fwalk.py

示例12: _message_at_path

 def _message_at_path(self, path, load_content=True):
     try:
         content = None
         if load_content:
             f = open(path, "rb")
             content = f.read()
             f.close()
         
         mtime = os.path.getmtime(path)
         
         directory, filename = os.path.split(path)
         directory, subdir = os.path.split(directory)
         
         msgid = None
         info = None
         parts = filename.split(":")
         if len(parts) > 0:
             msgid = parts[0]
         if len(parts) > 1:
             info = parts[1]
         
         msg = Message(content=content, msgid=msgid, info=info, subdir=subdir, mtime=mtime)
         if not msg.msg_md5 and self._use_xattrs and load_content:
             try:
                 xattrs = xattr.listxattr(path)
                 # logging.debug(xattrs)
                 if XATTR_MD5SUM in xattrs:
                     msg.msg_md5 = xattr.getxattr(path, XATTR_MD5SUM)
                     # logging.debug("Read md5: %s", msg.msg_md5)
                 else:
                     c = msg.content_hash
                     if c:
                         # logging.debug("Setting shasum xattr: %r", c)
                         xattr.setxattr(path, XATTR_MD5SUM, c)
                     else:
                         logging.warning("Could not generate content hash of %s", msgid)
                 
                 if XATTR_DATE in xattrs:
                     msg._date = xattr.getxattr(path, XATTR_DATE).decode("utf8")
                     msg._date = datetime.datetime.fromtimestamp(float(msg._date))
                     # logging.debug("Read date: %s", msg._date)
                 else:
                     d = str(msg.date.timestamp()).encode("utf8")
                     if d:
                         # logging.debug("Setting date xattr: %r", d)
                         xattr.setxattr(path, XATTR_DATE, d)
                     else:
                         logging.warning("Could not determine message date of %s", msgid)
             
             except IOError:
                 # read-only FS, unsupported on FS, etc.
                 self._use_xattrs = False
                 log.debug("host filesystem for %s does not support xattrs; disabling" % self.name)
         
         return msg
         
     except OSError:
         raise KeyError
开发者ID:ahknight,项目名称:maildir-lite,代码行数:58,代码来源:maildir.py

示例13: list

 def list(self):
     try:
         return list(xattr.listxattr(self._path))
     except IOError as e:
         if e.errno == errno.EOPNOTSUPP or e.errno == errno.ENOENT:  # No
             # xattr support or the file doesn't exist
             return []
         else:
             raise
开发者ID:javawizard,项目名称:fileutils,代码行数:9,代码来源:local.py

示例14: listxattr

def listxattr (path):
    global xattr_supported
    if xattr_supported:
        try:
            return xattr.listxattr (path)
        except IOError, e:
            if e.errno == 95: # Operation not supported
                xattr_supported = False
            else:
                raise
开发者ID:pasalo,项目名称:common,代码行数:10,代码来源:xattr_wrap.py

示例15: set_eas

	def set_eas(self, rp, write):
		"""Set extended attributes from rp. Tests writing if write is true."""
		assert Globals.local_connection is rp.conn
		assert rp.lstat()
		if Globals.eas_active == 0:
			log.Log("Extended attributes test skipped. rdiff-backup run "
					"with --no-eas option.", 4)
			self.eas = 0
			return
		try: import xattr
		except ImportError:
			log.Log("Unable to import module xattr.\nExtended attributes not "
					"supported on filesystem at %s" % (rp.path,), 4)
			self.eas = 0
			return

		try:
			ver = xattr.__version__
		except AttributeError:
			ver = 'unknown'
		if ver < '0.2.2' or ver == 'unknown':
			log.Log("Warning: Your version of pyxattr (%s) has broken support "
					"for extended\nattributes on symlinks. If you choose not "
					"to upgrade to a more recent version,\nyou may see many "
					"warning messages from listattr().\n" % (ver,), 3)

		try:
			xattr.listxattr(rp.path)
			if write:
				xattr.setxattr(rp.path, "user.test", "test val")
				assert xattr.getxattr(rp.path, "user.test") == "test val"
		except IOError:
			log.Log("Extended attributes not supported by "
					"filesystem at %s" % (rp.path,), 4)
			self.eas = 0
		except AssertionError:
			log.Log("Extended attributes support is broken on filesystem at "
					"%s.\nPlease upgrade the filesystem driver, contact the "
					"developers,\nor use the --no-eas option to disable "
					"extended attributes\nsupport and suppress this message."
					% (rp.path,), 1)
			self.eas = 0
		else: self.eas = 1
开发者ID:ObiWahn,项目名称:rdiff-backup,代码行数:43,代码来源:fs_abilities.py


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