Python xbmc.abortRequested() Examples

The following are 30 code examples of xbmc.abortRequested(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xbmc , or try the search function .
Example #1
Source File: ts.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def run(self):
        LogToXBMC('Start SockThread')
        while self.active and not self.error and not xbmc.abortRequested:
            try:
                xbmc.sleep(32)
                self.lastRecv = self.lastRecv + self.sock.recv(self.buffer)
                if self.lastRecv.find('\r\n') > -1:
                    cmds = self.lastRecv.split('\r\n')
                    for cmd in cmds:
                        if cmd.replace(' ', '').__len__() > 0:
                            #LogToXBMC('RUN Получена комманда = ' + cmd)
                            self._constructMsg(cmd)
                    self.lastRecv = ''
            except Exception, e:
                self.isRecv = True
                self.active = False
                self.error = e
                LogToXBMC('RECV THREADING %s' % e, 2)
                _msg = TSMessage()
                _msg.type = TSMessage.ERROR
                _msg.params = 'Ошибка соединения с TS'
                self.state_method(_msg)
                #self.owner.end()
                #self.owner.connectToTS()
                #self.owner.parent.close() 
Example #2
Source File: default.py    From script.toolbox with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self):
        log("version %s started" % ADDON_VERSION)
        xbmc.executebuiltin('SetProperty(toolbox_running,True,home)')
        self._init_vars()
        self._parse_argv()
        if self.infos:
            self.StartInfoActions(self.infos, self.params)
        elif not len(sys.argv) > 1:
            self.selection_dialog()
        xbmc.executebuiltin('ClearProperty(toolbox_running,home)')
        while self.params.get("daemon", False) and not xbmc.abortRequested:
            self.image_now = xbmc.getInfoLabel("Player.Art(thumb)")
            if self.image_now != self.image_prev:
                self.image_prev = self.image_now
                image, imagecolor = Filter_Image(self.image_now, int(self.params.get("radius", 5)))
                HOME.setProperty(self.params.get("prefix", "") + 'ImageFilter', image)
                HOME.setProperty(self.params.get("prefix", "") + "ImageColor", imagecolor)
            else:
                xbmc.sleep(300) 
Example #3
Source File: library.py    From service.nextup.notification with GNU General Public License v2.0 6 votes vote down vote up
def _fetch_recommended_episodes(self):
            # First we get a list of all the in-progress TV shows.
            json_query_string = self.json_query("VideoLibrary.GetTVShows", unplayed=True,
                                                properties=self.tvshow_properties,
                                                sort={"order": "descending",
                                                      "method": "lastplayed"},
                                                query_filter=self.inprogress_filter)
            json_query = json.loads(json_query_string)

            # If we found any, find the oldest unwatched show for each one.
            if "result" in json_query and 'tvshows' in json_query['result']:
                for item in json_query['result']['tvshows']:
                    if xbmc.abortRequested:
                        break
                    json_query2 = self.json_query("VideoLibrary.GetEpisodes", unplayed=True,
                                                  include_specials=True,
                                                  properties=self.tvepisode_properties,
                                                  sort={"method": "episode"}, limit=1,
                                                  params={"tvshowid": item['tvshowid']})
                    self.WINDOW.setProperty("recommended-episodes-data-%d"
                                            % item['tvshowid'], json_query2)
            return json_query_string 
Example #4
Source File: gui.py    From FTV-Guide-Repo with GNU General Public License v2.0 6 votes vote down vote up
def updateTimebar(self, scheduleTimer=True):
        # move timebar to current time
        timeDelta = datetime.datetime.today() - self.viewStartDate
        control = self.getControl(self.C_MAIN_TIMEBAR)
        if control:
            (x, y) = control.getPosition()
            try:
                # Sometimes raises:
                # exceptions.RuntimeError: Unknown exception thrown from the call "setVisible"
                control.setVisible(timeDelta.days == 0)
            except:
                pass
            control.setPosition(self._secondsToXposition(timeDelta.seconds), y)

        if scheduleTimer and not xbmc.abortRequested and not self.isClosing:
            threading.Timer(1, self.updateTimebar).start() 
Example #5
Source File: gui.py    From FTV-Guide-Repo with GNU General Public License v2.0 6 votes vote down vote up
def onSourceProgressUpdate(self, percentageComplete):
        control = self.getControl(self.C_MAIN_LOADING_PROGRESS)
        if percentageComplete < 1:
            if control:
                control.setPercent(1)
            self.progressStartTime = datetime.datetime.now()
            self.progressPreviousPercentage = percentageComplete
        elif percentageComplete != self.progressPreviousPercentage:
            if control:
                control.setPercent(percentageComplete)
            self.progressPreviousPercentage = percentageComplete
            delta = datetime.datetime.now() - self.progressStartTime

            if percentageComplete < 20:
                self.setControlLabel(self.C_MAIN_LOADING_TIME_LEFT, strings(CALCULATING_REMAINING_TIME))
            else:
                secondsLeft = int(delta.seconds) / float(percentageComplete) * (100.0 - percentageComplete)
                if secondsLeft > 30:
                    secondsLeft -= secondsLeft % 10
                self.setControlLabel(self.C_MAIN_LOADING_TIME_LEFT, strings(TIME_LEFT) % secondsLeft)

        return not xbmc.abortRequested and not self.isClosing 
Example #6
Source File: service.py    From plugin.git.browser with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #7
Source File: TSCore.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def play_url_ind(self, index=0, title='', icon='', thumb=''):
        self.log.out('play')

        self.player=_TSPlayer()
        lnk=self.get_link(index,title,icon,thumb)
        if not lnk: return False
        self.player.link=lnk
        self.player.vod=True
        if self.progress:self.progress.close()
        item = xbmcgui.ListItem(title,thumb,icon,path=lnk)
        if self.local: 
            xbmcvfs.rename(lnk,lnk)
            xbmc.Player().play(lnk,item)

        else: 
            self.player.play(lnk,item)
            while self.player.active and not self.local: 
                self.loop()
                xbmc.sleep(300)
                if xbmc.abortRequested:
                    self.log.out("XBMC is shutting down")
                    break
            self.log.out('ended play') 
Example #8
Source File: ASCore.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def play_url_ind(self, index=0, title='', icon='', thumb=''):
        self.log.out('play')

        
        lnk=self.get_link(index,title,icon,thumb)
        if not lnk: return False
        self.player.link=lnk
        self.player.vod=True
        if self.progress:self.progress.close()
        item = xbmcgui.ListItem(title,thumb,icon,path=lnk)
        if self.local: 
            xbmc.Player().play(lnk,item)
        else: 
            self.player.play(lnk,item)
            while self.player.active and not self.local: 
                self.loop()
                xbmc.sleep(300)
                if xbmc.abortRequested:
                    self.log.out("XBMC is shutting down")
                    break
            self.log.out('ended play') 
Example #9
Source File: tthp.py    From tdw with GNU General Public License v3.0 6 votes vote down vote up
def list(uri):
  # Create instance of Engine 
  engine = Engine(uri)
  files = []
  # Ensure we'll close engine on exception 
  with closing(engine):
    # Start engine 
    engine.start()
    # Wait until files received 
    while not files and not xbmc.abortRequested:
        # Will list only video files in torrent
        files = engine.list(media_types=[MediaType.VIDEO])
        # Check if there is loading torrent error and raise exception 
        engine.check_torrent_error()
        xbmc.sleep(200)
  return files 
Example #10
Source File: sopcast.py    From program.plexus with GNU General Public License v2.0 6 votes vote down vote up
def sop_sleep(time, spsc_pid):
    counter = 0
    increment = 200
    path = "/proc/%s" % str(spsc_pid)
    try:
        while counter < time and spsc_pid > 0 and not xbmc.abortRequested:
            counter += increment
            xbmc.sleep(increment)
    except:
        return True

    if counter < time:
        return False
    else:
        return True


# dirty hack to break sopcast.exe player codec to avoid double sound 
Example #11
Source File: libtools.py    From filmkodi with Apache License 2.0 5 votes vote down vote up
def range(self, url):
        control.idle()

        yes = control.yesnoDialog(control.lang(30425).encode('utf-8'), '', '')
        if not yes: return

        if not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo'):
            control.infoDialog(control.lang(30421).encode('utf-8'), time=10000000)
            self.infoDialog = True

        from resources.lib.indexers import tvshows
        items = tvshows.tvshows().get(url, idx=False)
        if items == None: items = []

        for i in items:
            try:
                if xbmc.abortRequested == True: return sys.exit()
                self.add(i['title'], i['year'], i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], range=True)
            except:
                pass

        if self.infoDialog == True:
            control.infoDialog(control.lang(30423).encode('utf-8'), time=1)

        if self.library_setting == 'true' and not control.condVisibility('Library.IsScanningVideo'):
            control.execute('UpdateLibrary(video)') 
Example #12
Source File: TSCore.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        if xbmc.Player().isPlaying(): xbmc.Player().stop()

        self.log=Logger("TSEngine")
        self.push=Logger('OUT')
        self.alive=True
        self.progress = xbmcgui.DialogProgress()
        self.player=None
        self.files={}
        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        #self._sock.setblocking(0)
        self._sock.settimeout(3)
        self.progress.create("AceStream Client","Инициализация")
        self.tsserv =None
        self.conn=False
        self.title=None
        self.filename=None
        self.mode=None
        self.url=None
        self.local=False
        self.saved=False
        self.pos=[25,50,75,100]
        self.save=False
        l=False
        while xbmc.Player().isPlaying(): 
            l=True
            if xbmc.abortRequested:
                self.log.out("XBMC is shutting down")
                return False
            if self.progress.iscanceled():
                return False
            xbmc.sleep(300)
        Addon.setSetting('active','1')
        if l: xbmc.sleep(500) 
Example #13
Source File: acecore.py    From program.plexus with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        xbmc.Player().stop()
        self.log=Logger("TSEngine")
        self.push=Logger('OUT')
        self.alive=True
        self.progress = xbmcgui.DialogProgress()
        self.player=None
        self.files={}
        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self._sock.settimeout(3)
        self.progress.create(translate(30000),translate(30043))
        self.tsserv =None
        self.conn=False
        self.title=None
        self.filename=None
        self.mode=None
        self.url=None
        self.local=False
        self.saved=False
        self.canceled = False
        self.pos=[25,50,75,100]
        l=False
        while xbmc.Player().isPlaying(): 
            l=True
            if xbmc.abortRequested:
                self.log.out("XBMC asked to abort request")
                return False
            if self.progress.iscanceled():
                self.canceled = True
                return False
            xbmc.sleep(300)
        
        settings.setSetting('active','1')
        if l: xbmc.sleep(500) 
Example #14
Source File: YaTv.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def GetChannels(Url):
	http = GET(Url, Url)
	ht={}
	if http == None:
		showMessage('YaTV:', 'Сервер не отвечает', 1000)
		http = GET(Url, Url)
		if http == None:
			http = GET(Url, Url)
			if http == None:
				return None
			else:
				http = http.replace(':false',':0').replace(':true',':1')
				http=eval(http)
				for channel in http["schedules"]:
					if xbmc.abortRequested:
						break
					else:
						save_cache(channel, channel["channel"]["id"])
		else:
			http = http.replace(':false',':0').replace(':true',':1')
			http=eval(http)
			for channel in http["schedules"]:
				if xbmc.abortRequested:
					break
				else:
					save_cache(channel, channel["channel"]["id"])
	else:
		http = http.replace(':false',':0').replace(':true',':1')
		http=eval(http)
		for channel in http["schedules"]:
			if xbmc.abortRequested:
				break
			else:
				save_cache(channel, channel["channel"]["id"]) 
Example #15
Source File: YaTv.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def GetChannelsFull(Url):
	http = GET(Url, Url)
	if http == None:
		showMessage('YaTV:', 'Сервер не отвечает', 1000)
		http = GET(Url, Url)
		if http == None:
			http = GET(Url, Url)
			if http == None:
				return None
			else:
				http = http.replace(':false',':0').replace(':true',':1')
				http = eval(http.replace("\\/","//"))
				for channel in http["schedules"]:
					if xbmc.abortRequested:
						break
					else:
						add_to_db_New(channel["channel"]["id"], channel)
						xbmc.sleep(250)
		else:
			http = http.replace(':false',':0').replace(':true',':1')
			http = eval(http.replace("\\/","//"))
			for channel in http["schedules"]:
				if xbmc.abortRequested:
					break
				else:
					add_to_db_New(channel["channel"]["id"], channel)
					xbmc.sleep(250)
	else:
		http = http.replace(':false',':0').replace(':true',':1')
		http = eval(http.replace("\\/","//"))
		for channel in http["schedules"]:
			if xbmc.abortRequested:
				break
			else:
				add_to_db_New(channel["channel"]["id"], channel)
				xbmc.sleep(250) 
Example #16
Source File: rodina.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def _daemon(self):
        while not xbmc.abortRequested:
            xbmc.sleep(1000)

        log('abort requested') 
Example #17
Source File: default.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def _daemon(self):
		#this will run constantly
		while (not xbmc.abortRequested):
			xbmc.sleep(500)
			self.count = 0
			self.line_num = 0
			if xbmc.getCondVisibility('Window.IsActive(virtualkeyboard)'):            
                                
				self.push_string(self.count, self.line_num) 
Example #18
Source File: control.py    From script.module.openscrapers with GNU General Public License v3.0 5 votes vote down vote up
def sleep(time):  # Modified `sleep` command that honors a user exit request
	while time > 0 and not xbmc.abortRequested:
		xbmc.sleep(min(100, time))
		time = time - 100 
Example #19
Source File: libtools.py    From filmkodi with Apache License 2.0 5 votes vote down vote up
def range(self, url):
        control.idle()

        yes = control.yesnoDialog(control.lang(30425).encode('utf-8'), '', '')
        if not yes: return

        if not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo'):
            control.infoDialog(control.lang(30421).encode('utf-8'), time=10000000)
            self.infoDialog = True

        from resources.lib.indexers import movies
        items = movies.movies().get(url, idx=False)
        if items == None: items = []
        for i in items:
            control.log('## ITEMS %s' % i['title'])

        for i in items:
            try:
                if xbmc.abortRequested == True: return sys.exit()
                self.add('%s (%s)' % (i['title'], i['year']), i['title'], i['year'], i['imdb'], i['tmdb'], range=True)
            except:
                pass

        if self.infoDialog == True:
            control.infoDialog(control.lang(30423).encode('utf-8'), time=1)

        if self.library_setting == 'true' and not control.condVisibility('Library.IsScanningVideo'):
            control.execute('UpdateLibrary(video)') 
Example #20
Source File: TSCore.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def ts_init(self):
       
        
        self.tsserv = TSServ(self._sock)
        self.tsserv.start()
        #comm="HELLOBG"
        #self.TSpush(comm)
        comm="HELLOBG"
        self.TSpush(comm)
        self.progress.update(0,"Ждем ответа"," ")
        while not self.tsserv.version:
            if xbmc.abortRequested:
                self.log.out("XBMC is shutting down")
                return False
            if self.progress.iscanceled():
                return False
            time.sleep(1)
        ready='READY'
        if self.tsserv.key:

            import hashlib
            sha1 = hashlib.sha1()
            pkey=self.tsserv.pkey
            sha1.update(self.tsserv.key+pkey)
            key=sha1.hexdigest()
            pk=pkey.split('-')[0]
            key="%s-%s"%(pk,key)
            ready='READY key=%s'% key
        if self.progress.iscanceled():
            self.err=1
            return False	
        self.TSpush(ready)
        return True 
Example #21
Source File: default.py    From script.tv.show.next.aired with GNU General Public License v2.0 5 votes vote down vote up
def handle_bg_version_change(self, latest_version):
        log("### NextAired version changed from %s to %s -- starting a replacement background proc" % (__version__, latest_version), level=1)
        # Delay a bit, just to be sure that it is ready to run.  We need to also be sure that this
        # is at least as long as the elapsed time we allow in our NextAired.background_id check.
        for cnt in range(15):
            if xbmc.abortRequested:
                sys.exit()
            xbmc.sleep(1000)
        json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Addons.ExecuteAddon", "params": {"addonid": "script.tv.show.next.aired", "params": %s}, "id": 0}' % json.dumps(self.params))
        json_query = unicode(json_query, 'utf-8', errors='ignore')
        json_response = json.loads(json_query)
        log("### %s" % json_response)
        self.close("stopping this older background proc") 
Example #22
Source File: default.py    From script.tv.show.next.aired with GNU General Public License v2.0 5 votes vote down vote up
def listing(self):
        failures = 0
        # If the computer is waking up from a sleep, this call might fail for a little bit.
        while not xbmc.abortRequested:
            json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"properties": ["title", "file", "thumbnail", "art", "imdbnumber", "premiered"], "sort": { "method": "title" } }, "id": 1}')
            json_query = unicode(json_query, 'utf-8', errors='ignore')
            json_response = json.loads(json_query)
            log("### %s" % json_response)
            if 'result' in json_response:
                break
            failures += 1
            if failures >= 5:
                break
            xbmc.sleep(5000)
        try:
            tvshows = json_response['result']['tvshows']
        except:
            tvshows = []
        TVlist = []
        for item in tvshows:
            tvshowname = normalize(item, 'title')
            path = item['file']
            art = item['art']
            thumbnail = item['thumbnail']
            dbid = self.videodb + str(item['tvshowid']) + '/'
            TVlist.append((tvshowname, path, art, dbid, thumbnail, item['imdbnumber'], item['premiered']))
        log("### list: %s" % TVlist)
        return TVlist 
Example #23
Source File: gui.py    From FTV-Guide-Repo with GNU General Public License v2.0 5 votes vote down vote up
def waitForPlayBackStopped(self):
        for retry in range(0, 100):
            time.sleep(0.1)
            if self.player.isPlaying():
                break

        while self.player.isPlaying() and not xbmc.abortRequested and not self.isClosing:
            time.sleep(0.5)

        self.onPlayBackStopped() 
Example #24
Source File: gui.py    From FTV-Guide-Repo with GNU General Public License v2.0 5 votes vote down vote up
def isSourceInitializationCancelled(self):
        return xbmc.abortRequested or self.isClosing 
Example #25
Source File: default.py    From script.tvtime with GNU General Public License v2.0 5 votes vote down vote up
def _trackPosition(self):
        while self._playback_lock.isSet() and not xbmc.abortRequested:
            try:
                self._last_pos = player.getTime()
            except:
                self._playback_lock.clear()
            log('Inside Player. Tracker time = %s' % self._last_pos)
            xbmc.sleep(250)
        log('Position tracker ending with last_pos = %s' % self._last_pos) 
Example #26
Source File: sutils.py    From plugin.video.sosac.ph with GNU General Public License v2.0 5 votes vote down vote up
def sleep(sleep_time):
        while not xbmc.abortRequested and sleep_time > 0:
            sleep_time -= 1
            xbmc.sleep(1) 
Example #27
Source File: sutils.py    From plugin.video.sosac.ph with GNU General Public License v2.0 5 votes vote down vote up
def evalSchedules(self):
        if not self.scanRunning() and not self.isPlaying():
            notified = False
            util.info("SOSAC Loading subscriptions")
            subs = self.get_subs()
            new_items = False
            for url, sub in subs.iteritems():
                if xbmc.abortRequested:
                    util.info("SOSAC Exiting")
                    return
                if sub['type'] == sosac.LIBRARY_TYPE_TVSHOW:
                    if self.scanRunning() or self.isPlaying():
                        self.cache.delete("subscription.last_run")
                        return
                    refresh = int(sub['refresh'])
                    if refresh > 0:
                        next_check = sub['last_run'] + (refresh * 3600 * 24)
                        if next_check < time.time():
                            if not notified:
                                self.showNotification(
                                    'Subscription', 'Chcecking')
                                notified = True
                            util.debug("SOSAC Refreshing " + url)
                            new_items |= self.run_custom({
                                'action': sosac.LIBRARY_ACTION_ADD,
                                'type': sosac.LIBRARY_TYPE_TVSHOW,
                                'update': True,
                                'url': url,
                                'name': sub['name'],
                                'refresh': sub['refresh']
                            })
                            self.sleep(3000)
                        else:
                            n = (next_check - time.time()) / 3600
                            util.debug("SOSAC Skipping " + url +
                                       " , next check in %dh" % n)
            if new_items:
                xbmc.executebuiltin('UpdateLibrary(video)')
            notified = False
        else:
            util.info("SOSAC Scan skipped") 
Example #28
Source File: sutils.py    From plugin.video.sosac.ph with GNU General Public License v2.0 5 votes vote down vote up
def service(self):
        util.info("SOSAC Service Started")
        try:
            sleep_time = int(self.getSetting("start_sleep_time")) * 1000 * 60 * 60
        except:
            sleep_time = self.sleep_time
            pass

        self.sleep(sleep_time)

        try:
            self.last_run = float(self.cache.get("subscription.last_run"))
        except:
            self.last_run = time.time()
            self.cache.set("subscription.last_run", str(self.last_run))
            pass

        if not xbmc.abortRequested and time.time() > self.last_run:
            self.evalSchedules()

        while not xbmc.abortRequested:
            # evaluate subsciptions every 10 minutes
            if(time.time() > self.last_run + 600):
                self.evalSchedules()
                self.last_run = time.time()
                self.cache.set("subscription.last_run", str(self.last_run))
            self.sleep(self.sleep_time)
        util.info("SOSAC Shutdown") 
Example #29
Source File: betaseries.py    From xbmc-betaseries with GNU General Public License v2.0 5 votes vote down vote up
def __init__( self ):
        self._service_setup()
        while (not xbmc.abortRequested):
            xbmc.sleep(1000) 
Example #30
Source File: ASCore.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        if xbmc.Player().isPlaying(): xbmc.Player().stop()
        self.save=False
        self.log=Logger("TSEngine")
        self.push=Logger('OUT')
        self.alive=True
        self.progress = xbmcgui.DialogProgress()
        self.player=None
        self.files={}
        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        #self._sock.setblocking(0)
        self._sock.settimeout(3)
        self.progress.create("AceStream Client","Инициализация")
        self.tsserv =None
        self.conn=False
        self.title=None
        self.filename=None
        self.mode=None
        self.url=None
        self.local=False
        self.saved=False
        self.pos=[25,50,75,100]
        l=False
        while xbmc.Player().isPlaying(): 
            l=True
            if xbmc.abortRequested:
                self.log.out("XBMC is shutting down")
                return False
            if self.progress.iscanceled():
                return False
            xbmc.sleep(300)
        
        Addon.setSetting('active','1')
        if l: xbmc.sleep(500)