本文整理汇总了Python中util.Logutil.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Logutil.debug方法的具体用法?Python Logutil.debug怎么用?Python Logutil.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Logutil
的用法示例。
在下文中一共展示了Logutil.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readImagePlacing
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
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, ''
示例2: get_scraper_by_name
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
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
示例3: insertFile
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
def insertFile(self, fileName, gameId, fileType, romCollectionId, publisherId, developerId):
log.debug("Begin Insert file: %s" % fileName)
parentId = None
# TODO console and romcollection could be done only once per RomCollection
# fileTypeRow[3] = parent
if fileType.parent == 'game':
parentId = gameId
elif fileType.parent == 'romcollection':
parentId = romCollectionId
elif fileType.parent == 'publisher':
parentId = publisherId
elif fileType.parent == 'developer':
parentId = developerId
log.info("Inserting file with parent {0} (type {1})".format(parentId, fileType.parent))
fileRow = File(self.gdb).getFileByNameAndTypeAndParent(fileName, fileType.id, parentId)
if fileRow is None:
log.info("File does not exist in database. Insert file: %s" % fileName)
f = File(self.gdb)
try:
f.insert((fileName, fileType.id, parentId))
except Exception, (exc):
log.warn("Error inserting into database: %s" % fileName)
示例4: __checkGameHasSaveStates
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
def __checkGameHasSaveStates(self, gameRow, filenameRows):
if self.romCollection.saveStatePath == '':
log.debug("No save state path set")
return ''
rom = filenameRows[0][0]
saveStatePath = self.__replacePlaceholdersInParams(self.romCollection.saveStatePath, rom, gameRow)
saveStateFiles = glob.glob(saveStatePath)
if len(saveStateFiles) == 0:
log.debug("No save state files found")
return ''
log.info('saveStateFiles found: ' + str(saveStateFiles))
# don't select savestatefile if ASKNUM is requested in Params
if re.search('(?i)%ASKNUM%', self.romCollection.saveStateParams):
return saveStateFiles[0]
options = [util.localize(32165)]
for f in saveStateFiles:
options.append(os.path.basename(f))
selectedFile = xbmcgui.Dialog().select(util.localize(32166), options)
# If selections is canceled or "Don't launch statefile" option
if selectedFile < 1:
return ''
return saveStateFiles[selectedFile - 1]
示例5: add_romfiles_to_db
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
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
示例6: retrieve
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
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
示例7: add_genres_to_db
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
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
示例8: __init__
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
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
示例9: open_xml_url
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
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')
示例10: checkRomfileAlreadyExists
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
def checkRomfileAlreadyExists(self, filename, enableFullReimport):
isUpdate = False
gameId = None
log.debug("Checking if file already exists in DB: %s" % filename)
romFile = File(self.gdb).getFileByNameAndType(filename, 0)
if romFile is not None:
isUpdate = True
gameId = romFile[3] # FIXME TODO Replace with FILE_parentId
log.info("File '%s' already exists in database." % filename)
log.info("Always rescan imported games = {0}".format(enableFullReimport))
if enableFullReimport is False:
log.info("Won't scrape this game again. Set 'Always rescan imported games' to True to force scraping.")
return False, isUpdate, gameId
else:
log.debug("Couldn't find file in DB")
return True, isUpdate, gameId
示例11: _parse_search_results
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
def _parse_search_results(self, response):
results = []
""" response is expected to be a JSON object """
log.debug("Parsing response for search results: {0}".format(response))
if len(response["games"]) == 0:
log.warn("No results found")
return results
for result in response['games']:
results.append({'id': result['game_id'],
'title': result['title'],
'releaseDate': "", # MobyGames search doesn't return a year in brief mode
'SearchKey': [result['title']]})
log.debug("Found {0} results using requests JSON parser: {1}".format(len(results), results))
return results
示例12: resolveParseResult
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
def resolveParseResult(self, result, itemName):
resultValue = ""
try:
resultValue = result[itemName][0]
resultValue = util.html_unescape(resultValue)
resultValue = resultValue.strip()
# unescape ugly html encoding from websites
resultValue = HTMLParser.HTMLParser().unescape(resultValue)
except Exception as e:
# log.warn("Error while resolving item: " + itemName + " : " + str(exc))
log.warn("Error while resolving item: {0} : {1} {2}".format(itemName, type(e), str(e)))
try:
log.debug("Result " + itemName + " = " + resultValue)
except:
pass
return resultValue
示例13: addNewElements
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
def addNewElements(self, results, newResults):
""" Add fields from the results to the existing set of results, adding if new, replacing if empty. This allows
us to add fields from subsequent site scrapes that were missing or not available in previous sites.
Args:
results: Existing results dict from previous scrapes
newResults: Result dict from most recent scrape
Returns:
Updated dict of result fields
"""
try:
log.debug("Before merging results: %s vs %s" % (results.items(), newResults.items()))
# Retain any existing key values that aren't an empty list, overwrite all others
z = dict(newResults.items() + dict((k, v) for k, v in results.iteritems() if len(v) > 0).items())
log.debug("After merging results: %s" % z.items())
return z
except Exception as e:
# Return original results without doing anything
log.warn("Error when merging results: %s" % e)
return results
示例14: __copyLauncherScriptsToUserdata
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
def __copyLauncherScriptsToUserdata(self):
log.info('__copyLauncherScriptsToUserdata')
oldBasePath = os.path.join(util.getAddonInstallPath(), 'resources', 'scriptfiles')
newBasePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')
files = []
# Copy applaunch shell script/batch file
if self.env == 'win32':
files.append('applaunch.bat')
else:
files.append('applaunch.sh')
# Copy VBS files
if self.env == 'win32' and __addon__.getSetting(util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true':
files += ['applaunch-vbs.bat', 'LaunchKodi.vbs', 'Sleep.vbs']
for f in files:
if not xbmcvfs.exists(os.path.join(newBasePath, f)):
log.debug("Copying file {0} from {1} to {2}".format(f, oldBasePath, newBasePath))
if not xbmcvfs.copy(os.path.join(oldBasePath, f), os.path.join(newBasePath, f)):
log.warn("Error copying file")
示例15: open_json_url
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import debug [as 别名]
def open_json_url(self, **kwargs):
log.info('Retrieving url %s, params = %s' %(kwargs['url'], kwargs['params']))
try:
r = requests.get(kwargs['url'], headers=self._headers, params=kwargs['params'])
except ValueError as e:
# Typically non-JSON response
raise ScraperUnexpectedContentException("Non-JSON response received")
log.debug(u"Retrieving {0} as JSON - HTTP{1}".format(r.url, r.status_code))
if r.status_code == 401:
# Mobygames and GiantBomb send a 401 if the API key is invalid
raise ScraperUnauthorisedException("Invalid API key sent")
if r.status_code == 429:
raise ScraperExceededAPIQuoteException("Scraper exceeded API key limits")
if r.status_code == 500:
raise ScraperWebsiteUnavailableException("Website unavailable")
return r.json()