daca2: minor tweaks of wget and removeLargeFiles
This commit is contained in:
parent
32e2a5b879
commit
aaf5bbb7ad
|
@ -14,13 +14,26 @@ import os
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
|
|
||||||
FTPSERVER = 'ftp.sunet.se'
|
DEBIAN = ['ftp://ftp.sunet.se/pub/Linux/distributions/Debian/debian/',
|
||||||
FTPPATH = '/pub/Linux/distributions/Debian/debian/'
|
'http://ftp.sunet.se/pub/Linux/distributions/Debian/debian/',
|
||||||
|
'ftp://ftp.debian.org/debian/']
|
||||||
|
|
||||||
|
|
||||||
|
def wget(filepath):
|
||||||
|
filename = filepath
|
||||||
|
if filepath.find('/') >= 0:
|
||||||
|
filename = filename[filename.rfind('/') + 1:]
|
||||||
|
for d in DEBIAN:
|
||||||
|
subprocess.call(['nice', 'wget', d + filepath])
|
||||||
|
if os.path.isfile(filename):
|
||||||
|
return True
|
||||||
|
time.sleep(10)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def getpackages(folder):
|
def getpackages(folder):
|
||||||
subprocess.call(
|
if not wget('ls-lR.gz'):
|
||||||
['nice', 'wget', 'ftp://' + FTPSERVER + FTPPATH + 'ls-lR.gz'])
|
return []
|
||||||
subprocess.call(['nice', 'gunzip', 'ls-lR.gz'])
|
subprocess.call(['nice', 'gunzip', 'ls-lR.gz'])
|
||||||
f = open('ls-lR', 'rt')
|
f = open('ls-lR', 'rt')
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
|
@ -98,24 +111,25 @@ def removeLargeFiles(path):
|
||||||
continue
|
continue
|
||||||
if os.path.isdir(g):
|
if os.path.isdir(g):
|
||||||
removeLargeFiles(g + '/')
|
removeLargeFiles(g + '/')
|
||||||
elif g != 'results.txt':
|
elif os.path.isfile(g) and g != 'results.txt':
|
||||||
statinfo = os.stat(g)
|
statinfo = os.stat(g)
|
||||||
if statinfo.st_size > 100000:
|
if statinfo.st_size > 100000:
|
||||||
os.remove(g)
|
os.remove(g)
|
||||||
|
|
||||||
|
|
||||||
def scanarchive(fullpath):
|
def scanarchive(filepath):
|
||||||
results = open('results.txt', 'at')
|
results = open('results.txt', 'at')
|
||||||
results.write(fullpath + '\n')
|
results.write(DEBIAN[0] + filepath + '\n')
|
||||||
results.close()
|
results.close()
|
||||||
|
|
||||||
filename = fullpath[fullpath.rfind('/') + 1:]
|
if not wget(filepath):
|
||||||
count = 5
|
if not wget(filepath):
|
||||||
while count > 0 and not os.path.isfile(filename):
|
results = open('results.txt', 'at')
|
||||||
count = count - 1
|
results.write('wget failed\n')
|
||||||
time.sleep(10)
|
results.close()
|
||||||
subprocess.call(['nice', 'wget', fullpath])
|
return
|
||||||
|
|
||||||
|
filename = filepath[filepath.rfind('/') + 1:]
|
||||||
if filename[-3:] == '.gz':
|
if filename[-3:] == '.gz':
|
||||||
subprocess.call(['tar', 'xzvf', filename])
|
subprocess.call(['tar', 'xzvf', filename])
|
||||||
elif filename[-3:] == '.xz':
|
elif filename[-3:] == '.xz':
|
||||||
|
@ -138,7 +152,8 @@ def scanarchive(fullpath):
|
||||||
|
|
||||||
removeLargeFiles('')
|
removeLargeFiles('')
|
||||||
|
|
||||||
print('cppcheck "' + dirname + '"')
|
print(filename + ': cppcheck ' + dirname)
|
||||||
|
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
['nice',
|
['nice',
|
||||||
'../cppcheck-O2',
|
'../cppcheck-O2',
|
||||||
|
@ -199,7 +214,7 @@ try:
|
||||||
# remove all files/folders except results.txt
|
# remove all files/folders except results.txt
|
||||||
removeAllExceptResults()
|
removeAllExceptResults()
|
||||||
|
|
||||||
scanarchive('ftp://' + FTPSERVER + FTPPATH + archive)
|
scanarchive(archive)
|
||||||
|
|
||||||
except EOFError:
|
except EOFError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue