示例#1
0
def createBackup():
    import SerienRecorder
    from SerienRecorderLogWriter import SRLogger
    from SerienRecorderTVPlaner import SERIENRECORDER_TVPLANER_HTML_FILENAME
    lt = time.localtime()

    # Remove old backups
    if config.plugins.serienRec.deleteBackupFilesOlderThan.value > 0:
        SRLogger.writeLog(
            "\nEntferne alte Backup-Dateien und erzeuge neues Backup.", True)
        now = time.time()
        logFolderPattern = re.compile('\d{4}\d{2}\d{2}\d{2}\d{2}')
        for root, dirs, files in os.walk(
                config.plugins.serienRec.BackupPath.value, topdown=False):
            for name in dirs:
                if logFolderPattern.match(name) and os.stat(
                        os.path.join(root, name)).st_ctime < (
                            now - config.plugins.serienRec.
                            deleteBackupFilesOlderThan.value * 24 * 60 * 60):
                    shutil.rmtree(os.path.join(root, name), True)
                    SRLogger.writeLog(
                        "Lösche Ordner: %s" % os.path.join(root, name), True)
    else:
        SRLogger.writeLog("Erzeuge neues Backup", True)

    BackupPath = "%s%s%s%s%s%s/" % (
        config.plugins.serienRec.BackupPath.value, lt.tm_year, str(
            lt.tm_mon).zfill(2), str(lt.tm_mday).zfill(2), str(
                lt.tm_hour).zfill(2), str(lt.tm_min).zfill(2))
    if not os.path.exists(BackupPath):
        try:
            os.makedirs(BackupPath)
        except:
            pass
    if os.path.isdir(BackupPath):
        try:
            if fileExists(SerienRecorder.serienRecDataBaseFilePath):
                from SerienRecorderDatabase import SRDatabase
                database = SRDatabase(SerienRecorder.serienRecDataBaseFilePath)
                database.backup(BackupPath)
            if fileExists(SRLogger.getLogFilePath()):
                shutil.copy(SRLogger.getLogFilePath(), BackupPath)
            if fileExists("/etc/enigma2/timers.xml"):
                shutil.copy("/etc/enigma2/timers.xml", BackupPath)
            if fileExists("%sConfig.backup" %
                          SerienRecorder.serienRecMainPath):
                shutil.copy(
                    "%sConfig.backup" % SerienRecorder.serienRecMainPath,
                    BackupPath)
            STBHelpers.saveEnigmaSettingsToFile(BackupPath)
            for filename in os.listdir(BackupPath):
                os.chmod(os.path.join(BackupPath, filename), 0o777)
            if fileExists(SERIENRECORDER_TVPLANER_HTML_FILENAME %
                          config.plugins.serienRec.LogFilePath.value):
                shutil.copy(
                    SERIENRECORDER_TVPLANER_HTML_FILENAME %
                    config.plugins.serienRec.LogFilePath.value, BackupPath)
        except Exception, e:
            SRLogger.writeLog("Backup konnte nicht erstellt werden: " + str(e),
                              True)
	def readLog(self):
		print "[SerienRecorder] readLog called"
		if SerienRecorder.autoCheckFinished:
			if self.readLogTimer:
				self.readLogTimer.stop()
				self.readLogTimer = None
			print "[SerienRecorder] update log reader stopped."
			self['title'].setText("Auto-Check fertig !")

			from SerienRecorderLogWriter import SRLogger
			logFileHandle = open(SRLogger.getLogFilePath(), "r")
			for zeile in logFileHandle.readlines():
				if (not config.plugins.serienRec.logWrapAround.value) or (len(zeile.strip()) > 0):
					self.logliste.append(zeile)
			logFileHandle.close()
			self.chooseMenuList.setList(map(self.buildList, self.logliste))
			if config.plugins.serienRec.logScrollLast.value:
				count = len(self.logliste)
				if count != 0:
					self['log'].moveToIndex(int(count - 1))
			SerienRecorder.autoCheckRunning = False
		else:
			print "[SerienRecorder] waiting"
			self.points += " ."
			self['title'].setText("Suche nach neuen Timern läuft.%s" % self.points)
			self.executeAutoCheck()
示例#3
0
	def setupSkin(self):
		self.skin = None
		InitSkin(self)

		self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
		self.chooseMenuList.l.setFont(0, gFont('Regular', 20 + int(config.plugins.serienRec.listFontsize.value)))
		if config.plugins.serienRec.logWrapAround.value:
			self.chooseMenuList.l.setItemHeight(int(70 *skinFactor))
		else:
			self.chooseMenuList.l.setItemHeight(int(25 *skinFactor))
		self['log'] = self.chooseMenuList
		self['log'].show()
		self['video'].hide()
		self['cover'].hide()

		self['title'].setText("Lese LogFile: (%s)" % SRLogger.getLogFilePath())

		if not config.plugins.serienRec.showAllButtons.value:
			self['bt_red'].show()
			self['bt_exit'].show()
			self['bt_info'].show()
			self['bt_menu'].show()

			self['text_red'].show()
			self['text_0'].show()
			self['text_1'].show()
			self['text_2'].show()
			self['text_3'].show()
			self['text_4'].show()
示例#4
0
    def readLog(self):
        print "[SerienRecorder] readLog called"
        if SerienRecorder.autoCheckFinished:
            if self.readLogTimer:
                self.readLogTimer.stop()
                self.readLogTimer = None
            print "[SerienRecorder] update log reader stopped."
            self['title'].setText("Auto-Check fertig !")

            from SerienRecorderLogWriter import SRLogger
            logFileHandle = open(SRLogger.getLogFilePath(), "r")
            for zeile in logFileHandle.readlines():
                if (not config.plugins.serienRec.logWrapAround.value) or (len(
                        zeile.strip()) > 0):
                    self.logliste.append(zeile)
            logFileHandle.close()
            self.chooseMenuList.setList(map(self.buildList, self.logliste))
            if config.plugins.serienRec.logScrollLast.value:
                count = len(self.logliste)
                if count != 0:
                    self['log'].moveToIndex(int(count - 1))
            SerienRecorder.autoCheckRunning = False
        else:
            print "[SerienRecorder] waiting"
            self.points += " ."
            self['title'].setText("Suche nach neuen Timern läuft.%s" %
                                  self.points)
            self.executeAutoCheck()
def createBackup():
	import SerienRecorder
	from SerienRecorderLogWriter import SRLogger
	lt = time.localtime()

	# Remove old backups
	if config.plugins.serienRec.deleteBackupFilesOlderThan.value > 0:
		SRLogger.writeLog("\nEntferne alte Backup-Dateien und erzeuge neues Backup.", True)
		now = time.time()
		logFolderPattern = re.compile('\d{4}\d{2}\d{2}\d{2}\d{2}')
		for root, dirs, files in os.walk(config.plugins.serienRec.BackupPath.value, topdown=False):
			for name in dirs:
				if logFolderPattern.match(name) and os.stat(os.path.join(root, name)).st_ctime < (now - config.plugins.serienRec.deleteBackupFilesOlderThan.value * 24 * 60 * 60):
					shutil.rmtree(os.path.join(root, name), True)
					SRLogger.writeLog("Lösche Ordner: %s" % os.path.join(root, name), True)
	else:
		SRLogger.writeLog("Erzeuge neues Backup", True)

	BackupPath = "%s%s%s%s%s%s/" % (config.plugins.serienRec.BackupPath.value, lt.tm_year, str(lt.tm_mon).zfill(2), str(lt.tm_mday).zfill(2), str(lt.tm_hour).zfill(2), str(lt.tm_min).zfill(2))
	if not os.path.exists(BackupPath):
		try:
			os.makedirs(BackupPath)
		except:
			pass
	if os.path.isdir(BackupPath):
		try:
			if fileExists(SerienRecorder.serienRecDataBaseFilePath):
				from SerienRecorderDatabase import SRDatabase
				database = SRDatabase(SerienRecorder.serienRecDataBaseFilePath)
				database.backup(BackupPath)
			if fileExists(SRLogger.getLogFilePath()):
				shutil.copy(SRLogger.getLogFilePath(), BackupPath)
			if fileExists("/etc/enigma2/timers.xml"):
				shutil.copy("/etc/enigma2/timers.xml", BackupPath)
			if fileExists("%sConfig.backup" % SerienRecorder.serienRecMainPath):
				shutil.copy("%sConfig.backup" % SerienRecorder.serienRecMainPath, BackupPath)
			STBHelpers.saveEnigmaSettingsToFile(BackupPath)
			for filename in os.listdir(BackupPath):
				os.chmod(os.path.join(BackupPath, filename), 0o777)
		except Exception, e:
			SRLogger.writeLog("Backup konnte nicht erstellt werden: " + str(e), True)
示例#6
0
	def readLog(self):
		logFilePath = SRLogger.getLogFilePath()
		if not fileExists(logFilePath):
			open(logFilePath, 'w').close()

		logFileSize = os.path.getsize(logFilePath)
		if not logFileSize == 0:
			readLog = open(logFilePath, "r")
			logliste = []
			for zeile in readLog.readlines():
				if (not config.plugins.serienRec.logWrapAround.value) or (len(zeile.strip()) > 0):
					logliste.append(zeile)
			readLog.close()
			self['title'].hide()
			self['path'].setText("LogFile:\n(%s)" % logFilePath)
			self['path'].show()
			self.chooseMenuList.setList(map(self.buildList, logliste))
			if config.plugins.serienRec.logScrollLast.value:
				count = len(logliste)
				if count != 0:
					self['log'].moveToIndex(int(count -1))