donate-cpu: Try to fix exception in hasInclude

This commit is contained in:
Daniel Marjamäki 2018-12-03 18:15:07 +01:00
parent 768eb79653
commit 0249e408d3
1 changed files with 6 additions and 9 deletions

View File

@ -19,7 +19,6 @@
# Quick start: just run this script without any arguments # Quick start: just run this script without any arguments
import shutil import shutil
import glob
import os import os
import subprocess import subprocess
import sys import sys
@ -190,17 +189,15 @@ def unpackPackage(workPath, tgz):
os.chdir(workPath) os.chdir(workPath)
def hasInclude(path,inc): def hasInclude(path, inc):
for g in glob.glob(path + '/*'): for root, _, files in os.walk(path):
if os.path.isfile(g): for name in files:
f = open(g,'rt') filename = os.path.join(root, name)
filedata = f.read() f = open(filename, 'rt')
filedata = f.read().decode(encoding='utf-8', errors='ignore')
f.close() f.close()
if filedata.find('\n#include ' + inc) >= 0: if filedata.find('\n#include ' + inc) >= 0:
return True return True
elif os.path.isdir(g) and not g.startswith('.'):
if hasInclude(g, inc) is True:
return True
return False return False