From 1c03243d9a04d7412132a421fb4b9d530ea4ea8b Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 4 Nov 2018 23:20:06 +0800 Subject: [PATCH] u --- class/public.py | 22 +++++++++------------- route/files.py | 2 +- task.py | 8 ++++++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/class/public.py b/class/public.py index 30086a1fd..4451a3390 100755 --- a/class/public.py +++ b/class/public.py @@ -241,15 +241,14 @@ def getSpeed(): return json.loads(data) -def GetLastLine(inputfile, lineNum): +def getLastLine(inputfile, lineNum): # 读文件指定倒数行数 try: fp = open(inputfile, 'r') - print fp lastLine = "" lines = fp.readlines() - print lines + count = len(lines) if count > lineNum: num = lineNum @@ -265,17 +264,14 @@ def GetLastLine(inputfile, lineNum): lastre.append(lastLine) result = '' - lineNum -= 1 - print lastre - while lineNum > 0: - print lineNum - # lastre[lineNum] - # result += lastre[lineNum] + "\n" - lineNum -= 1 - + num -= 1 + while num > 0: + print num + lastre[num] + result += lastre[num] + "\n" + num -= 1 return result - except (IOError, ZeroDivisionError), e: - # print e.message + except: return getMsg('TASK_SLEEP') diff --git a/route/files.py b/route/files.py index 56452a0f8..df02333c7 100644 --- a/route/files.py +++ b/route/files.py @@ -28,7 +28,7 @@ def GetExecLog(): file = os.getcwd() + "/tmp/panelExec.log" print file - v = public.GetLastLine(file, 100) + v = public.getLastLine(file, 100) return v diff --git a/task.py b/task.py index 5f8eed67a..08685ea27 100755 --- a/task.py +++ b/task.py @@ -28,8 +28,12 @@ isTask = os.getcwd() + '/tmp/panelTask.pl' if ~os.path.exists(os.getcwd() + "/tmp"): os.system('mkdir -p ' + os.getcwd() + "/tmp") - os.system("echo '' > " + logPath) - os.system("echo '' > " + isTask) + +if ~os.path.exists(logPath): + os.system("touch " + logPath) + +if ~os.path.exists(isTask): + os.system("touch " + isTask) class MyBad():