本文整理汇总了Python中util.Logutil类的典型用法代码示例。如果您正苦于以下问题:Python Logutil类的具体用法?Python Logutil怎么用?Python Logutil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logutil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: scanDescription
def scanDescription(self, descFile, descParseInstruction, encoding):
Logutil.log('scanDescription: %s' % descFile, util.LOG_LEVEL_INFO)
if(descFile.startswith('http://')):
req = urllib2.Request(descFile)
req.add_unredirected_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31')
descFile = urllib2.urlopen(req).read()
else:
fh = open(str(descFile), 'r')
descFile = fh.read()
#load xmlDoc as elementtree to check with xpaths
tree = fromstring(descFile)
#single result as dictionary
result = {}
rootElement = self.grammarNode.attrib.get('root')
for node in tree.findall(rootElement):
result = self.parseElement(node)
result = self.replaceResultTokens(result)
yield result
开发者ID:roeiba,项目名称:xbmc,代码行数:25,代码来源:descriptionparserxml.py
示例2: readImagePlacing
def readImagePlacing(self, imagePlacingName, tree):
#fileTypeForRow = None
fileTypeForRows = tree.findall('ImagePlacing/fileTypeFor')
fileTypeForRow = next((element for element in fileTypeForRows if element.attrib.get('name') == imagePlacingName), None)
if fileTypeForRow is None:
Logutil.log('Configuration error. ImagePlacing/fileTypeFor %s does not exist in config.xml' % str(imagePlacingName), util.LOG_LEVEL_ERROR)
return None, util.localize(32005)
imagePlacing = ImagePlacing()
imagePlacing.name = imagePlacingName
for attr in ['fileTypesForGameList', 'fileTypesForGameListSelected',
'fileTypesForMainView1', 'fileTypesForMainView2', 'fileTypesForMainView3',
'fileTypesForMainViewBackground', 'fileTypesForMainViewGameInfoBig',
'fileTypesForMainViewGameInfoUpperLeft', 'fileTypesForMainViewGameInfoUpperRight',
'fileTypesForMainViewGameInfoLowerLeft', 'fileTypesForMainViewGameInfoLowerRight',
'fileTypesForMainViewGameInfoLower', 'fileTypesForMainViewGameInfoUpper',
'fileTypesForMainViewGameInfoRight', 'fileTypesForMainViewGameInfoLeft',
'fileTypesForMainViewVideoWindowBig', 'fileTypesForMainViewVideoWindowSmall',
'fileTypesForMainViewVideoFullscreen']:
# Hack - class attribute fileTypesForXXX doesn't match XML key fileTypeForXXX
val = self.readFileTypeForElement(fileTypeForRow, attr.replace('fileTypesFor', 'fileTypeFor'), tree)
log.debug("Reading imageplacing for {0}: {1}".format(attr, val))
setattr(imagePlacing, attr, val)
return imagePlacing, ''
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:29,代码来源:config.py
示例3: get_scraper_by_name
def get_scraper_by_name(self, sname):
"""Given a scraper name, returns the scraper class
Args:
sname: Name of the scraper, e.g. thegamesdb.net or MAME
Raises:
ConfigScraperSiteDoesNotExistException: No scraper matches the name
"""
try:
target = self.scrapers[sname]
except KeyError as e:
raise ConfigScraperSiteDoesNotExistException("Unsupported scraper: {0}".format(sname))
log.debug("Instantiating scraper class {0} - {1}".format(sname, target))
try:
module = __import__(target.lower())
class_ = getattr(module, target)
instance = class_()
except ImportError:
log.error("Unable to find scraper {0}".format(sname))
raise
return instance
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:25,代码来源:scraper.py
示例4: updateSelectedRomCollection
def updateSelectedRomCollection(self):
log.info("updateSelectedRomCollection")
sites = []
sites = self.addScraperToSiteList(CONTROL_LIST_SCRAPER1, sites, self.selectedRomCollection)
self.selectedRomCollection.scraperSites = sites
# Image Placing Main
control = self.getControlById(CONTROL_LIST_IMAGEPLACING_MAIN)
imgPlacingItem = control.getSelectedItem()
imgPlacingName = imgPlacingItem.getLabel()
# HACK search key by value
for item in config.imagePlacingDict.items():
if item[1] == imgPlacingName:
imgPlacingName = item[0]
imgPlacing, errorMsg = self.gui.config.readImagePlacing(imgPlacingName, self.gui.config.tree)
self.selectedRomCollection.imagePlacingMain = imgPlacing
# Image Placing Info
control = self.getControlById(CONTROL_LIST_IMAGEPLACING_INFO)
imgPlacingItem = control.getSelectedItem()
imgPlacingName = imgPlacingItem.getLabel()
# HACK search key by value
for item in config.imagePlacingDict.items():
if item[1] == imgPlacingName:
imgPlacingName = item[0]
imgPlacing, errorMsg = self.gui.config.readImagePlacing(imgPlacingName, self.gui.config.tree)
self.selectedRomCollection.imagePlacingInfo = imgPlacing
# Update values for each of the buttons
for btn in self._control_buttons:
control = self.getControlById(btn['control'])
setattr(self.selectedRomCollection, btn['value'], bool(control.isSelected()))
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:35,代码来源:dialogeditromcollection.py
示例5: __init__
def __init__(self, *args, **kwargs):
# Don't put GUI sensitive stuff here (as the xml hasn't been read yet)
log.info("init ContextMenu")
self.gui = kwargs["gui"]
self.doModal()
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:7,代码来源:dialogcontextmenu.py
示例6: retrieve
def retrieve(self, gameid, platform=None):
result = {}
tree = ET.ElementTree()
if sys.version_info >= (2, 7):
parser = ET.XMLParser(encoding='utf-8')
else:
parser = ET.XMLParser()
tree.parse(self._get_xml_path(), parser)
#gameid is the exact name of the game used in element <description>
game = tree.find('.//game[description="%s"]'%gameid)
# Standard fields
for k, v in self._game_mapping.items():
# HACK - This is only used to retain backwards compatibility with existing scraper, where each key value was a
# list, even if only one value is in that list
try:
result[k] = [game.find(v).text]
# FIXME TODO When we remove the hack, this will be the code to use:
# result[k] = game.find(v).text
except Exception as e:
# Typically this result doesn't have this field
log.debug("Unable to extract data from key {0}".format(k))
# Custom fields
result['Genre'] = self._parse_genres(game)
return result
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:31,代码来源:offline_gdbi_scraper.py
示例7: addScraperToSiteList
def addScraperToSiteList(self, controlId, sites, romCollection):
log.info("addScraperToSiteList")
control = self.getControlById(controlId)
scraperItem = control.getSelectedItem()
scraper = scraperItem.getLabel()
if scraper == util.localize(32854):
return sites
#check if this site is already available for current RC
for site in romCollection.scraperSites:
if site.name == scraper:
sites.append(site)
return sites
siteRow = None
siteRows = self.gui.config.tree.findall('Scrapers/Site')
for element in siteRows:
if element.attrib.get('name') == scraper:
siteRow = element
break
if siteRow is None:
xbmcgui.Dialog().ok(util.localize(32021), util.localize(32022) % scraper)
return None
site, errorMsg = self.gui.config.readScraper(siteRow, romCollection.name, '', '', True, self.gui.config.tree)
if site is not None:
sites.append(site)
return sites
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:33,代码来源:dialogeditromcollection.py
示例8: add_romfiles_to_db
def add_romfiles_to_db(self, romFiles, gameId):
for romFile in romFiles:
log.debug("Adding romfile to DB: %s" % romFile)
fileType = FileType()
fileType.id, fileType.name, fileType.parent = 0, "rcb_rom", "game"
self.insertFile(romFile, gameId, fileType, None, None, None)
del fileType
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:7,代码来源:dbupdate.py
示例9: _parse_game_result
def _parse_game_result(self, response):
""" response is expected to be a JSON object """
result = {}
# Standard fields
for k, v in self._game_mapping.items():
try:
# HACK - for compatibility we need to put each result in an array
#result[k] = response[v]
result[k] = [response[v]]
except KeyError as k:
log.warn("Unable to find key: {0}".format(k))
except Exception as e:
log.warn("Unable to extract data from key {0}".format(e))
# Custom fields (i.e. ones that require special handling
# HACK - for compatibility we need to put each result in an array
result['ReleaseYear'] = [self._parse_date(response['original_release_date'])]
result['Developer'] = self._parse_developers(response['developers'])
result['Publisher'] = self._parse_publishers(response['publishers'])
result['Genre'] = self._parse_genres(response['genres'])
# FIXME TODO Artwork and images are quite cumbersome to get from giantbomb search results
return result
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:25,代码来源:giantbomb_scraper.py
示例10: search
def search(self, gamename, platform=None):
""" Ignore platform """
# Newer versions support multi systems, $info=XXX indicates an arcade ROM
startmarker = "$info=%s," %gamename
gamedata = False
data = ""
historyfile_path = self._get_history_path()
try:
with io.open(historyfile_path, 'r', encoding="utf-8") as historyfile:
for line in historyfile:
if line.startswith(startmarker):
gamedata = True
if gamedata:
data += line
if line.startswith("$end"):
gamedata = False
except Exception as e:
log.error(e)
raise
try:
# Note the regex has to search for either Windows-style line endings (\r\n) or Unix-style (\n)
# Earlier history.dat files had 3 line breaks, newer versions have 2
# We also rename manufacturer and Publisher, and Description is all data between the bio heading and the first
# subheading (e.g. - TECHNICAL - or - CONTRIBUTE -). The romset entry is delimited by the $end.
# Japanese (or other foreign titles) have the translated name in brackets underneath.
# Newer versions have an age-based reference (e.g. A 24-year-old SNK Neo-Geo MVS Cart) between the $bio
# and title line
pattern = r"\$bio(\r?\n){2}" \
"(?P<AgeRef>.*?(\r?\n){2})?" \
"(?P<Game>.*?) \(c\) (?P<ReleaseYear>\d{4}) (?P<Publisher>.*?)\.(\r?\n)" \
"(\((?P<Translation>.*?)\))?(\r?\n){1,2}" \
"(?P<Description>.*?)(\r?\n){2,3}" \
"- [A-Z]"
rdata = re.search(pattern, data, re.DOTALL | re.MULTILINE | re.UNICODE)
if rdata is None:
raise ScraperNoSearchResultsFoundException("Unable to find %s in MAME history dat file" %gamename)
except Exception as e:
print "Error searching for game %s using regex: %s" %(gamename, str(e))
return []
self.resultdata = [rdata.groupdict()]
self.resultdata[0]['id'] = self.resultdata[0]['Game']
self.resultdata[0]['SearchKey'] = self.resultdata[0]['Game']
# HACK - This is only used to retain backwards compatibility with existing scraper, where each key value was a
# list, even if only one value is in that list
for k, v in self.resultdata[0].iteritems():
self.resultdata[0][k] = [v]
return self.resultdata
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:59,代码来源:mame_scraper.py
示例11: __init__
def __init__(self):
self.env = (os.environ.get("OS", "win32"), "win32", )[os.environ.get("OS", "win32") == "xbox"]
log.debug("Running environment detected as {0}".format(self.env))
# Do we need to escape commands before executing?
self.escapeCmd = __addon__.getSetting(util.SETTING_RCB_ESCAPECOMMAND).upper() == 'TRUE'
self.romCollection = None
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:8,代码来源:launcher.py
示例12: __init__
def __init__(self, *args, **kwargs):
log.info("init Edit Rom Collection")
self.gui = kwargs["gui"]
self.romCollections = self.gui.config.romCollections
self.scraperSites = self.gui.config.scraperSites
self.doModal()
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:8,代码来源:dialogeditromcollection.py
示例13: walkDownPath
def walkDownPath(self, files, romPath, maxFolderDepth):
log.info("alkDownPath romPath: %s" % romPath)
files = self.walkDown(files, romPath, maxFolderDepth)
log.info("files after walkDown = %s" % files)
return files
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:8,代码来源:dbupdate.py
示例14: add_genres_to_db
def add_genres_to_db(self, genreIds, gameId):
# If the genre-game link doesn't exist in the DB, create it
for genreId in genreIds:
genreGame = GenreGame(self.gdb).getGenreGameByGenreIdAndGameId(genreId, gameId)
if genreGame is None:
log.debug("Inserting link between game %s and genre %s" % (str(gameId), str(genreId)))
GenreGame(self.gdb).insert((genreId, gameId))
del genreGame
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:8,代码来源:dbupdate.py
示例15: selectScrapersInList
def selectScrapersInList(self, sitesInRomCollection, sitesInList):
log.info("selectScrapersInList")
if len(sitesInRomCollection) >= 1:
self.selectItemInList(sitesInRomCollection[0].name, CONTROL_LIST_SCRAPER1)
else:
self.selectItemInList(util.localize(32854), CONTROL_LIST_SCRAPER1)
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:8,代码来源:dialogeditromcollection.py
示例16: updateControls
def updateControls(self):
log.info('updateControls')
control = self.getControlById(CONTROL_LIST_ROMCOLLECTIONS)
selectedRomCollectionName = str(control.getSelectedItem().getLabel())
self.selectedRomCollection = self.gui.config.getRomCollectionByName(selectedRomCollectionName)
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:8,代码来源:dialogdeleteromcollection.py
示例17: open_xml_url
def open_xml_url(self, **kwargs):
log.info('Retrieving url %s, params = %s' %(kwargs['url'], kwargs['params']))
r = requests.get(kwargs['url'], headers=self._headers, params=kwargs['params'])
log.debug(u"Retrieving {0} as XML - HTTP{1}".format(r.url, r.status_code))
# Need to ensure we are sending back Unicode text
return r.text.encode('utf-8')
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:9,代码来源:web_scraper.py
示例18: __getEncoding
def __getEncoding(self):
# HACK: sys.getfilesystemencoding() is not supported on all systems (e.g. Android)
try:
encoding = sys.getfilesystemencoding()
except Exception as e:
log.warn("Unable to get filesystem encoding, defaulting to UTF-8")
encoding = 'utf-8'
return encoding
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:9,代码来源:launcher.py
示例19: selectItemInList
def selectItemInList(self, options, itemName, controlId):
log.info('selectItemInList')
for i in range(0, len(options)):
option = options[i]
if itemName == option:
control = self.getControlById(controlId)
control.selectItem(i)
break
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:10,代码来源:dialogdeleteromcollection.py
示例20: compareNames
def compareNames(self, gamename, searchkey, checkSubtitle):
if checkSubtitle:
if searchkey.find(gamename) > -1:
log.info("%s is a subtitle of %s. Using result %s" % (gamename, searchkey, searchkey))
return True
else:
if gamename == searchkey:
log.info("Perfect match. Using result %s" % searchkey)
return True
return False
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:11,代码来源:matcher.py
注:本文中的util.Logutil类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论