本文整理汇总了Python中maraschino.logger.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_dir
def create_dir(dir):
if not os.path.exists(dir):
try:
logger.log('TRAKT :: Creating dir %s' % dir, 'INFO')
os.makedirs(dir)
except:
logger.log('TRAKT :: Problem creating dir %s' % dir, 'ERROR')
示例2: xhr_headphones_artists
def xhr_headphones_artists(mobile=False):
logger.log("HEADPHONES :: Fetching artists list", "INFO")
artists = []
try:
headphones = headphones_api("getIndex")
updates = headphones_api("getVersion")
except Exception as e:
if mobile:
headphones_exception(e)
return artists
return headphones_exception(e)
for artist in headphones:
if not "Fetch failed" in artist["ArtistName"]:
try:
artist["Percent"] = int(100 * float(artist["HaveTracks"]) / float(artist["TotalTracks"]))
except:
artist["Percent"] = 0
if not hp_compact() and not mobile:
try:
artist["ThumbURL"] = hp_artistart(artist["ArtistID"])
except:
pass
artists.append(artist)
if mobile:
return artists
return render_template(
"headphones-artists.html", headphones=True, artists=artists, updates=updates, compact=hp_compact()
)
示例3: xhr_headphones_artist_action
def xhr_headphones_artist_action(artistid, action, mobile=False):
if action == "pause":
logger.log("HEADPHONES :: Pausing artist", "INFO")
command = "pauseArtist&id=%s" % artistid
elif action == "resume":
logger.log("HEADPHONES :: Resuming artist", "INFO")
command = "resumeArtist&id=%s" % artistid
elif action == "refresh":
logger.log("HEADPHONES :: Refreshing artist", "INFO")
command = "refreshArtist&id=%s" % artistid
elif action == "remove":
logger.log("HEADPHONES :: Removing artist", "INFO")
command = "delArtist&id=%s" % artistid
elif action == "add":
logger.log("HEADPHONES :: Adding artist", "INFO")
command = "addArtist&id=%s" % artistid
try:
if command == "remove":
headphones_api(command, False)
elif command == "pause":
headphones_api(command, False)
elif command == "resume":
headphones_api(command, False)
else:
Thread(target=headphones_api, args=(command, False)).start()
except Exception as e:
if mobile:
headphones_exception(e)
return jsonify(error="failed")
return headphones_exception(e)
return jsonify(status="successful")
示例4: xhr_trakt_recommendations
def xhr_trakt_recommendations(type=None, mobile=False):
if not type:
type = get_setting_value('trakt_default_media')
logger.log('TRAKT :: Fetching %s recommendations' % type, 'INFO')
url = 'http://api.trakt.tv/recommendations/%s/%s' % (type, trakt_apikey())
params = {
'hide_collected': True,
'hide_watchlisted': True
}
try:
recommendations = trak_api(url, params)
except Exception as e:
trakt_exception(e)
return render_template('traktplus/trakt-base.html', message=e)
random.shuffle(recommendations)
for item in recommendations:
item['poster'] = cache_image(item['images']['poster'], type)
while THREADS:
time.sleep(1)
if mobile:
return recommendations
return render_template('traktplus/trakt-recommendations.html',
type=type.title(),
recommendations=recommendations,
title='Recommendations',
)
示例5: json_login
def json_login():
if not loginToPlex():
return jsonify(success=False, msg='Failed to login to plex.tv, plese make sure this is a valid username/password.')
# Delete info for previous accounts
try:
PlexServer.query.delete()
except:
logger.log('Plex :: Failed to delete old server info', 'WARNING')
# Populate servers for new user
if not getServers():
return jsonify(success=False, msg='Failed to retrieve server information from https://plex.tv/pms/servers.')
# Set active server to 0 (no server selected)
try:
active_server = get_setting('active_server')
if not active_server:
active_server = Setting('active_server', 0)
db_session.add(active_server)
db_session.commit()
else:
active_server.value = 0
db_session.add(active_server)
db_session.commit()
except:
logger.log('Plex :: Failed to reset server, please make sure to select new one.', 'WARNING')
# return a list of (server name, server id)
return jsonify(success=True, servers=listServers())
示例6: xhr_trakt_trending
def xhr_trakt_trending(type=None, mobile=False):
if not type:
type = get_setting_value('trakt_default_media')
limit = int(get_setting_value('trakt_trending_limit'))
logger.log('TRAKT :: Fetching trending %s' % type, 'INFO')
url = 'http://api.trakt.tv/%s/trending.json/%s' % (type, trakt_apikey())
try:
trakt = trak_api(url)
except Exception as e:
trakt_exception(e)
return render_template('traktplus/trakt-base.html', message=e)
if mobile:
return trakt
if len(trakt) > limit:
trakt = trakt[:limit]
for item in trakt:
item['images']['poster'] = cache_image(item['images']['poster'], type)
while THREADS:
time.sleep(1)
return render_template('traktplus/trakt-trending.html',
trending=trakt,
type=type.title(),
title='Trending',
)
示例7: xhr_trakt_watchlist
def xhr_trakt_watchlist(user, type=None, mobile=False):
if not type:
type = get_setting_value('trakt_default_media')
logger.log('TRAKT :: Fetching %s\'s %s watchlist' % (user, type), 'INFO')
url = 'http://api.trakt.tv/user/watchlist/%s.json/%s/%s/' % (type, trakt_apikey(), user)
try:
trakt = trak_api(url)
except Exception as e:
trakt_exception(e)
return render_template('traktplus/trakt-base.html', message=e)
if mobile:
return trakt
if trakt == []:
trakt = [{'empty': True}]
return render_template('traktplus/trakt-watchlist.html',
watchlist=trakt,
type=type.title(),
user=user,
title='Watchlist',
)
示例8: xhr_sickrage
def xhr_sickrage():
params = '/?cmd=future&sort=date'
try:
sickrage = sickrage_api(params)
compact_view = get_setting_value('sickrage_compact') == '1'
show_airdate = get_setting_value('sickrage_airdate') == '1'
if sickrage['result'].rfind('success') >= 0:
logger.log('SICKRAGE :: Successful API call to %s' % params, 'DEBUG')
sickrage = sickrage['data']
for time in sickrage:
for episode in sickrage[time]:
episode['image'] = get_pic(episode['indexerid'], 'banner')
logger.log('SICKRAGE :: Successful %s' % (episode['image']), 'DEBUG')
except:
return render_template('sickrage.html',
sickrage='',
)
return render_template('sickrage.html',
url=sickrage_url_no_api(),
app_link=sickrage_url_no_api(),
sickrage=sickrage,
missed=sickrage['missed'],
today=sickrage['today'],
soon=sickrage['soon'],
later=sickrage['later'],
compact_view=compact_view,
show_airdate=show_airdate,
)
示例9: xbmc_get_moviesets
def xbmc_get_moviesets(xbmc, setid):
logger.log("LIBRARY :: Retrieving movie set: %s" % setid, "INFO")
version = xbmc.Application.GetProperties(properties=["version"])["version"]["major"]
sort = xbmc_sort("movies")
properties = ["playcount", "thumbnail", "year", "rating", "set"]
params = {"sort": sort, "properties": properties}
if version == 11: # Eden
params["properties"].append("setid")
else: # Frodo
params["filter"] = {"setid": setid}
movies = xbmc.VideoLibrary.GetMovies(**params)["movies"]
if version == 11: # Eden
movies = [x for x in movies if setid in x["setid"]]
setlabel = xbmc.VideoLibrary.GetMovieSetDetails(setid=setid)["setdetails"]["label"]
for movie in movies:
movie["set"] = setlabel
if get_setting_value("xbmc_movies_hide_watched") == "1":
movies = [x for x in movies if not x["playcount"]]
movies[0]["setid"] = setid
return movies
示例10: xhr_headphones_album
def xhr_headphones_album(albumid, mobile=False):
logger.log('HEADPHONES :: Fetching album', 'INFO')
try:
headphones = headphones_api('getAlbum&id=%s' % albumid)
except Exception as e:
return headphones_exception(e)
album = headphones['album'][0]
try:
album['ThumbURL'] = hp_albumart(album['AlbumID'])
except:
pass
album['TotalDuration'] = 0
for track in headphones['tracks']:
if track['TrackDuration'] == None:
track['TrackDuration'] = 0
album['TotalDuration'] = album['TotalDuration'] + int(track['TrackDuration'])
track['TrackDuration'] = convert_track_duration(track['TrackDuration'])
album['TotalDuration'] = convert_track_duration(album['TotalDuration'])
album['Tracks'] = len(headphones['tracks'])
if mobile:
return headphones
return render_template('headphones/album.html',
album=headphones,
headphones=True,
compact=hp_compact(),
)
示例11: xhr_trakt_hated
def xhr_trakt_hated(user, type):
logger.log('TRAKT :: Fetching %s\'s hated %s' % (user, type), 'INFO')
apikey = get_setting_value('trakt_api_key')
url = 'http://api.trakt.tv/user/library/%s/hated.json/%s/%s/' % (type, apikey, user)
try:
result = urllib.urlopen(url).read()
except:
logger.log('TRAKT :: Problem fething URL', 'ERROR')
return render_template('trakt-base.html', message=url_error)
trakt = json.JSONDecoder().decode(result)
amount = len(trakt)
if trakt == []:
trakt = [{'empty': True}]
return render_template('trakt-hated.html',
hated = trakt,
amount = amount,
type = type.title(),
user = user,
title = 'Hated',
)
示例12: download_image
def download_image(image, file_path):
try:
logger.log('TRAKT :: Creating file %s' % file_path, 'INFO')
downloaded_image = file(file_path, 'wb')
except:
logger.log('TRAKT :: Failed to create file %s' % file_path, 'ERROR')
logger.log('TRAKT :: Using remote image', 'INFO')
threads.pop()
return image
try:
logger.log('TRAKT :: Downloading %s' % image, 'INFO')
image_on_web = urllib.urlopen(image)
while True:
buf = image_on_web.read(65536)
if len(buf) == 0:
break
downloaded_image.write(buf)
downloaded_image.close()
image_on_web.close()
except:
logger.log('TRAKT :: Failed to download %s' % image, 'ERROR')
threads.pop()
return
示例13: xhr_trakt_trending
def xhr_trakt_trending(type):
logger.log('TRAKT :: Fetching trending %s' % type, 'INFO')
apikey = get_setting_value('trakt_api_key')
url = 'http://api.trakt.tv/%s/trending.json/%s' % (type, apikey)
try:
result = urllib.urlopen(url).read()
except:
logger.log('TRAKT :: Problem fething URL', 'ERROR')
return render_template('trakt-base.html', message=url_error)
trakt = json.JSONDecoder().decode(result)
if len(trakt) > 20:
trakt = trakt[:20]
for item in trakt:
item['images']['poster'] = cache_image(item['images']['poster'], type)
while threads:
time.sleep(1)
return render_template('trakt-trending.html',
trending = trakt,
type = type.title(),
title = 'Trending',
)
示例14: gitUpdate
def gitUpdate():
"""Update Maraschino using git"""
output, err = runGit('pull origin %s' % branch)
if not output:
logger.log('Couldn\'t download latest version', 'ERROR')
maraschino.USE_GIT = False
return 'failed'
for line in output.split('\n'):
if 'Already up-to-date.' in line:
logger.log('UPDATER :: Already up to date', 'INFO')
logger.log('UPDATER :: Git output: ' + str(output), 'DEBUG')
return 'complete'
elif line.endswith('Aborting.'):
logger.log('UPDATER :: Unable to update from git: '+line, 'ERROR')
logger.log('UPDATER :: Output: ' + str(output), 'DEBUG')
maraschino.USE_GIT = False
return 'failed'
maraschino.CURRENT_COMMIT = maraschino.LATEST_COMMIT
writeVersion(maraschino.LATEST_COMMIT)
maraschino.COMMITS_BEHIND = 0
return 'complete'
示例15: xbmc_get_seasons
def xbmc_get_seasons(xbmc, tvshowid):
logger.log("LIBRARY :: Retrieving seasons for tvshowid: %s" % tvshowid, "INFO")
version = xbmc.Application.GetProperties(properties=["version"])["version"]["major"]
params = {"sort": xbmc_sort("seasons")}
if version < 12 and params["sort"]["method"] in ["rating", "playcount", "random"]: # Eden
logger.log(
'LIBRARY :: Sort method "%s" is not supported in XBMC Eden. Reverting to "label"'
% params["sort"]["method"],
"INFO",
)
change_sort("seasons", "label")
params["sort"] = xbmc_sort("seasons")
params["tvshowid"] = tvshowid
params["properties"] = ["playcount", "showtitle", "tvshowid", "season", "thumbnail", "episode"]
seasons = xbmc.VideoLibrary.GetSeasons(**params)["seasons"]
if get_setting_value("xbmc_seasons_hide_watched") == "1":
seasons = [x for x in seasons if not x["playcount"]]
# Add episode playcounts to seasons
for season in seasons:
episodes = xbmc.VideoLibrary.GetEpisodes(tvshowid=tvshowid, season=season["season"], properties=["playcount"])[
"episodes"
]
season["unwatched"] = len([x for x in episodes if not x["playcount"]])
return seasons