Skip to content

Instantly share code, notes, and snippets.

@donno
Created April 12, 2020 04:01
Show Gist options
  • Save donno/45748342cad2abbfca6088c7807e6047 to your computer and use it in GitHub Desktop.
Save donno/45748342cad2abbfca6088c7807e6047 to your computer and use it in GitHub Desktop.
Parses the entwine output to determine which files weren't completed.
"""Parses the entwine output to determine which files weren't completed at
the time of a crash.
There are two lines from the output that this script is interested in. The
lines with 'Adding' and 'Done'.
Output Example:
Adding 0 - E:/data/Volcano/LAZ/E262N1546_LAZ_PL1.laz
Adding 1 - E:/data/Volcano/LAZ/E262N1547_LAZ_PL1.laz
Adding 2 - E:/data/Volcano/LAZ/E262N1548_LAZ_PL1.laz
Adding 3 - E:/data/Volcano/LAZ/E262N1549_LAZ_PL1.laz
Adding 4 - E:/data/Volcano/LAZ/E262N1550_LAZ_PL1.laz
Done 1
Adding 5 - E:/data/Volcano/LAZ/E262N1551_LAZ_PL1.laz
Done 2
Adding 6 - E:/data/Volcano/LAZ/E263N1543_LAZ_PL1.laz
00:10 - 0% - 14,399,664 - 5,183(5,183)M/h - 90W - 0R - 287A
Done 0
"""
def read(filepath):
"""Read the output from 'entwine build' to determine what files were
started for processing and which are complete."""
started = []
done = []
started_prefix = 'Adding '
with open(filepath) as reader:
for line in reader:
if line.startswith(started_prefix):
number, _, path = line[len(started_prefix):].partition(' - ')
started.append((int(number), path.strip()))
elif 'Done ' in line:
_, _, result = line.partition('Done ')
done.append(int(result.strip()))
return started, done
def incomplete(started, done):
"""Return items from started that were never done."""
done = set(done)
for number, path in started:
if number not in done:
yield path
if __name__ == '__main__':
started, done = read('output.txt')
remaining = incomplete(started, done)
print('Items still to do:')
print('\n'.join(remaining))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment