This commit is contained in:
Ruud
2011-09-28 08:56:29 +02:00
parent 4ca5f6f1c5
commit c6f322a2c2
3 changed files with 41 additions and 13 deletions
+16 -2
View File
@@ -2,6 +2,7 @@ from couchpotato.api import addApiView
from couchpotato.core.helpers.request import jsonified, getParam
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
import os
class Logging(Plugin):
@@ -12,10 +13,22 @@ class Logging(Plugin):
def get(self):
nr = int(getParam('nr', 0))
path = '%s%s' % (Env.get('log_path'), '.%s' % nr if nr > 0 else '')
total = 1
for x in range(0, 50):
path = '%s%s' % (Env.get('log_path'), '.%s' % x if x > 0 else '')
# Set current path
if x is nr:
current_path = path
# Check see if the log exists
if not os.path.isfile(path):
total = x
break
# Reverse
f = open(path, 'r')
f = open(current_path, 'r')
lines = []
for line in f.readlines():
lines.insert(0, line)
@@ -27,4 +40,5 @@ class Logging(Plugin):
return jsonified({
'success': True,
'log': log,
'total': total,
})