Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions tools/daca2-download.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ def getpackages():
filename = line[1 + line.rfind(' '):]
filenames.append(filename)

for a in archives:
print(a)

return archives


Expand Down Expand Up @@ -114,6 +111,17 @@ def removeAll():
count = 0


def accept_filename(filename:str):
if '.' not in filename:
return False
ext = filename[filename.rfind('.'):]
if ext == '.proto' and ('--protobuf' in sys.argv):
print('accept_filename:' + filename)
return True
return ext in ('.C', '.c', '.H', '.h', '.cc',
'.cpp', '.cxx', '.c++', '.hpp', '.tpp', '.t++')


def removeLargeFiles(path):
for g in glob.glob(path + '*'):
if g == '.' or g == '..':
Expand All @@ -129,8 +137,7 @@ def removeLargeFiles(path):
os.remove(g)

# remove non-source files
elif g[-2:] not in {'.C', '.c', '.H', '.h'} and g[-3:] != '.cc' and\
g[-4:] not in {'.cpp', '.cxx', '.c++', '.hpp', '.tpp', '.t++'}:
elif not accept_filename(g):
os.remove(g)


Expand All @@ -145,13 +152,13 @@ def downloadpackage(filepath, outpath):
filename = filepath[filepath.rfind('/') + 1:]
if filename[-3:] == '.gz':
# TODO: handle exitcode?
subprocess.call(['tar', 'xzvf', filename])
subprocess.call(['tar', 'xzf', filename])
elif filename[-3:] == '.xz':
# TODO: handle exitcode?
subprocess.call(['tar', 'xJvf', filename])
subprocess.call(['tar', 'xJf', filename])
elif filename[-4:] == '.bz2':
# TODO: handle exitcode?
subprocess.call(['tar', 'xjvf', filename])
subprocess.call(['tar', 'xjf', filename])
else:
return

Expand All @@ -160,7 +167,7 @@ def downloadpackage(filepath, outpath):
for g in glob.glob('[#_A-Za-z0-9]*'):
if os.path.isdir(g):
# TODO: handle exitcode?
subprocess.call(['tar', '-cJvf', outpath + filename[:filename.rfind('.')] + '.xz', g])
subprocess.call(['tar', '-cJf', outpath + filename[:filename.rfind('.')] + '.xz', g])
break

workdir = os.path.expanduser('~/daca2-packages/tmp/')
Expand Down