def prepareFilmPage(self): style = '<style>body { float:left;} div {white-space: nowrap;padding:2px;margin:0px;font-family: Helvetica, Arial, sans-serif;font-size:0.85em;} .evenrow {background-color: #F8E0D7;} .oddrow {background-color: #F8EEEE;} .back {float:right}</style>' htmlStart = '<!DOCTYPE html><html><head><meta content="text/html; charset=UTF-8">' + style + '<title>Recorded Films</title><body>' htmlend = '--- End ---</body></html>' htmlBack = '<div class= back><a href="./Log.html">Back to Log</a></div>' srcFile = self._config.getLoggingPath() srcFile = OSTools.ensureFile(srcFile, "Filmlist.txt") destFile = self._config.getFilePath(self._config.getWebPath(), "Films.html") with codecs.open(srcFile, 'r', encoding="utf-8") as logFile: logLines = logFile.readlines() isEven = False with open(destFile, 'w+') as htmlFile: htmlFile.write(htmlStart) htmlFile.write("<b> The film list</b>") htmlFile.write(htmlBack) for line in logLines: if isEven: divid = "evenrow" else: divid = "oddrow" hack = self.utf8ToHTMLUmlauts(line) htmlFile.write('<div class="' + divid + '">' + hack + "</div>") isEven = not isEven htmlFile.write(htmlend)
def __linkLogging(self): # ../../../VideoRecorder/src/log/ # NO! That is where the command shell sits: currentPath=os.getcwd() destFile = self._config.getFilePath(self._config.getWebPath(), "Log.txt") srcFile = self._config.getLoggingPath(); srcFile = OSTools.ensureFile(srcFile, "dvb_suspend.log") self._config.logInfo("Linking file:" + srcFile) if not os.path.lexists(destFile): os.symlink(srcFile, destFile)
def prepareLogFile(self, lineStart, lineCount): #read the log file, prepare it and put it into the log file text? self.log("Getting Log request") srcFile = self._config.getLoggingPath() srcFile = OSTools.ensureFile(srcFile, "dvb_suspend.log") destFile = self._config.getFilePath(self._config.getWebPath(), "Log.html") style = '<style>body { float:left;} div {white-space: nowrap;padding:2px;margin:0px;font-family: Helvetica, Arial, sans-serif;font-size:0.85em;} .evenrow {background-color: #F8E0D7;} .oddrow {background-color: #F8EEEE;}</style>' htmlStart = '<!DOCTYPE html><html><head><meta content="text/html; charset=UTF-8">' + style + '<title>Micro Recorder Log</title><body>' htmlend = '--- End ---</body></html>' htmlmore = '<a href="./Log.html?NXT">Log more?</a></body></html>' htmlFilms = '<a href="./Films.html">Show Films</a>' with codecs.open(srcFile, 'r', encoding='utf-8') as logFile: logLines = logFile.readlines() startIndex = len(logLines) reqLines = lineStart + lineCount reqEnd = max(0, startIndex - reqLines) print(("start:", startIndex, " to:", reqEnd)) #aRange=reversed(range(reqEnd,startIndex)) isEven = False with open(destFile, 'w+') as htmlFile: htmlFile.write(htmlStart) htmlFile.write("<b> The Logs (newest first) </b>") htmlFile.write(htmlFilms) #for line in logLines: lineIndex = startIndex while lineIndex > reqEnd: lineIndex -= 1 line = logLines[lineIndex] if isEven: divid = "evenrow" else: divid = "oddrow" htmlFile.write('<div class="' + divid + '">' + line + "</div>") isEven = not isEven if reqEnd == 0: htmlFile.write(htmlend) else: htmlFile.write(htmlmore)
def prepareLogFile(self,lineStart,lineCount): #read the log file, prepare it and put it into the log file text? self.log("Getting Log request") srcFile = self._config.getLoggingPath(); srcFile = OSTools.ensureFile(srcFile, "dvb_suspend.log") destFile = self._config.getFilePath(self._config.getWebPath(), "Log.html") style ='<style>body { float:left;} div {white-space: nowrap;padding:2px;margin:0px;font-family: Helvetica, Arial, sans-serif;font-size:0.85em;} .evenrow {background-color: #F8E0D7;} .oddrow {background-color: #F8EEEE;}</style>' htmlStart = '<!DOCTYPE html><html><head><meta content="text/html; charset=UTF-8">'+style+'<title>Micro Recorder Log</title><body>' htmlend = '--- End ---</body></html>' htmlmore = '<a href="./Log.html?NXT">Log more?</a></body></html>' with codecs.open(srcFile, 'r',"utf-8") as logFile: logLines = logFile.readlines() startIndex = len(logLines) reqLines = lineStart+lineCount reqEnd = max(0,startIndex-reqLines) print "start:",startIndex," to:",reqEnd #aRange=reversed(range(reqEnd,startIndex)) isEven=False with open(destFile, 'w+') as htmlFile: htmlFile.write(htmlStart) htmlFile.write("<b> The Logs (newest first) </b>") #for line in logLines: lineIndex = startIndex while lineIndex > reqEnd: lineIndex-=1; line=logLines[lineIndex] asccode = line.encode('ascii', 'xmlcharrefreplace') #makes utf8 readable! if isEven: divid="evenrow" else: divid="oddrow" htmlFile.write('<div class="'+divid+'">'+asccode+"</div>") isEven=not isEven if reqEnd==0: htmlFile.write(htmlend) else: htmlFile.write(htmlmore)