Exemplo n.º 1
0
	def remove(self, number):
		if number in self.phonebook:
			debug("[NcidClientPhonebook] remove entry in phonebook")
			del self.phonebook[number]
			if config.plugins.NcidClient.phonebook.value:
				try:
					phonebookFilename = os.path.join(config.plugins.NcidClient.phonebookLocation.value, "PhoneBook.txt")
					debug("[NcidClientPhonebook] remove entry in Phonebook.txt")
					fOld = open(phonebookFilename, 'r')
					fNew = open(phonebookFilename + str(os.getpid()), 'w')
					line = fOld.readline()
					while (line):
						elems = line.split('#')
						if len(elems) == 2 and not elems[0] == number:
							fNew.write(line)
						line = fOld.readline()
					fOld.close()
					fNew.close()
					# os.remove(phonebookFilename)
					eBackgroundFileEraser.getInstance().erase(phonebookFilename)
					os.rename(phonebookFilename + str(os.getpid()), 	phonebookFilename)
					debug("[NcidClientPhonebook] removed %s from Phonebook.txt" % number)
					return True

				except (IOError, OSError):
					debug("[NcidClientPhonebook] error removing %s from %s" % (number, phonebookFilename))
		return False
Exemplo n.º 2
0
    def Exit(self):
        print '[AirPlayMusicPlayer] stopping AirTunesPlayer'
        self.backend.MusicWindow = None
        if self.lastservice and self.lastservice is not None:
            self.backend.updateEventInfo('stopped')
        else:
            print '[AirPlayMusicPlayer] lastService is None, not sending stop command'
        os.system('killall hairtunes')
        os.system('killall atproxy')
        try:
            config.av.downmix_ac3.value = self.backend.downmix_ac3
            config.av.downmix_ac3.save()
        except Exception as e:
            print '[AirPlayMusicPlayer] rest downmix failed: ', e

        if self.backend.ENIGMA_SERVICE_ID == self.backend.ENIGMA_SERVICEAZ_ID:
            self.session.nav.stopService()
            open('/proc/player', 'w').write('1')
            import time
            time.sleep(2)
        if self.lastservice and self.lastservice is not None:
            self.session.nav.playService(self.lastservice)
        eBackgroundFileEraser.getInstance().erase(config.plugins.airplayer.path.value + '/cover.jpg')
        eBackgroundFileEraser.getInstance().erase(config.plugins.airplayer.path.value + '/metadata.bin')
        self.close()
Exemplo n.º 3
0
    def leavePlayerConfirmed(self, answer):
        if answer:
            print '[AirPlayMoviePlayer] stopping MoviePlayer'
            self.backend.MovieWindow = None
            if self.localCache:
                self.container.kill()
                eBackgroundFileEraser.getInstance().erase(
                    config.plugins.airplayer.path.value + self.filename)
                self.StatusTimer.stop()
            if self.lastservice and self.lastservice is not None:
                self.backend.updateEventInfo('stopped')
            else:
                print '[AirPlayMoviePlayer] lastService is None, not sending stop command'
            self.backend.updateEventInfo('stopped')
            if self.backend.ENIGMA_SERVICE_ID == self.backend.ENIGMA_SERVICEAZ_ID:
                self.session.nav.stopService()
                open('/proc/player', 'w').write('1')
                import time
                time.sleep(2)
            try:
                print '[AirPlayMoviePlayer] try to remove proxy cache'
                os.system('rm %s/AirPlayerChunk* &' %
                          config.plugins.airplayer.path.value)
            except Exception:
                pass

            if self.proxyProcess != None:
                try:
                    self.proxyProcess.kill()
                except Exception:
                    pass

            self.close()
Exemplo n.º 4
0
	def remove(self, number):
		if number in self.phonebook:
			debug("[NcidClientPhonebook] remove entry in phonebook")
			del self.phonebook[number]
			if config.plugins.NcidClient.phonebook.value:
				try:
					phonebookFilename = os.path.join(config.plugins.NcidClient.phonebookLocation.value, "PhoneBook.txt")
					debug("[NcidClientPhonebook] remove entry in Phonebook.txt")
					fOld = open(phonebookFilename, 'r')
					fNew = open(phonebookFilename + str(os.getpid()), 'w')
					line = fOld.readline()
					while (line):
						elems = line.split('#')
						if len(elems) == 2 and not elems[0] == number:
							fNew.write(line)
						line = fOld.readline()
					fOld.close()
					fNew.close()
					# os.remove(phonebookFilename)
					eBackgroundFileEraser.getInstance().erase(phonebookFilename)
					os.rename(phonebookFilename + str(os.getpid()), 	phonebookFilename)
					debug("[NcidClientPhonebook] removed %s from Phonebook.txt" % number)
					return True
	
				except (IOError, OSError):
					debug("[NcidClientPhonebook] error removing %s from %s" % (number, phonebookFilename))
		return False
Exemplo n.º 5
0
    def leavePlayerConfirmed(self, answer):
        if answer:
            print '[AirPlayMoviePlayer] stopping MoviePlayer'
            self.backend.MovieWindow = None
            if self.localCache:
                self.container.kill()
                eBackgroundFileEraser.getInstance().erase(config.plugins.airplayer.path.value + self.filename)
                self.StatusTimer.stop()
            if self.lastservice and self.lastservice is not None:
                self.backend.updateEventInfo('stopped')
            else:
                print '[AirPlayMoviePlayer] lastService is None, not sending stop command'
            self.backend.updateEventInfo('stopped')
            if self.backend.ENIGMA_SERVICE_ID == self.backend.ENIGMA_SERVICEAZ_ID:
                self.session.nav.stopService()
                open('/proc/player', 'w').write('1')
                import time
                time.sleep(2)
            try:
                print '[AirPlayMoviePlayer] try to remove proxy cache'
                os.system('rm %s/AirPlayerChunk* &' % config.plugins.airplayer.path.value)
            except Exception:
                pass

            if self.proxyProcess != None:
                try:
                    self.proxyProcess.kill()
                except Exception:
                    pass

            self.close()
Exemplo n.º 6
0
    def Exit(self):
        print('[AirPlayMusicPlayer] stopping AirTunesPlayer')
        self.backend.MusicWindow = None
        if self.lastservice and self.lastservice is not None:
            self.backend.updateEventInfo('stopped')
        else:
            print(
                '[AirPlayMusicPlayer] lastService is None, not sending stop command'
            )
        Console().ePopen('killall -9 hairtunes')
        Console().ePopen('killall -9 atproxy')
        try:
            config.av.downmix_ac3.value = self.backend.downmix_ac3
            config.av.downmix_ac3.save()
        except Exception as e:
            print('[AirPlayMusicPlayer] rest downmix failed: ', e)

        if self.backend.ENIGMA_SERVICE_ID == self.backend.ENIGMA_SERVICEAZ_ID:
            self.session.nav.stopService()
            open('/proc/player', 'w').write('1')
            import time
            time.sleep(2)
        if self.lastservice and self.lastservice is not None:
            self.session.nav.playService(self.lastservice)
        eBackgroundFileEraser.getInstance().erase(
            config.plugins.airplayer.path.value + '/cover.jpg')
        eBackgroundFileEraser.getInstance().erase(
            config.plugins.airplayer.path.value + '/metadata.bin')
        self.close()
        return
Exemplo n.º 7
0
    def JobTrash(self):
        ctimeLimit = time() - config.crash.daysloglimit.value * 3600 * 24
        allowedBytes = 1048576 * int(config.crash.sizeloglimit.value)
        mounts = []
        matches = []
        print '[LogManager] probing folders'
        f = open('/proc/mounts', 'r')
        for line in f.readlines():
            parts = line.strip().split()
            mounts.append(parts[1])

        f.close()
        for mount in mounts:
            if path.isdir(path.join(mount, 'logs')):
                matches.append(path.join(mount, 'logs'))

        matches.append('/home/root/logs')
        print "[LogManager] found following log's:", matches
        if len(matches):
            for logsfolder in matches:
                print '[LogManager] looking in:', logsfolder
                logssize = get_size(logsfolder)
                bytesToRemove = logssize - allowedBytes
                candidates = []
                size = 0
                for root, dirs, files in walk(logsfolder, topdown=False):
                    for name in files:
                        try:
                            fn = path.join(root, name)
                            st = stat(fn)
                            if st.st_ctime < ctimeLimit:
                                print '[LogManager] ' + str(
                                    fn) + ': Too old:', name, st.st_ctime
                                eBackgroundFileEraser.getInstance().erase(fn)
                                bytesToRemove -= st.st_size
                            else:
                                candidates.append(
                                    (st.st_ctime, fn, st.st_size))
                                size += st.st_size
                        except Exception as e:
                            print '[LogManager] Failed to stat %s:' % name, e

                    for name in dirs:
                        try:
                            rmdir(path.join(root, name))
                        except:
                            pass

                    candidates.sort()
                    for st_ctime, fn, st_size in candidates:
                        print '[LogManager] ' + str(
                            logsfolder) + ': bytesToRemove', bytesToRemove
                        if bytesToRemove < 0:
                            break
                        eBackgroundFileEraser.getInstance().erase(fn)
                        bytesToRemove -= st_size
                        size -= st_size

        self.TrashTimer.startLongTimer(43200)
Exemplo n.º 8
0
    def JobTrash(self):
        ctimeLimit = time() - (config.crash.daysloglimit.getValue() * 3600 *
                               24)
        allowedBytes = 1024 * 1024 * int(config.crash.sizeloglimit.getValue())

        mounts = []
        matches = []
        print "[LogManager] probing folders"
        f = open('/proc/mounts', 'r')
        for line in f.readlines():
            parts = line.strip().split()
            mounts.append(parts[1])
        f.close()

        for mount in mounts:
            if path.isdir(path.join(mount, 'logs')):
                matches.append(path.join(mount, 'logs'))
        matches.append('/home/root/logs')

        print "[LogManager] found following log's:", matches
        if len(matches):
            for logsfolder in matches:
                print "[LogManager] looking in:", logsfolder
                logssize = get_size(logsfolder)
                bytesToRemove = logssize - allowedBytes
                candidates = []
                size = 0
                for root, dirs, files in walk(logsfolder, topdown=False):
                    for name in files:
                        try:
                            fn = path.join(root, name)
                            st = stat(fn)
                            if st.st_ctime < ctimeLimit:
                                print "[LogManager] " + str(
                                    fn) + ": Too old:", name, st.st_ctime
                                eBackgroundFileEraser.getInstance().erase(fn)
                                bytesToRemove -= st.st_size
                            else:
                                candidates.append(
                                    (st.st_ctime, fn, st.st_size))
                                size += st.st_size
                        except Exception, e:
                            print "[LogManager] Failed to stat %s:" % name, e
                    # Remove empty directories if possible
                    for name in dirs:
                        try:
                            rmdir(path.join(root, name))
                        except:
                            pass
                    candidates.sort()
                    # Now we have a list of ctime, candidates, size. Sorted by ctime (=deletion time)
                    for st_ctime, fn, st_size in candidates:
                        print "[LogManager] " + str(
                            logsfolder) + ": bytesToRemove", bytesToRemove
                        if bytesToRemove < 0:
                            break
                        eBackgroundFileEraser.getInstance().erase(fn)
                        bytesToRemove -= st_size
                        size -= st_size
 def Exit(self):
     print '[AirPlayPicturePlayer] stopping PicturePlayer'
     del self.picload
     self.backend.PictureWindow = None
     if config.plugins.airplayer.stopTVOnPicture.value and self.lastservice is not None:
         self.session.nav.playService(self.lastservice)
     eBackgroundFileEraser.getInstance().erase(config.plugins.airplayer.path.value + '/' + self.picFile)
     self.close()
Exemplo n.º 10
0
 def Exit(self):
     print '[AirPlayPicturePlayer] stopping PicturePlayer'
     del self.picload
     self.backend.PictureWindow = None
     if config.plugins.airplayer.stopTVOnPicture.value and self.lastservice is not None:
         self.session.nav.playService(self.lastservice)
     eBackgroundFileEraser.getInstance().erase(
         config.plugins.airplayer.path.value + '/' + self.picFile)
     self.close()
Exemplo n.º 11
0
    def JobTrash(self):
        ctimeLimit = time() - config.crash.daysloglimit.value * 3600 * 24
        allowedBytes = 1048576 * int(config.crash.sizeloglimit.value)
        mounts = []
        matches = []
        print '[LogManager] probing folders'
        f = open('/proc/mounts', 'r')
        for line in f.readlines():
            parts = line.strip().split()
            mounts.append(parts[1])

        f.close()
        for mount in mounts:
            if path.isdir(path.join(mount, 'logs')):
                matches.append(path.join(mount, 'logs'))

        matches.append('/home/root/logs')
        print "[LogManager] found following log's:", matches
        if len(matches):
            for logsfolder in matches:
                print '[LogManager] looking in:', logsfolder
                logssize = get_size(logsfolder)
                bytesToRemove = logssize - allowedBytes
                candidates = []
                size = 0
                for root, dirs, files in walk(logsfolder, topdown=False):
                    for name in files:
                        try:
                            fn = path.join(root, name)
                            st = stat(fn)
                            if st.st_ctime < ctimeLimit:
                                print '[LogManager] ' + str(fn) + ': Too old:', name, st.st_ctime
                                eBackgroundFileEraser.getInstance().erase(fn)
                                bytesToRemove -= st.st_size
                            else:
                                candidates.append((st.st_ctime, fn, st.st_size))
                                size += st.st_size
                        except Exception as e:
                            print '[LogManager] Failed to stat %s:' % name, e

                    for name in dirs:
                        try:
                            rmdir(path.join(root, name))
                        except:
                            pass

                    candidates.sort()
                    for st_ctime, fn, st_size in candidates:
                        print '[LogManager] ' + str(logsfolder) + ': bytesToRemove', bytesToRemove
                        if bytesToRemove < 0:
                            break
                        eBackgroundFileEraser.getInstance().erase(fn)
                        bytesToRemove -= st_size
                        size -= st_size

        self.TrashTimer.startLongTimer(43200)
Exemplo n.º 12
0
	def JobTrash(self):
		ctimeLimit = time() - (config.crash.daysloglimit.value * 3600 * 24)
		allowedBytes = 1024*1024 * int(config.crash.sizeloglimit.value)

		mounts = []
		matches = []
		print "[LogManager] probing folders"
		f = open('/proc/mounts', 'r')
		for line in f.readlines():
			parts = line.strip().split()
			mounts.append(parts[1])
		f.close()

		for mount in mounts:
			if path.isdir(path.join(mount,'logs')):
				matches.append(path.join(mount,'logs'))
		matches.append('/home/root/logs')

		print "[LogManager] found following log's:", matches
		if len(matches):
			for logsfolder in matches:
				print "[LogManager] looking in:", logsfolder
				logssize = get_size(logsfolder)
				bytesToRemove = logssize - allowedBytes
				candidates = []
				size = 0
				for root, dirs, files in walk(logsfolder, topdown=False):
					for name in files:
						try:
							fn = path.join(root, name)
							st = stat(fn)
							if st.st_ctime < ctimeLimit:
								print "[LogManager] " + str(fn) + ": Too old:", name, st.st_ctime
								eBackgroundFileEraser.getInstance().erase(fn)
								bytesToRemove -= st.st_size
							else:
								candidates.append((st.st_ctime, fn, st.st_size))
								size += st.st_size
						except Exception, e:
							print "[LogManager] Failed to stat %s:"% name, e
					# Remove empty directories if possible
					for name in dirs:
						try:
							rmdir(path.join(root, name))
						except:
							pass
					candidates.sort()
					# Now we have a list of ctime, candidates, size. Sorted by ctime (=deletion time)
					for st_ctime, fn, st_size in candidates:
						print "[LogManager] " + str(logsfolder) + ": bytesToRemove", bytesToRemove
						if bytesToRemove < 0:
							break
						eBackgroundFileEraser.getInstance().erase(fn)
						bytesToRemove -= st_size
						size -= st_size
Exemplo n.º 13
0
 def _onLoad(self, result, f, loaded=True):
     pixmap = PICON_PATH + f
     self.picons[f] = pixmap
     self.requests.append(f)
     if loaded:
         d, consumers = self.defers.pop(f)
         for consumer in consumers:
             consumer.callback(pixmap)
         del d
     if len(self.requests) >= self.CACHE_SIZE:
         self.trace("wipe cache", self.requests)
         for _i in xrange(self.CACHE_SIZE / 2):
             fname = self.requests.popleft()
             del self.picons[fname]
             eBackgroundFileEraser.getInstance().erase(PICON_PATH + fname)
Exemplo n.º 14
0
	def delete_cache(self, f):
		bgFileEraser = eBackgroundFileEraser.getInstance()
		keys = self._cached_files.keys()
		for i in ifilter(f, keys):
			filename = self._cached_files[i]
			bgFileEraser.erase(str(filename))
			del self._cached_files[i]
Exemplo n.º 15
0
	def __init__(self, session, movieinfo, movietitle):
		self.skin = PlayRtmpMovie.skin
		Screen.__init__(self, session)

		self.url = movieinfo[0]
		self.filename = movieinfo[1]
		self.movietitle = movietitle
		self.movieinfo = movieinfo
		self.destination = config.mediaportal.storagepath.value
		#self.moviepath = self.destination + ASCIItranslit.legacyEncode(self.filename)
		self.moviepath = self.destination + ".rtmp_movie"

		self.streamactive = False
		self.isVisible = True

		self.container=eConsoleAppContainer()
		self.container.appClosed.append(self.copyfinished)
		self.container.stdoutAvail.append(self.progressUpdate)
		self.container.stderrAvail.append(self.progressUpdate)
		self.container.setCWD(self.destination)

		self.oldService = self.session.nav.getCurrentlyPlayingServiceReference()

		self.BgFileEraser = eBackgroundFileEraser.getInstance()

		filesize = 0
		self.filesize = float(filesize) # in bytes

		self.dummyfilesize = False
		self.lastcmddata = None
		self.lastlocalsize = 0
		self.localsize = 0
		self.isplaying = False
		self.autoplaythreshold = config.mediaportal.autoplayThreshold.value

		self["key_green"] = Button(_("Play"))
		self["key_red"] = Button(_("Cancel"))
		self["key_blue"] = Button(_("Show/Hide"))

		self["label_filename"] = StaticText("File: %s" % (self.filename))
		self["label_progress"] = StaticText("Progress: N/A")
		self["label_speed"] = StaticText("Speed: N/A")
		self["label_timeleft"] = StaticText("Time left: N/A")

		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
		{
			"cancel": self.exit,
			"ok": self.okbuttonClick,
			"red": self.exit,
			"green": self.playfile,
			"blue": self.visibility
		}, -1)

		self.StatusTimer = eTimer()
		self.StatusTimer.callback.append(self.UpdateStatus)

		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider

		self.onFirstExecBegin.append(self.firstExecBegin)
Exemplo n.º 16
0
	def delete_cache(self, f):
		bgFileEraser = eBackgroundFileEraser.getInstance()
		keys = self._cached_files.keys()
		for i in ifilter(f, keys):
			filename = self._cached_files[i]
			bgFileEraser.erase(str(filename))
			del self._cached_files[i]
Exemplo n.º 17
0
	def delete(self):
		item = self["timerlist"].getCurrent()
		if item is None:
			return # huh?
		name = item.name
		service = str(item.service_ref.getServiceName())
		t = localtime(item.begin)
		f = str(t.tm_year) + str(t.tm_mon).zfill(2) + str(t.tm_mday).zfill(2) + " " + str(t.tm_hour).zfill(2) + str(t.tm_min).zfill(2) + " - " + service + " - " + name
		f = f.replace(':','_')
		f = f.replace(',','_')
		f = f.replace('/','_')
		path = resolveFilename(SCOPE_HDD)
		self.removeTimer(True)
		from enigma import eBackgroundFileEraser
		files = os.listdir(path)
		for file in files:
			if file.startswith(f):
				eBackgroundFileEraser.getInstance().erase(os.path.realpath(path + file))
Exemplo n.º 18
0
	def delete(self):
		item = self["timerlist"].getCurrent()
		if item is None:
			return # huh?
		name = item.name
		service = str(item.service_ref.getServiceName())
		t = localtime(item.begin)
		f = str(t.tm_year) + str(t.tm_mon).zfill(2) + str(t.tm_mday).zfill(2) + " " + str(t.tm_hour).zfill(2) + str(t.tm_min).zfill(2) + " - " + service + " - " + name
		f = f.replace(':','_')
		f = f.replace(',','_')
		f = f.replace('/','_')
		path = resolveFilename(SCOPE_HDD)
		self.removeTimer(True)
		from enigma import eBackgroundFileEraser
		files = os.listdir(path)
		for file in files:
			if file.startswith(f):
				eBackgroundFileEraser.getInstance().erase(os.path.realpath(path + file))
Exemplo n.º 19
0
    def __init__(self, session, movieinfo, movietitle):
        self.skin = PlayHttpMovie.skin
        Screen.__init__(self, session)

        self.url = movieinfo[0]
        self.filename = movieinfo[1]
        self.movietitle = movietitle
        self.movieinfo = movieinfo
        self.destination = config.mediaportal.storagepath.value
        self.moviepath = self.destination + ".http_movie"
        self.referer_val = movieinfo[2]
        if self.referer_val != '':
            self.referer = "--header 'Referer: %s'" % self.referer_val
        else:
            self.referer = ''

        self.useragent = "QuickTime/7.6.2 (qtver=7.6.2;os=Windows NT 5.1Service Pack 3)"
        self.useragent_header = "--user-agent '%s'" % self.useragent

        self.streamactive = False
        self.isVisible = True

        self.container = eConsoleAppContainer()
        self.container.appClosed.append(self.copyfinished)
        self.container.stdoutAvail.append(self.progressUpdate)
        self.container.stderrAvail.append(self.progressUpdate)
        self.container.setCWD(self.destination)

        self.oldService = self.session.nav.getCurrentlyPlayingServiceReference(
        )

        self.BgFileEraser = eBackgroundFileEraser.getInstance()

        try:
            req = Request(self.url)
            req.add_header('User-agent', self.useragent)
            req.add_header('Referer', self.referer_val)
            usock = urlopen(req)
            filesize = usock.info().get('Content-Length')
        except Exception, e:
            filesize = 0
Exemplo n.º 20
0
	def __init__(self, session, movieinfo, movietitle):
		self.skin = PlayHttpMovie.skin
		Screen.__init__(self, session)

		self.url = movieinfo[0]
		self.filename = movieinfo[1]
		self.movietitle = movietitle
		self.movieinfo = movieinfo
		self.destination = config.mediaportal.storagepath.value
		self.moviepath = self.destination + ".http_movie"
		self.referer_val = movieinfo[2]
		if self.referer_val != '':
			self.referer = "--header 'Referer: %s'" % self.referer_val
		else:
			self.referer = ''
		
		self.useragent = "QuickTime/7.6.2 (qtver=7.6.2;os=Windows NT 5.1Service Pack 3)"
		self.useragent_header = "--user-agent '%s'" % self.useragent
		
		self.streamactive = False
		self.isVisible = True

		self.container=eConsoleAppContainer()
		self.container.appClosed.append(self.copyfinished)
		self.container.stdoutAvail.append(self.progressUpdate)
		self.container.stderrAvail.append(self.progressUpdate)
		self.container.setCWD(self.destination)

		self.oldService = self.session.nav.getCurrentlyPlayingServiceReference()

		self.BgFileEraser = eBackgroundFileEraser.getInstance()

		try:
			req = Request(self.url)
			req.add_header('User-agent',self.useragent)
			req.add_header('Referer',self.referer_val)
			usock = urlopen(req)
			filesize =  usock.info().get('Content-Length')
		except Exception, e:
			filesize = 0
Exemplo n.º 21
0
    def __init__(self, session, movieinfo, movietitle):
        self.skin = PlayRtmpMovie.skin
        Screen.__init__(self, session)

        self.url = movieinfo[0]
        self.filename = movieinfo[1]
        self.movietitle = movietitle
        self.movieinfo = movieinfo
        self.destination = config.mediaportal.storagepath.value
        #self.moviepath = self.destination + ASCIItranslit.legacyEncode(self.filename)
        self.moviepath = self.destination + ".rtmp_movie"

        self.streamactive = False
        self.isVisible = True

        self.container = eConsoleAppContainer()
        self.container.appClosed.append(self.copyfinished)
        self.container.stdoutAvail.append(self.progressUpdate)
        self.container.stderrAvail.append(self.progressUpdate)
        self.container.setCWD(self.destination)

        self.oldService = self.session.nav.getCurrentlyPlayingServiceReference(
        )

        self.BgFileEraser = eBackgroundFileEraser.getInstance()

        filesize = 0
        self.filesize = float(filesize)  # in bytes

        self.dummyfilesize = False
        self.lastcmddata = None
        self.lastlocalsize = 0
        self.localsize = 0
        self.isplaying = False
        self.autoplaythreshold = config.mediaportal.autoplayThreshold.value

        self["key_green"] = Button(_("Play"))
        self["key_red"] = Button(_("Cancel"))
        self["key_blue"] = Button(_("Show/Hide"))

        self["label_filename"] = StaticText("File: %s" % (self.filename))
        self["label_progress"] = StaticText("Progress: N/A")
        self["label_speed"] = StaticText("Speed: N/A")
        self["label_timeleft"] = StaticText("Time left: N/A")

        self["actions"] = ActionMap(
            ["OkCancelActions", "ColorActions"], {
                "cancel": self.exit,
                "ok": self.okbuttonClick,
                "red": self.exit,
                "green": self.playfile,
                "blue": self.visibility
            }, -1)

        self.StatusTimer = eTimer()
        self.StatusTimer.callback.append(self.UpdateStatus)

        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider

        self.onFirstExecBegin.append(self.firstExecBegin)
Exemplo n.º 22
0
    def JobTrash(self):
        ctimeLimit = time() - (config.crash.daysloglimit.value * 3600 * 24)
        allowedBytes = 1024 * 1024 * int(config.crash.sizeloglimit.value)

        mounts = []
        matches = []
        print("[LogManager] probing folders")
        f = open('/proc/mounts', 'r')
        for line in f.readlines():
            parts = line.strip().split()
            mounts.append(parts[1])
        f.close()

        if (datetime.now().hour == 3) or (
                time() - config.crash.lastfulljobtrashtime.value > 3600 * 24):
            #full JobTrash (in all potential log file dirs) between 03:00 and 04:00 AM / every 24h
            config.crash.lastfulljobtrashtime.setValue(int(time()))
            config.crash.lastfulljobtrashtime.save()
            configfile.save()
            for mount in mounts:
                if path.isdir(path.join(mount, 'logs')):
                    matches.append(path.join(mount, 'logs'))
            matches.append('/home/root/logs')
        else:
            #small JobTrash (in selected log file dir only) twice a day
            matches.append(config.crash.debug_path.value)

        print("[LogManager] found following log's:", matches)
        if len(matches):
            for logsfolder in matches:
                print("[LogManager] looking in:", logsfolder)
                logssize = get_size(logsfolder)
                bytesToRemove = logssize - allowedBytes
                candidates = []
                size = 0
                for root, dirs, files in walk(logsfolder, topdown=False):
                    for name in files:
                        try:
                            fn = path.join(root, name)
                            st = stat(fn)
                            if st.st_ctime < ctimeLimit:
                                print("[LogManager] " + str(fn) + ": Too old:",
                                      name, st.st_ctime)
                                eBackgroundFileEraser.getInstance().erase(fn)
                                bytesToRemove -= st.st_size
                            else:
                                candidates.append(
                                    (st.st_ctime, fn, st.st_size))
                                size += st.st_size
                        except Exception as e:
                            print("[LogManager] Failed to stat %s:" % name, e)
                    # Remove empty directories if possible
                    for name in dirs:
                        try:
                            rmdir(path.join(root, name))
                        except:
                            pass
                    candidates.sort()
                    # Now we have a list of ctime, candidates, size. Sorted by ctime (=deletion time)
                    for st_ctime, fn, st_size in candidates:
                        print(
                            "[LogManager] " + str(logsfolder) +
                            ": bytesToRemove", bytesToRemove)
                        if bytesToRemove < 0:
                            break
                        eBackgroundFileEraser.getInstance().erase(fn)
                        bytesToRemove -= st_size
                        size -= st_size
        now = datetime.now()
        seconds_since_0330am = (
            now - now.replace(hour=3, minute=30, second=0)).total_seconds()
        if (seconds_since_0330am <= 0):
            seconds_since_0330am += 86400
        if (seconds_since_0330am > 43200):
            self.TrashTimer.startLongTimer(
                int(86400 - seconds_since_0330am))  #at 03:30 AM
        else:
            self.TrashTimer.startLongTimer(43200)  #twice a day
Exemplo n.º 23
0
	def delete_all_cache(self):
		bgFileEraser = eBackgroundFileEraser.getInstance()
		for path in self._cached_files.itervalues():
			bgFileEraser.erase(str(path))
		self._cached_files.clear()
Exemplo n.º 24
0
	def __init__(self, session, movieinfo, movietitle, playCallback=None):
		self.plugin_path = mp_globals.pluginPath
		self.skin_path = mp_globals.pluginPath + mp_globals.skinsPath
		path = "%s/%s/PlayRtmpMovie.xml" % (self.skin_path, config.mediaportal.skin.value)
		if not fileExists(path):
			path = self.skin_path + mp_globals.skinFallback + "/PlayRtmpMovie.xml"
		with open(path, "r") as f:
			self.skin = f.read()
			f.close()

		Screen.__init__(self, session)
		self['title'] = Label("Caching...")
		self.setTitle("Caching...")

		self.playCallback = playCallback
		self.url = movieinfo[0]
		self.filename = movieinfo[1]
		self.movietitle = movietitle
		self.movieinfo = movieinfo
		self.destination = config.mediaportal.storagepath.value
		#self.moviepath = self.destination + ASCIItranslit.legacyEncode(self.filename)
		self.moviepath = self.destination + ".rtmp_movie"

		self.streamactive = False
		self.isVisible = True

		self.container=eConsoleAppContainer()
		if mp_globals.isDreamOS:
			self.container.appClosed_conn = self.container.appClosed.connect(self.copyfinished)
			self.container.stdoutAvail_conn = self.container.stdoutAvail.connect(self.progressUpdate)
			self.container.stderrAvail_conn = self.container.stderrAvail.connect(self.progressUpdate)
		else:
			self.container.appClosed.append(self.copyfinished)
			self.container.stdoutAvail.append(self.progressUpdate)
			self.container.stderrAvail.append(self.progressUpdate)
		self.container.setCWD(self.destination)

		self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()

		self.BgFileEraser = eBackgroundFileEraser.getInstance()

		self.filesize = 0.0 # in bytes

		self.dummyfilesize = False
		self.lastcmddata = None
		self.lastlocalsize = 0.0
		self.localsize = 0.0
		self.isplaying = False
		self.autoplaythreshold = config.mediaportal.autoplayThreshold.value

		self["key_green"] = Button(_("Play"))
		self["key_red"] = Button(_("Cancel"))
		self["key_blue"] = Button(_("Hide"))

		self["label_filename"] = StaticText("File: %s" % (self.filename))
		self["label_progress"] = StaticText("Progress: N/A")
		self["label_speed"] = StaticText("Speed: N/A")
		self["label_timeleft"] = StaticText("Time left: N/A")

		self["actions"] = ActionMap(["MP_Actions"],
		{
			"cancel": self.exit,
			"ok": self.okbuttonClick,
			"red": self.exit,
			"green": self.playfile,
			"blue": self.visibility
		}, -1)

		self.StatusTimer = eTimer()
		if mp_globals.isDreamOS:
			self.StatusTimer_conn = self.StatusTimer.timeout.connect(self.UpdateStatus)
		else:
			self.StatusTimer.callback.append(self.UpdateStatus)

		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider

		self.onFirstExecBegin.append(self.firstExecBegin)
Exemplo n.º 25
0
	def updateEraseFlags(el):
		eBackgroundFileEraser.getInstance().setEraseFlags(int(el.value))
Exemplo n.º 26
0
	def delete_all_cache(self):
		bgFileEraser = eBackgroundFileEraser.getInstance()
		for path in self._cached_files.itervalues():
			bgFileEraser.erase(str(path))
		self._cached_files.clear()
Exemplo n.º 27
0
	def JobTrash(self):
		ctimeLimit = time() - (config.crash.daysloglimit.value * 3600 * 24)
		allowedBytes = 1024*1024 * int(config.crash.sizeloglimit.value)

		mounts = []
		matches = []
		print "[LogManager] probing folders"
		f = open('/proc/mounts', 'r')
		for line in f.readlines():
			parts = line.strip().split()
			mounts.append(parts[1])
		f.close()

		if (datetime.now().hour == 3) or (time() - config.crash.lastfulljobtrashtime.value > 3600 * 24):
			#full JobTrash (in all potential log file dirs) between 03:00 and 04:00 AM / every 24h
			config.crash.lastfulljobtrashtime.setValue(int(time()))
			config.crash.lastfulljobtrashtime.save()
			configfile.save()
			for mount in mounts:
				if path.isdir(path.join(mount,'logs')):
					matches.append(path.join(mount,'logs'))
			matches.append('/home/root/logs')
		else:
			#small JobTrash (in selected log file dir only) twice a day
			matches.append(config.crash.debug_path.value)

		print "[LogManager] found following log's:", matches
		if len(matches):
			for logsfolder in matches:
				print "[LogManager] looking in:", logsfolder
				logssize = get_size(logsfolder)
				bytesToRemove = logssize - allowedBytes
				candidates = []
				size = 0
				for root, dirs, files in walk(logsfolder, topdown=False):
					for name in files:
						try:
							fn = path.join(root, name)
							st = stat(fn)
							#print "Logname: %s" % fn
							#print "Last created: %s" % ctime(st.st_ctime)
							#print "Last modified: %s" % ctime(st.st_mtime)
							if st.st_mtime < ctimeLimit:
								print "[LogManager] " + str(fn) + ": Too old:", ctime(st.st_mtime)
								eBackgroundFileEraser.getInstance().erase(fn)
								bytesToRemove -= st.st_size
							else:
								candidates.append((st.st_mtime, fn, st.st_size))
								size += st.st_size
						except Exception, e:
							print "[LogManager] Failed to stat %s:"% name, e
					# Remove empty directories if possible
					for name in dirs:
						try:
							rmdir(path.join(root, name))
						except:
							pass
					candidates.sort()
					# Now we have a list of ctime, candidates, size. Sorted by ctime (=deletion time)
					for st_ctime, fn, st_size in candidates:
						print "[LogManager] " + str(logsfolder) + ": bytesToRemove", bytesToRemove
						if bytesToRemove < 0:
							break
						eBackgroundFileEraser.getInstance().erase(fn)
						bytesToRemove -= st_size
						size -= st_size
Exemplo n.º 28
0
	def updateEraseFlags(el):
		eBackgroundFileEraser.getInstance().setEraseFlags(int(el.value))
Exemplo n.º 29
0
def initDebug():
	try:
		# os.remove("/tmp/FritzDebug.log")
		eBackgroundFileEraser.getInstance().erase("/tmp/FritzDebug.log")
	except OSError:
		pass