0
私は、テスト結果の100分の1の概要を示すツールを作成しています。このツールはログファイルにアクセスし、合格と失敗の判定をチェックします。失敗した場合は、ログの前の行に戻って失敗の原因を取り出す必要があります。 linecache.getlineは私のワークスペースで動作します(PythonはEclipse経由で動作します)。しかし、私はWindowsインストーラ(.exeファイル)を作成し、自分のコンピュータにアプリケーションをインストールした後、linecache.getlineは何も返しません。これを修正するために私のsetup.pyファイルに追加する必要があるのでしょうか、それとも私のコードの問題ですか?アプリケーションのインストール後にラインキャッシングgetlineが機能しない
ツールコード
precon:wx.FileDialogから 、ログファイルにアクセス
self.result_path = dlg.GetPath()
try:
with open(self.result_path, 'r') as file:
self.checkLog(self.result_path, file)
def checkLog(self, path, f):
line_no = 1
index = 0
for line in f:
n = re.search("FAIL", line, re.IGNORECASE) or re.search("PASS", line, re.IGNORECASE)
if n:
currentline = re.sub('\s+', ' ', line.rstrip())
finalresult = currentline
self.list_ctrl.InsertStringItem(index, finaltestname)
self.list_ctrl.SetStringItem(index, 1, finalresult)
if currentline == "FAIL":
fail_line1 = linecache.getline(path, int(line_no - 3)) #Get reason of failure
fail_line2 = linecache.getline(path, int(line_no - 2)) #Get reason of failure
cause = fail_line1.strip() + " " + fail_line2.strip()
self.list_ctrl.SetStringItem(index, 2, cause)
index += 1
line_no += 1