本文整理汇总了Python中xbmc.Monitor方法的典型用法代码示例。如果您正苦于以下问题:Python xbmc.Monitor方法的具体用法?Python xbmc.Monitor怎么用?Python xbmc.Monitor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbmc
的用法示例。
在下文中一共展示了xbmc.Monitor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def __init__ (self):
xbmc.Player.__init__(self)
log('Player - init')
self.token = __addon__.getSetting('token')
self.facebook = __addon__.getSetting('facebook')
self.twitter = __addon__.getSetting('twitter')
self.welcome = __addon__.getSetting('welcome')
self.notifications = __addon__.getSetting('notifications')
self.notif_during_playback = __addon__.getSetting('notif_during_playback')
self.notif_scrobbling = __addon__.getSetting('notif_scrobbling')
self.progress = __addon__.getSetting('progress')
self.http = __addon__.getSetting('http')
self.http_playing = False
self.emotion = __addon__.getSetting('emotion')
self.defaultemotion = __addon__.getSetting('defaultemotion')
if self.token is '':
log(__language__(32901))
if self.notifications == 'true':
notif(__language__(32901), time=2500)
return
self.user = self._GetUser()
if not self.user.is_authenticated:
return
self._monitor = Monitor(action = self._reset)
log('Player - monitor')
示例2: __init__
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def __init__(self):
try:
self.enabled = g.ADDON.getSettingInt('lib_auto_upd_mode') == 2
except Exception: # pylint: disable=broad-except
# If settings.xml was not created yet, as at first service run
# g.ADDON.getSettingInt('lib_auto_upd_mode') will thrown a TypeError
# If any other error appears, we don't want the service to crash,
# let's return None in all case
self.enabled = False
self.startidle = 0
self.next_schedule = _compute_next_schedule()
# Update library variables
xbmc.Monitor.__init__(self)
self.scan_in_progress = False
self.scan_awaiting = False
AddonSignals.registerSlot(
g.ADDON.getAddonInfo('id'), common.Signals.LIBRARY_UPDATE_REQUESTED,
self.update_kodi_library)
示例3: run
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def run(self):
"""Monitor and process the event queue"""
common.debug('[Event queue monitor] Thread started')
monitor = xbmc.Monitor()
while not monitor.abortRequested() and not self._stop_requested:
try:
# Take the first queued item
event = self.queue_events.get_nowait()
# Process the request
continue_queue = self._process_event_request(event)
if not continue_queue:
# Ban future requests from this event id
self.banned_events_ids += [event.get_event_id()]
except queue.Empty:
pass
except Exception as exc: # pylint: disable=broad-except
common.error('[Event queue monitor] An error has occurred: {}', exc)
import traceback
common.error(g.py2_decode(traceback.format_exc(), 'latin-1'))
self.clear_queue()
monitor.waitForAbort(1)
示例4: __init__
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def __init__(self):
self.addon = xbmcaddon.Addon(id=ADDON_ID)
self.win = xbmcgui.Window(10000)
self.kodimonitor = xbmc.Monitor()
self.spotty = Spotty()
# spotipy and the webservice are always prestarted in the background
# the auth key for spotipy will be set afterwards
# the webserver is also used for the authentication callbacks from spotify api
self.sp = spotipy.Spotify()
self.connect_player = ConnectPlayer(sp=self.sp, spotty=self.spotty)
self.proxy_runner = ProxyRunner(self.spotty)
self.proxy_runner.start()
webport = self.proxy_runner.get_port()
log_msg('started webproxy at port {0}'.format(webport))
# authenticate at startup
self.renew_token()
# start mainloop
self.main_loop()
示例5: run
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def run(self):
'''Main run loop for the background thread'''
last_title = ""
monitor = xbmc.Monitor()
while not monitor.abortRequested() and self.active:
cur_playback = self.get_curplayback()
if cur_playback and cur_playback.get("item"):
if cur_playback["shuffle_state"] != self.dialog.shuffle_state:
self.toggle_shuffle(cur_playback["shuffle_state"])
if cur_playback["repeat_state"] != self.dialog.repeat_state:
self.set_repeat(cur_playback["repeat_state"])
if cur_playback["is_playing"] != self.dialog.is_playing:
self.toggle_playstate(cur_playback["is_playing"])
cur_title = cur_playback["item"]["uri"]
if cur_title != last_title:
last_title = cur_title
trackdetails = cur_playback["item"]
self.update_info(trackdetails)
monitor.waitForAbort(2)
del monitor
示例6: precache_library
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def precache_library(self):
if not self.win.getProperty("Spotify.PreCachedItems"):
monitor = xbmc.Monitor()
self.win.setProperty("Spotify.PreCachedItems", "busy")
userplaylists = self.get_user_playlists(self.userid)
for playlist in userplaylists:
self.get_playlist_details(playlist['owner']['id'], playlist["id"])
if monitor.abortRequested():
return
self.get_savedalbums()
if monitor.abortRequested():
return
self.get_savedartists()
if monitor.abortRequested():
return
self.get_saved_tracks()
del monitor
self.win.setProperty("Spotify.PreCachedItems", "done")
示例7: __init__
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def __init__(self, dbtype=None, tvshowid=None, attempt_reconnect=False):
self.dbtype = None
self.database = None
self.get_database(dbtype, tvshowid)
if self.database or not dbtype or not attempt_reconnect:
return
# If we didn't get database retry in case Kodi was starting up
retries = 0
monitor = xbmc.Monitor()
while not monitor.abortRequested() and not self.database and retries < 5:
monitor.waitForAbort(1)
self.get_database(dbtype, tvshowid)
retries += 1
utils.kodi_log(u'Unable to retrive {} KodiDB!\nAttempting to Reconnect - Attempt {}'.format(dbtype, retries), 1)
if not self.database:
utils.kodi_log(u'Getting KodiDB {} FAILED!'.format(dbtype), 1)
示例8: __init__
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def __init__(self):
super(ServiceMonitor, self).__init__()
self.property_basename = 'TMDbHelper.ListItem'
self.kodimonitor = xbmc.Monitor()
self.container = 'Container.'
self.containeritem = 'ListItem.'
self.exit = False
self.cur_item = 0
self.pre_item = 1
self.pre_folder = None
self.cur_folder = None
self.properties = set()
self.indxproperties = set()
self.cron_job = CronJob(self.addon.getSettingInt('library_autoupdate_hour'))
self.cron_job.setName('Cron Thread')
self.playermonitor = None
self.run_monitor()
示例9: __init__
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def __init__(self, monitor=None):
self.monitor = monitor or xbmc.Monitor()
self.language = None
self.autolanguages = None
self.progress = xbmcgui.DialogProgressBG()
self.visible = False
self.freshstart = "0"
self.processed = ProcessedItems()
self.gatherer = None
self.downloader = None
self.chunkcount = 1
self.currentchunk = 0
self.debug = False
self.localmode = False
settings.update_settings()
mediatypes.update_settings()
示例10: register_instance
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def register_instance(self, waittime=1):
"""
Tries to register an instance. If another
instance (thread/process) is active, the method
locks until the process is terminated or a
timeout occurs
Args:
waittime(int, optional): Timeout for registering
the instance. Default is 1 second
"""
if self.bad_instance():
self.service.info(
'Found other instance with id {}', self.instance_id)
self.service.info(
'Startup delayed by {} second(s) waiting the other instance to shut down', waittime)
self.service.set_setting(self.setting_id, self.instance_id)
xbmc.Monitor.waitForAbort(self, waittime)
else:
self.service.set_setting(self.setting_id, self.instance_id)
示例11: wait_for_abort
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def wait_for_abort(self, timeout=None):
"""
Waits until Kodi is shutting down or a specified timeout
has occurred. Returns `True` if Kodi is shutting down.
Args:
timeout(int, optional): Number of seconds to wait.
If not specified, the funtion waits forever.
"""
if timeout is None:
# infinite wait
while not self.abort_requested():
if xbmc.Monitor.waitForAbort(self, 1):
return True
return True
else:
for _ in range(timeout):
if self.bad_instance() or xbmc.Monitor.waitForAbort(self, 1):
return True
return self.bad_instance()
示例12: threaded
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def threaded(self):
""" A loop threaded function, so you can do another things meanwhile """
log("login thread start = {0}".format(self))
cnt = 0
while True:
log("Still waiting... {0}".format(cnt))
if self.pin_check(self.pin):
self.success()
self.close()
break
if self.canceled or cnt >= 220:
notify(get_str(32031))
break
cnt += 1
xbmc.Monitor().waitForAbort(4)
log("Stop waiting")
示例13: get_album_json_thread
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def get_album_json_thread(self):
try:
while not xbmc.Monitor().waitForAbort(timeout=0.01) and not self.abortAlbumThreads:
try:
album_id = self.albumQueue.get_nowait()
except:
break
try:
self.get_album(album_id, withCache=False)
except requests.HTTPError as e:
r = e.response
msg = _T(30505)
try:
msg = r.reason
msg = r.json().get('userMessage')
except:
pass
log('Error getting Album ID %s' % album_id, xbmc.LOGERROR)
if r.status_code == 429 and not self.abortAlbumThreads:
self.abortAlbumThreads = True
log('Too many requests. Aborting Workers ...', xbmc.LOGERROR)
self.albumQueue._init(9999)
xbmcgui.Dialog().notification(plugin.name, msg, xbmcgui.NOTIFICATION_ERROR)
except Exception, e:
traceback.print_exc()
示例14: start
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def start(self):
enable_updates
class Monitor(xbmc.Monitor):
def onSettingsChanged(self):
global enable_updates
enable_updates = kodi.get_setting('enable_updates') == 'true'
monitor = Monitor()
kodi.log("Service Starting...")
if is_depricated:
while not xbmc.abortRequested:
kodi.sleep(1000)
self.update()
else:
while not monitor.abortRequested():
if monitor.waitForAbort(10):
break
self.update()
self.shutdown()
示例15: show_info_panel
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Monitor [as 别名]
def show_info_panel(self):
'''feature to auto show the OSD infopanel for X seconds'''
try:
sec_to_display = int(xbmc.getInfoLabel("Skin.String(SkinHelper.ShowInfoAtPlaybackStart)"))
except Exception:
return
if sec_to_display > 0 and not self.infopanelshown:
retries = 0
log_msg("Show OSD Infopanel - number of seconds: %s" % sec_to_display)
self.infopanelshown = True
if self.win.getProperty("VideoScreensaverRunning") != "true":
while retries != 50 and getCondVisibility("!Player.ShowInfo"):
xbmc.sleep(100)
if getCondVisibility("!Player.ShowInfo + Window.IsActive(fullscreenvideo)"):
xbmc.executebuiltin('Action(info)')
retries += 1
# close info again after given amount of time
xbmc.Monitor().waitForAbort(sec_to_display)
if getCondVisibility("Player.ShowInfo + Window.IsActive(fullscreenvideo)"):
xbmc.executebuiltin('Action(info)')