當前位置: 首頁>>代碼示例>>Python>>正文


Python FileInfo.get_absolute_path方法代碼示例

本文整理匯總了Python中fileinfo.FileInfo.get_absolute_path方法的典型用法代碼示例。如果您正苦於以下問題:Python FileInfo.get_absolute_path方法的具體用法?Python FileInfo.get_absolute_path怎麽用?Python FileInfo.get_absolute_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fileinfo.FileInfo的用法示例。


在下文中一共展示了FileInfo.get_absolute_path方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: callback

# 需要導入模塊: from fileinfo import FileInfo [as 別名]
# 或者: from fileinfo.FileInfo import get_absolute_path [as 別名]
def callback(ch, method, properties, body):
	global callback_flag
	global file_logger
	global logger
	global scanner
	global trans
	global vclient
	global mqclient
	global id
	stats = "NOT OK"
	
	trx_id = misc.generate_id(size=15)
	procid = id + " " + trx_id

	file_logger.info(procid + " Start Migration: " + repr(body))
	meta = json.loads(body)
	key = meta["path"]
	info = FileInfo(meta["base"], key)
	file_logger.info("FileInfo " + repr(info))
	fullpath = info.get_absolute_path()
	key_exist = False
	try:
		key_exist = trans.key_exist(key=key)
	except mogilefs.MogileFSError:
		pass

	if key_exist:
		file_logger.warning(procid + " Key exist: " + key)
	elif not os.path.isfile(fullpath):
		file_logger.warning(procid + " File does not exist: " + fullpath)
	else:
		file_logger.info("Scanning file: " + fullpath)
		scan_result = scanner.scan_file(fullpath)
		file_logger.info(procid + " Scanned file {0}: {1}".format(fullpath,scan_result))
		if scan_result:
			trans_result = trans.send_file(source=fullpath, key=key, clas=migconfig.clas)
			message = procid + " MogileFS key {0}: {1}".format(key, trans_result)
			file_logger.info(message)
			if trans_result == True:
				coll = info.to_collection()
				logger.file_saved(coll)
				file_logger.info(procid + " Saved metadata: " + repr(coll))
				vclient.send(coll["_id"])
				file_logger.info(procid + " Validation task: " + coll["_id"])
				stats = "OK"
			elif trans_result == None:
				file_logger.warning(procid + " Not saved because key exist: " + key)
			else:
				message = procid + " Error sent file to MogileFS: " + info.to_string()
				file_logger.error(message)
				mqclient.send(body)
		else:
			coll = info.to_collection()
			coll['status'] = 'infected'
			logger.file_saved(coll)
			file_logger.error(procid + " Infected file: " + repr(coll))
	ch.basic_ack(delivery_tag = method.delivery_tag)
	file_logger.info(procid + " End migration %s: %s " %(repr(body),  stats))
開發者ID:gdpadmin,項目名稱:MogileFS-Migrator,代碼行數:60,代碼來源:migratortask.py


注:本文中的fileinfo.FileInfo.get_absolute_path方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。