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


Python fileinfo.FileInfo类代码示例

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


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

示例1: _get_dir_info

 def _get_dir_info(self, rootdir):
     for item in os.listdir(rootdir):
         fullname = os.path.join(rootdir, item)
         
         if not item.startswith('.') and not os.path.islink(fullname):
             if os.path.isdir(fullname):
                 dir = DirInfo(fullname, self._recursive)
                 self._dirs.append(dir)
                 self._dircount += 1
                 
                 if self._recursive:
                     self._filecount += dir.get_filecount()
                     self._dircount += dir.get_dircount()
                     self._totalsize += dir.get_totalsize()
                     self._codelines += dir.get_code_lines()
                     self._commentlines += dir.get_comment_lines()
                     self._whitespacelines += dir.get_whitespace_lines()                        
             else:
                 file = FileInfo(rootdir, item)
                 self._files.append(file)
                 self._filecount += 1
                 self._totalsize += file.get_filesize()
                 self._codelines += file.get_code_lines()
                 self._commentlines += file.get_comment_lines()
                 self._whitespacelines += file.get_whitespace_lines()
开发者ID:JeroenDeDauw,项目名称:phpstat,代码行数:25,代码来源:dirinfo.py

示例2: callback

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,代码行数:58,代码来源:migratortask.py

示例3: from_dict

 def from_dict(d):
     bi = BasicInfo.from_dict(d['basic_info'])
     fi = FileInfo.from_dict(d['file_info'])
     si = None
     if 'scm_info' in d:
         if d['scm_info']['system'] == 'git':
             si = GitInfo.from_dict(d['scm_info'])
     return Artifact(bi, fi, si)
开发者ID:mogproject,项目名称:artifact-cli,代码行数:8,代码来源:artifact.py

示例4: callback

def callback(ch, method, properties, body):
	stats = "OK"
	global id

	procid = id + "-" + misc.generate_id(size=15)
	file_logger.info(procid + " Start validation: " + repr(body))
	dbmeta = logger.file_get(body)
	file_logger.info(procid + " Database meta data: " + repr(dbmeta))
	
	if dbmeta:
		base = "/tmp"
		name = os.path.basename(dbmeta["path"])
		fullpath = os.path.join(base, name)
		try:
			if os.path.isfile(fullpath):
				os.remove(fullpath)
		except OSError:
			suffix = misc.generate_id()
			fullpath = fullpath + "-" + suffix
		
		trans.download_file(key=dbmeta["path"], name=fullpath)
		mogmeta = FileInfo("/tmp", name)
		file_logger.info(procid + " MogileFS meta data: " + repr(mogmeta.to_collection()))
		if mogmeta.equal_meta(dbmeta):
			logger.file_validated(dbmeta)
		else:
			logger.file_corrupted(dbmeta)
			migration_job = {"path": dbmeta["path"], "base": dbmeta["base"]}
			mqclient.send(migration_job)
			msg = procid + " File corrupted. Sent new job to migration queue: " + json.dumps(dbmeta)
			logger.warning(msg)
			stats = "CORRUPTED"

		os.remove(fullpath)
	else:
		if not trans.key_exist(body):
			file_logger.error("Missing key: " + body)
		
	ch.basic_ack(delivery_tag = method.delivery_tag)
	file_logger.info("%s End validation %s: %s" %(procid, repr(body), stats))
开发者ID:gdpadmin,项目名称:MogileFS-Migrator,代码行数:40,代码来源:validatortask.py

示例5: FileInfo

from fileinfo import FileInfo
import re

file_info = FileInfo()

filename_regex           = r"^gapps-jb43-[0-9]+-dmd151\.zip$"
file_info.patch          = 'Google_Apps/gapps-doomed151.dualboot.patch'
file_info.has_boot_image = False

def matches(filename):
  if re.search(filename_regex, filename):
    return True
  else:
    return False

def print_message():
  print("Detected doomed151's Google Apps zip")

def get_file_info():
  return file_info
开发者ID:nauddin257,项目名称:DualBootPatcher,代码行数:20,代码来源:gapps-doomed151.py

示例6: FileInfo

from fileinfo import FileInfo
import re

file_info = FileInfo()

filename_regex           = r"^UPDATE-SuperSU-v[0-9\.]+\.zip$"
file_info.patch          = 'Other/supersu.dualboot.patch'
file_info.has_boot_image = False

def matches(filename):
  if re.search(filename_regex, filename):
    return True
  else:
    return False

def print_message():
  print("Detected Chainfire's SuperSU zip")

def get_file_info():
  return file_info
开发者ID:nauddin257,项目名称:DualBootPatcher,代码行数:20,代码来源:supersu.py

示例7: ramdisk

# This file describes the ROM/Kernel/etc with the following information:
#   - Pattern in file name
#   - Patch to use
#   - Type of ramdisk (if any)
#   - Message to display to user
#
# Please copy this file to a new one before editing.

from fileinfo import FileInfo
import multiboot.autopatcher as autopatcher
import re

file_info = FileInfo()

# This is the regular expression for detecting a ROM using the filename. Here
# are some basic rules for how regex's work:
# Pattern        | Meaning
# -----------------------------------------------
# ^              | Beginning of filename
# $              | End of filename
# .              | Any character
# \.             | Period
# [a-z]          | Lowercase English letters
# [a-zA-Z]       | All English letters
# [0-9]          | Numbers
# *              | 0 or more of previous pattern
# +              | 1 or more of previous pattern

# We'll use the SuperSU zip as an example.
#
# Filename: UPDATE-SuperSU-v1.65.zip
开发者ID:luisafire666,项目名称:DualBootPatcher,代码行数:31,代码来源:Sample.py

示例8: FileInfo

from fileinfo import FileInfo
import re

file_info = FileInfo()

filename_regex           = r"^i9505-ge-untouched-4.3-.*.zip$"
file_info.ramdisk        = 'jflte/GoogleEdition/GoogleEdition.def'
file_info.patch          = 'jflte/ROMs/TouchWiz/ge-MaKTaiL.dualboot.patch'

def matches(filename):
  if re.search(filename_regex, filename):
    return True
  else:
    return False

def print_message():
  print("Detected MaKTaiL's Google Edition ROM zip")

def get_file_info():
  return file_info
开发者ID:nauddin257,项目名称:DualBootPatcher,代码行数:20,代码来源:ge-MaKTaiL.py

示例9: __setitem__

def __setitem__(self, key, item):
    if key == "name" and item:
        self.__parse(item)
    FileInfo.__setitem__(self, key, item)
开发者ID:Ania9,项目名称:dip_example,代码行数:4,代码来源:e5_14.py

示例10: FileInfo

from fileinfo import FileInfo
import re

file_info = FileInfo()

filename_regex           = r"^FoxHound_.*\.zip$"
file_info.ramdisk        = 'jflte/TouchWiz/TouchWiz.def'
file_info.bootimg        = "snakes/Kernels/Stock/boot.img"

def matches(filename):
  if re.search(filename_regex, filename):
    if re.search("_3.[0-9]+", filename):
      file_info.patch    = 'jflte/ROMs/TouchWiz/foxhound-3.0.dualboot.patch'
    else:
      file_info.patch    = 'jflte/ROMs/TouchWiz/foxhound.dualboot.patch'
    return True
  else:
    return False

def print_message():
  print("Detected FoxHound ROM zip")

def get_file_info():
  return file_info
开发者ID:nauddin257,项目名称:DualBootPatcher,代码行数:24,代码来源:foxhound.py

示例11: FileInfo

from fileinfo import FileInfo
import re

file_info = FileInfo()

filename_regex           = r"^gapps-jb-[0-9]{8}-signed\.zip$"
file_info.patch          = 'Google_Apps/gapps-cyanogenmod.dualboot.patch'
file_info.has_boot_image = False

def matches(filename):
  if re.search(filename_regex, filename):
    return True
  else:
    return False

def print_message():
  print("Detected Cyanogenmod Google Apps zip")

def get_file_info():
  return file_info
开发者ID:nauddin257,项目名称:DualBootPatcher,代码行数:20,代码来源:gapps-cyanogenmod.py

示例12: FileInfo

from fileinfo import FileInfo
import re

file_info = FileInfo()

filename_regex           = r"^gapps-jb\([0-9\.]+\)-[0-9\.]+\.zip$"
file_info.patch          = 'Google_Apps/gapps-task650.dualboot.patch'
file_info.has_boot_image = False

def matches(filename):
  if re.search(filename_regex, filename):
    return True
  else:
    return False

def print_message():
  print("Detected Task650's Google Apps zip")

def get_file_info():
  return file_info
开发者ID:nauddin257,项目名称:DualBootPatcher,代码行数:20,代码来源:gapps-task650.py

示例13: ramdisk

# This file describes the ROM/Kernel/etc with the following information:
#   - Pattern in file name
#   - Patch to use
#   - Type of ramdisk (if any)
#   - Message to display to user
#
# Please copy this file to a new one before editing.

from fileinfo import FileInfo
import re

file_info = FileInfo()

# This is the regular expression for detecting a ROM using the filename. Here
# are some basic rules for how regex's work:
# Pattern        | Meaning
# -----------------------------------------------
# ^              | Beginning of filename
# $              | End of filename
# .              | Any character
# \.             | Period
# [a-z]          | Lowercase English letters
# [a-zA-Z]       | All English letters
# [0-9]          | Numbers
# *              | 0 or more of previous pattern
# +              | 1 or more of previous pattern

# We'll use the SuperSU zip as an example.
#
# Filename: UPDATE-SuperSU-v1.65.zip
# Pattern: ^UPDATE-SuperSU-v[0-9\.]+\.zip$
开发者ID:nauddin257,项目名称:DualBootPatcher,代码行数:31,代码来源:Sample.py

示例14: FileInfo

from fileinfo import FileInfo
import common as c
import re

file_info = FileInfo()

filename_regex           = r"^GE.*\.zip$"
file_info.ramdisk        = 'jflte/TouchWiz/TouchWiz.def'
file_info.has_boot_image = True
file_info.bootimg        = 'kernel/boot.img'

def print_message():
  print("Detected Goldeneye")

###

def matches(filename):
  if re.search(filename_regex, filename):
    if 'ATT' in filename:
      file_info.loki     = True
      file_info.bootimg  = 'kernel/boot.lok'
    return True
  else:
    return False

def get_file_info():
  return file_info

def extract_files():
  return [ 'META-INF/com/google/android/updater-script' ]
开发者ID:nauddin257,项目名称:DualBootPatcher,代码行数:30,代码来源:goldeneye.py

示例15: FileInfo

from fileinfo import FileInfo
import re

file_info = FileInfo()

filename_regex           = r"^v[0-9\.]+-Google-edition-ausdim-Kernel-.*\.zip$"
file_info.ramdisk        = 'jflte/TouchWiz/TouchWiz.def'
file_info.patch          = 'jflte/Kernels/TouchWiz/ausdim.dualboot.patch'

def matches(filename):
  if re.search(filename_regex, filename):
    return True
  else:
    return False

def print_message():
  print("Detected Ausdim kernel zip")

def get_file_info():
  return file_info
开发者ID:nauddin257,项目名称:DualBootPatcher,代码行数:20,代码来源:ausdim.py


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