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

Python xattr.listxattr函数代码示例

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

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



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


示例16: localCopyOfImageInFolder

def localCopyOfImageInFolder(imageURLString, imagePageString, targetFolder):
	username = None
	if imageURLString != None:
		fileName = NSString.stringWithString_(imageURLString).lastPathComponent()
		filePath = targetFolder + "/" + fileName

		if NSFileManager.defaultManager().fileExistsAtPath_(filePath) == False:
			imageURL = NSURL.URLWithString_(NSString.stringWithString_(NSString.stringWithString_(imageURLString).stringByAddingPercentEscapesUsingEncoding_(NSUTF8StringEncoding)))
			request = NSURLRequest.requestWithURL_(imageURL)
			data, response, error = NSURLConnection.sendSynchronousRequest_returningResponse_error_(request, None, None)
			if data != None:
				if data.writeToFile_atomically_(filePath, True):
					print "	Image file cached successfully at " + filePath
				else:
					print "	* Failed to write image file at " + filePath
			else:
				print "	* Could not load " + imageURLString + " (" + error.description() + ")"

			# get image creator's name
			infoURL = NSURL.URLWithString_(NSString.stringWithString_(imagePageString).stringByAddingPercentEscapesUsingEncoding_(NSUTF8StringEncoding))
			(infoPageString, error) = NSString.stringWithContentsOfURL_encoding_error_(infoURL, NSUTF8StringEncoding, None)
			if infoPageString != None:
				(infoXHTML, error) = NSXMLDocument.alloc().initWithXMLString_options_error_(infoPageString, NSXMLDocumentTidyXML, None)
				if infoXHTML != None:
					nodes, error = infoXHTML.nodesForXPath_error_("""//tr[contains(.,"current")]/td/a[contains(@class,'mw-userlink')]""", None)
					if len(nodes) > 0:
						wikipediaPath = nodes[0]
						username = wikipediaPath.stringValue().split(":")[-1]
						xattr.setxattr(filePath, "net.earthlingsoft.imageauthor", username)
						print "	Image author »" + username + "« stored."
					else:
						nodes, error = infoXHTML.nodesForXPath_error_("""//tr[contains(.,"aktuell")]/td/a[contains(@class,'mw-userlink')]""", None)
						if len(nodes) > 0:
							wikipediaPath = nodes[0]
							username = wikipediaPath.stringValue().split(":")[-1]
							xattr.setxattr(filePath, "net.earthlingsoft.imageauthor", username)
							print "	Image author »" + username + "« stored."
						else:
							print "		* Could not find author information in info page at " + imagePageString
				else:
					print "		* Could not parse XML of info page at " + imagePageString
			else:
				print "		* Could not download image information at " + imagePageString

		else:
			xattrs = xattr.listxattr(filePath)
			if "net.earthlingsoft.imageauthor" in xattrs:
				username = xattr.getxattr(filePath, "net.earthlingsoft.imageauthor")
			print "	Cached image file available"
		
		newURL = myURL + targetFolder + "/" + fileName
	else:
		newURL = None
		
	return [newURL, username]
开发者ID:ssp,项目名称:Gedenktafeln,代码行数:55,代码来源:Gedenktafeln.py


示例17: testManyOpsDeprecated

 def testManyOpsDeprecated(self):
     """test many ops (deprecated functions)"""
     fh, fname = self._getfile()
     xattr.setxattr(fh, self.USER_ATTR, self.USER_VAL)
     VL = [self.USER_ATTR]
     for i in range(self.MANYOPS_COUNT):
         self.assertEqual(xattr.listxattr(fh), VL)
     for i in range(self.MANYOPS_COUNT):
         self.assertEqual(xattr.getxattr(fh, self.USER_ATTR), self.USER_VAL)
     for i in range(self.MANYOPS_COUNT):
         self.assertEqual(xattr.get_all(fh), [(self.USER_ATTR, self.USER_VAL)])
开发者ID:floppym,项目名称:pyxattr,代码行数:11,代码来源:test_xattr.py


示例18: process_expire

 def process_expire(self, expire):
     with self.lock:
         self.current_expire = expire
     for z in xrange(self.maxz, 2 - 1, -1):
         with self.lock:
             self.current_expire_zoom = z
         for (x, y) in expire.expiredAt(z):
             t = Tile(z, x, y)
             tile_path = getTilePath(REFERENCE_TILESET, z, x, y)
             if path.isfile(tile_path):
                 if 'user.toposm_dirty' not in xattr.listxattr(tile_path):
                     xattr.setxattr(tile_path, 'user.toposm_dirty', 'yes')
                 mt = t.metatile
                 tile_path = getTilePath(REFERENCE_TILESET, mt.z, mt.x * NTILES[z], mt.y * NTILES[z])
                 if path.isfile(tile_path) and 'user.toposm_dirty' not in xattr.listxattr(tile_path):
                     xattr.setxattr(tile_path, 'user.toposm_dirty', 'yes')
                 self.queue.queue_tile(t, 'zoom', 'expire')
     with self.lock:
         self.current_expire = None
         self.current_expire_zoom = None
开发者ID:asciiphil,项目名称:TopOSM,代码行数:20,代码来源:queuemaster.py


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


示例20: read_xattr_metadata

def read_xattr_metadata(file_list):
  """For the given list of files read us the kMDItemDescription and kMDItemKeywords."""
  meta_data = []
  for file in file_list:
    md = {}
    attrs = xattr.listxattr(file)
    if 'com.apple.metadata:kMDItemDescription' in attrs:
      md['Caption-Abstract'] = biplist.readPlistFromString(xattr.getxattr(file, 'com.apple.metadata:kMDItemDescription'))
    if 'com.apple.metadata:kMDItemKeywords' in attrs:
      md['Keywords'] = biplist.readPlistFromString(xattr.getxattr(file, 'com.apple.metadata:kMDItemKeywords'))
    meta_data.append(md)
  return meta_data
开发者ID:kghose,项目名称:Chhobi2,代码行数:12,代码来源:libchhobi.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python xattr.remove函数代码示例发布时间:2022-05-26
下一篇:
Python xattr.list函数代码示例发布时间: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