From d6a008052a304d660ecaaf3605341a06e3657c08 Mon Sep 17 00:00:00 2001 From: George Lacey Date: Mon, 19 Sep 2016 23:00:20 +0100 Subject: [PATCH] Grab borg output - Loops through each line of output and adds to a dictionary containing list of log attributes. - Currently outputs to file for debugging. --- main.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..9c4873c --- /dev/null +++ b/main.py @@ -0,0 +1,26 @@ +from sys import stdin + +borg_output = stdin.readlines() + +attributes = { "Archive name: " : "", + "Archive fingerprint: " : "", + "Time (start): " : "", + "Duration: " : "", + "Number of files: " : "", } + +#archive_name, archive_fingerprint, time_start, duration, file_count + +for i in range(0, len(borg_output)): + + for key in attributes: + if borg_output[i].startswith(key): + attributes[key] = borg_output[i] \ + .strip(key) \ + .strip("\n") + +output = open("borg.txt", "w") + +for key, value in attributes.iteritems(): + output.write("%s%s\n" % (key, value)) + +output.close()