本文整理汇总了Python中quasar.logger.log.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: register
def register(search, search_movie, search_episode):
try:
payload = json.loads(base64.b64decode(sys.argv[1]))
except:
notify(ADDON.getLocalizedString(30102).encode('utf-8'), time=1000)
return
results = ()
method = {
"search": search,
"search_movie": search_movie,
"search_episode": search_episode,
}.get(payload["method"]) or (lambda *a, **kw: [])
try:
results = ()
try:
objects = method(payload["search_object"])
if objects is not None:
results = tuple(objects)
except Exception as e:
notify("%s: %s" % (ADDON.getLocalizedString(30224).encode('utf-8'), e))
map(log.error, traceback.format_exc().split("\n"))
finally:
try:
req = urllib2.Request(payload["callback_url"], data=json.dumps(results))
with closing(urllib2.urlopen(req)) as response:
log.info("%s" % repr(response))
except Exception as e:
notify("%s: %s" % (ADDON.getLocalizedString(30224).encode('utf-8'), e))
map(log.error, traceback.format_exc().split("\n"))
开发者ID:KillerJoeBR,项目名称:plugin.video.quasar,代码行数:30,代码来源:provider.py
示例2: run
def run(url_suffix=""):
if not os.path.exists(os.path.join(xbmc.translatePath(ADDON.getAddonInfo("path")), ".firstrun")):
notify(ADDON.getLocalizedString(30101).encode('utf-8'))
system_information()
return
socket.setdefaulttimeout(300)
urllib2.install_opener(urllib2.build_opener(NoRedirectHandler()))
url = sys.argv[0].replace("plugin://%s" % ADDON_ID, QUASARD_HOST + url_suffix) + sys.argv[2]
log.info("Requesting %s" % url)
try:
data = _json(url)
except Exception as e:
map(log.error, traceback.format_exc().split("\n"))
notify("%s: %s" % (ADDON.getLocalizedString(30225).encode('utf-8'), e))
return
if not data:
return
if data["content_type"]:
xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_DATE)
xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_GENRE)
xbmcplugin.setContent(HANDLE, data["content_type"])
listitems = range(len(data["items"]))
for i, item in enumerate(data["items"]):
# Translate labels
if item["label"][0:8] == "LOCALIZE":
item["label"] = GetLocalizedString(item["label"])
if item["label2"][0:8] == "LOCALIZE":
item["label2"] = GetLocalizedString(item["label2"])
listItem = xbmcgui.ListItem(label=item["label"], label2=item["label2"], iconImage=item["icon"], thumbnailImage=item["thumbnail"])
if item.get("info"):
listItem.setInfo("video", item["info"])
if item.get("stream_info"):
for type_, values in item["stream_info"].items():
listItem.addStreamInfo(type_, values)
if item.get("art"):
listItem.setArt(item["art"])
if item.get("context_menu"):
# Translate context menus
for m, menu in enumerate(item["context_menu"]):
if menu[0][0:8] == "LOCALIZE":
menu[0] = GetLocalizedString(menu[0])
listItem.addContextMenuItems(item["context_menu"])
listItem.setProperty("isPlayable", item["is_playable"] and "true" or "false")
if item.get("properties"):
for k, v in item["properties"].items():
listItem.setProperty(k, v)
listitems[i] = (item["path"], listItem, not item["is_playable"])
xbmcplugin.addDirectoryItems(HANDLE, listitems, totalItems=len(listitems))
xbmcplugin.endOfDirectory(HANDLE, succeeded=True, updateListing=False, cacheToDisc=True)
开发者ID:razer1s,项目名称:plugin.video.quasar,代码行数:59,代码来源:navigation.py
示例3: Reset
def Reset(self):
for i in self._objects:
try:
self._objects[i].hide()
except:
pass
log.info("Resetting RPC objects...")
self._objects = {}
开发者ID:ShlomiD83,项目名称:plugin.video.quasar,代码行数:8,代码来源:rpc.py
示例4: wait_for_abortRequested
def wait_for_abortRequested(proc, monitor):
monitor.closing.wait()
log.info("quasard: exiting quasard daemon")
try:
proc.terminate()
except OSError:
pass # Process already exited, nothing to terminate
log.info("quasard: quasard daemon exited")
开发者ID:KillerJoeBR,项目名称:plugin.video.quasar,代码行数:8,代码来源:daemon.py
示例5: server_thread
def server_thread():
try:
s = bjsonrpc.createserver(port=JSONRPC_EXT_PORT, handler_factory=QuasarRPCServer)
log.info("quasar: starting jsonrpc service")
s.serve()
log.info("quasar: exiting jsonrpc service")
except Exception:
import traceback
map(log.error, traceback.format_exc().split("\n"))
raise
开发者ID:ShlomiD83,项目名称:plugin.video.quasar,代码行数:10,代码来源:rpc.py
示例6: system_information
def system_information():
build = xbmc.getInfoLabel("System.BuildVersion")
log.info("System information: %(os)s_%(arch)s %(version)s" % PLATFORM)
log.info("Kodi build version: %s" % build)
log.info("OS type: %s" % platform.system())
log.info("uname: %s" % repr(platform.uname()))
return PLATFORM
开发者ID:ditheo,项目名称:plugin.video.quasar,代码行数:7,代码来源:util.py
示例7: jsonrpc_enabled
def jsonrpc_enabled(notify=False):
try:
s = socket.socket()
s.connect(('127.0.0.1', 9090))
s.close()
log.info("Kodi's JSON-RPC service is available, starting up...")
del s
return True
except Exception as e:
log.error(repr(e))
if notify:
xbmc.executebuiltin("ActivateWindow(ServiceSettings)")
dialog = xbmcgui.Dialog()
dialog.ok("Quasar", getLocalizedString(30199))
return False
开发者ID:charly3pins,项目名称:plugin.video.quasar,代码行数:15,代码来源:daemon.py
示例8: GetCurrentView
def GetCurrentView(self):
skinPath = xbmc.translatePath('special://skin/')
xml = os.path.join(skinPath, 'addon.xml')
f = xbmcvfs.File(xml)
read = f.read()
f.close()
try:
src = re.search('defaultresolution="([^"]+)', read, re.DOTALL).group(1)
except:
src = re.search('<res.+?folder="([^"]+)', read, re.DOTALL).group(1)
src = os.path.join(skinPath, src, 'MyVideoNav.xml')
f = xbmcvfs.File(src)
read = f.read()
f.close()
match = re.search('<views>([^<]+)', read, re.DOTALL)
if match:
views = match.group(1)
log.info("Skin's ViewModes: %s" % views)
for view in views.split(','):
if xbmc.getInfoLabel('Control.GetLabel(%s)' % view):
return view
开发者ID:Casti9l,项目名称:plugin.video.quasar,代码行数:21,代码来源:rpc.py
示例9: run
def run():
# Make sure the XBMC jsonrpc server is started.
xbmc.startServer(xbmc.SERVER_JSONRPCSERVER, True)
# Make the monitor
monitor = QuasarMonitor()
threads = [
threading.Thread(target=server_thread), # JSONRPC thread
threading.Thread(target=quasard_thread, args=[monitor]), # Quasard thread
threading.Thread(target=library_thread), # Library thread
]
for t in threads:
t.daemon = True
t.start()
# XBMC loop
while not xbmc.abortRequested:
xbmc.sleep(1000)
log.info("quasar: exiting quasard")
开发者ID:Casti9l,项目名称:plugin.video.quasar,代码行数:21,代码来源:service.py
示例10: get_quasar_binary
def get_quasar_binary():
binary = "quasar" + (PLATFORM["os"] == "windows" and ".exe" or "")
platform = PLATFORM.copy()
if platform["os"] == "darwin": # 64 bits anyway on Darwin
platform["arch"] = "x64"
# elif platform["os"] == "windows": # 32 bits anyway on Windows
# platform["arch"] = "x86"
binary_dir = os.path.join(ADDON.getAddonInfo("path"), "resources", "bin", "%(os)s_%(arch)s" % platform)
if platform["os"] == "android":
binary_dir = binary_dir.replace("/storage/emulated/0", "/storage/emulated/legacy")
app_id = android_get_current_appid()
xbmc_data_path = os.path.join("/data", "data", app_id)
dest_binary_dir = os.path.join(xbmc_data_path, "files", ADDON_ID, "bin", "%(os)s_%(arch)s" % platform)
else:
dest_binary_dir = os.path.join(xbmc.translatePath(ADDON.getAddonInfo("profile")), "bin", "%(os)s_%(arch)s" % platform)
try:
binary_dir = binary_dir.decode("latin1")
dest_binary_dir = dest_binary_dir.decode("latin1")
except UnicodeEncodeError:
log.info("Unable to decode: binary_dir=%s dest_binary_dir=%s" % (repr(binary_dir), repr(dest_binary_dir)))
binary_path = os.path.join(binary_dir, binary)
dest_binary_path = os.path.join(dest_binary_dir, binary)
if not os.path.exists(dest_binary_path) or get_quasard_checksum(dest_binary_path) != get_quasard_checksum(binary_path):
log.info("Updating quasar daemon...")
try:
os.makedirs(dest_binary_dir)
except OSError:
pass
try:
shutil.rmtree(dest_binary_dir)
except:
pass
shutil.copytree(binary_dir, dest_binary_dir)
# Clean stale files in the directory, as this can cause headaches on
# Android when they are unreachable
dest_files = set(os.listdir(dest_binary_dir))
orig_files = set(os.listdir(binary_dir))
log.info("Deleting stale files %s" % (dest_files - orig_files))
for file_ in (dest_files - orig_files):
path = os.path.join(dest_binary_dir, file_)
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
return dest_binary_dir, ensure_exec_perms(dest_binary_path)
开发者ID:dmartinpro,项目名称:plugin.video.quasar,代码行数:52,代码来源:daemon.py
示例11: quasard_thread
def quasard_thread(monitor):
crash_count = 0
try:
while not xbmc.abortRequested:
log.info("quasard: starting quasard")
proc = start_quasard(stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if not proc:
break
threading.Thread(target=wait_for_abortRequested, args=[proc, monitor]).start()
if PLATFORM["os"] == "windows":
while proc.poll() is None:
log.info(proc.stdout.readline())
else:
# Kodi hangs on some Android (sigh...) systems when doing a blocking
# read. We count on the fact that Quasar daemon flushes its log
# output on \n, creating a pretty clean output
import fcntl
import select
fd = proc.stdout.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
while proc.poll() is None:
try:
to_read, _, _ = select.select([proc.stdout], [], [])
for ro in to_read:
line = ro.readline()
if line == "": # write end is closed
break
log.info(line)
except IOError:
time.sleep(1) # nothing to read, sleep
if proc.returncode == 0 or xbmc.abortRequested:
break
crash_count += 1
notify(getLocalizedString(30100), time=3000)
xbmc.executebuiltin("Dialog.Close(all, true)")
system_information()
time.sleep(5)
if crash_count >= 3:
notify(getLocalizedString(30110), time=3000)
break
except Exception as e:
import traceback
map(log.error, traceback.format_exc().split("\n"))
notify("%s: %s" % (getLocalizedString(30226), repr(e).encode('utf-8')))
raise
开发者ID:charly3pins,项目名称:plugin.video.quasar,代码行数:50,代码来源:daemon.py
示例12: quasard_thread
def quasard_thread(monitor):
try:
while not xbmc.abortRequested:
log.info("quasard: starting quasard")
proc = start_quasard(stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if not proc:
break
threading.Thread(target=wait_for_abortRequested, args=[proc, monitor]).start()
if PLATFORM["os"] == "windows":
while proc.poll() is None:
log.info(proc.stdout.readline())
else:
# Kodi hangs on some Android (sigh...) systems when doing a blocking
# read. We count on the fact that Quasar daemon flushes its log
# output on \n, creating a pretty clean output
import fcntl
fd = proc.stdout.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
while proc.poll() is None:
try:
log.info(proc.stdout.readline())
continue
except IOError:
time.sleep(1) # nothing to read, sleep
if proc.returncode == 0 or xbmc.abortRequested:
break
notify(ADDON.getLocalizedString(30100).encode('utf-8'), time=3000)
xbmc.executebuiltin("Dialog.Close(all, true)")
system_information()
time.sleep(3)
except Exception as e:
notify("%s: %s" % (ADDON.getLocalizedString(30226).encode('utf-8'), e))
map(log.error, traceback.format_exc().split("\n"))
raise
开发者ID:trisk,项目名称:plugin.video.quasar,代码行数:39,代码来源:daemon.py
示例13: get_quasar_binary
def get_quasar_binary():
binary = "quasar" + (PLATFORM["os"] == "windows" and ".exe" or "")
binary_dir = os.path.join(ADDON.getAddonInfo("path"), "resources", "bin", "%(os)s_%(arch)s" % PLATFORM)
if PLATFORM["os"] == "android":
log.info("Detected binary folder: %s" % binary_dir)
binary_dir_legacy = binary_dir.replace("/storage/emulated/0", "/storage/emulated/legacy")
if os.path.exists(binary_dir_legacy):
binary_dir = binary_dir_legacy
log.info("Using binary folder: %s" % binary_dir)
app_id = android_get_current_appid()
xbmc_data_path = os.path.join("/data", "data", app_id)
dest_binary_dir = os.path.join(xbmc_data_path, "files", ADDON_ID, "bin", "%(os)s_%(arch)s" % PLATFORM)
else:
dest_binary_dir = os.path.join(xbmc.translatePath(ADDON.getAddonInfo("profile")), "bin", "%(os)s_%(arch)s" % PLATFORM)
try:
binary_dir = binary_dir.decode("latin1")
dest_binary_dir = dest_binary_dir.decode("latin1")
except UnicodeEncodeError:
log.info("Unable to decode: binary_dir=%s dest_binary_dir=%s" % (repr(binary_dir), repr(dest_binary_dir)))
binary_path = os.path.join(binary_dir, binary)
dest_binary_path = os.path.join(dest_binary_dir, binary)
if not os.path.exists(binary_path):
notify(ADDON.getLocalizedString(30103).encode('utf-8'))
system_information()
return False, False
if not os.path.exists(dest_binary_path) or get_quasard_checksum(dest_binary_path) != get_quasard_checksum(binary_path):
log.info("Updating quasar daemon...")
try:
os.makedirs(dest_binary_dir)
except OSError:
pass
try:
shutil.rmtree(dest_binary_dir)
except OSError as e:
log.error("Unable to remove destination path for update: %s" % e)
system_information()
pass
try:
shutil.copytree(binary_dir, dest_binary_dir)
except OSError as e:
log.error("Unable to copy to destination path for update: %s" % e)
notify(ADDON.getLocalizedString(30227).encode('utf-8'))
system_information()
pass
# Clean stale files in the directory, as this can cause headaches on
# Android when they are unreachable
dest_files = set(os.listdir(dest_binary_dir))
orig_files = set(os.listdir(binary_dir))
log.info("Deleting stale files %s" % (dest_files - orig_files))
for file_ in (dest_files - orig_files):
path = os.path.join(dest_binary_dir, file_)
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
return dest_binary_dir, ensure_exec_perms(dest_binary_path)
开发者ID:Wesleyl89,项目名称:plugin.video.quasar,代码行数:63,代码来源:daemon.py
示例14: wait_for_abortRequested
def wait_for_abortRequested(proc, monitor):
monitor.closing.wait()
log.info("quasard: exiting quasard daemon")
proc.terminate()
log.info("quasard: quasard daemon exited")
开发者ID:Wesleyl89,项目名称:plugin.video.quasar,代码行数:5,代码来源:daemon.py
示例15: start_quasard
def start_quasard(**kwargs):
jsonrpc_failures = 0
while jsonrpc_enabled() is False:
jsonrpc_failures += 1
log.warning("Unable to connect to Kodi's JSON-RPC service, retrying...")
if jsonrpc_failures > 1:
time.sleep(5)
if not jsonrpc_enabled(notify=True):
log.error("Unable to reach Kodi's JSON-RPC service, aborting...")
return False
else:
break
time.sleep(3)
quasar_dir, quasar_binary = get_quasar_binary()
if quasar_dir is False or quasar_binary is False:
return False
lockfile = os.path.join(ADDON_PATH, ".lockfile")
if os.path.exists(lockfile):
log.warning("Existing process found from lockfile, killing...")
try:
with open(lockfile) as lf:
pid = int(lf.read().rstrip(" \t\r\n\0"))
os.kill(pid, 9)
except Exception as e:
log.error(repr(e))
if PLATFORM["os"] == "windows":
log.warning("Removing library.db.lock file...")
try:
library_lockfile = os.path.join(xbmc.translatePath(ADDON.getAddonInfo("profile")).decode('utf-8'), "library.db.lock")
os.remove(library_lockfile)
except Exception as e:
log.error(repr(e))
SW_HIDE = 0
STARTF_USESHOWWINDOW = 1
args = [quasar_binary]
kwargs["cwd"] = quasar_dir
if PLATFORM["os"] == "windows":
args[0] = getWindowsShortPath(quasar_binary)
kwargs["cwd"] = getWindowsShortPath(quasar_dir)
si = subprocess.STARTUPINFO()
si.dwFlags = STARTF_USESHOWWINDOW
si.wShowWindow = SW_HIDE
clear_fd_inherit_flags()
kwargs["startupinfo"] = si
else:
env = os.environ.copy()
env["LD_LIBRARY_PATH"] = "%s:%s" % (quasar_dir, env.get("LD_LIBRARY_PATH", ""))
kwargs["env"] = env
kwargs["close_fds"] = True
wait_counter = 1
while xbmc.getCondVisibility('Window.IsVisible(10140)'):
if wait_counter == 1:
log.info('Add-on settings currently opened, waiting before starting...')
if wait_counter > 300:
break
time.sleep(1)
return subprocess.Popen(args, **kwargs)
开发者ID:charly3pins,项目名称:plugin.video.quasar,代码行数:66,代码来源:daemon.py
注:本文中的quasar.logger.log.info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论