Convert borg output to log_entry class
- Remove old print code - Print using class method instead
This commit is contained in:
		
							parent
							
								
									ff8be8b90f
								
							
						
					
					
						commit
						8cb52d1150
					
				
							
								
								
									
										20
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								main.py
									
									
									
									
									
								
							|  | @ -1,6 +1,7 @@ | ||||||
| from sys import stdin | from sys import stdin | ||||||
|  | from log_entry import * | ||||||
| 
 | 
 | ||||||
| borg_output = stdin.readlines() | raw_borg_output = stdin.readlines() | ||||||
| 
 | 
 | ||||||
| attributes = {  "Archive name: " : "", | attributes = {  "Archive name: " : "", | ||||||
|                 "Archive fingerprint: " : "", |                 "Archive fingerprint: " : "", | ||||||
|  | @ -8,17 +9,18 @@ attributes = {  "Archive name: " : "", | ||||||
|                 "Duration: " : "", |                 "Duration: " : "", | ||||||
|                 "Number of files: " : "", } |                 "Number of files: " : "", } | ||||||
|                  |                  | ||||||
| for i in range(0, len(borg_output)): | for i in range(0, len(raw_borg_output)): | ||||||
|      |      | ||||||
|     for key in attributes: |     for key in attributes: | ||||||
|         if borg_output[i].startswith(key): |         if raw_borg_output[i].startswith(key): | ||||||
|             attributes[key] = borg_output[i] \ |             attributes[key] = raw_borg_output[i] \ | ||||||
|             .strip(key) \ |             .strip(key) \ | ||||||
|             .rstrip() |             .rstrip() | ||||||
| 
 | 
 | ||||||
| output = open("borg.txt", "w") | borg_output = log_entry(attributes["Archive name: "], | ||||||
|  |                         attributes["Archive fingerprint: "], | ||||||
|  |                         attributes["Time (start): "], | ||||||
|  |                         attributes["Duration: "], | ||||||
|  |                         attributes["Number of files: "]) | ||||||
| 
 | 
 | ||||||
| for key, value in attributes.iteritems(): | borg_output.print_to_file("borg.txt") | ||||||
|     output.write("%s%s\n" % (key, value)) |  | ||||||
| 
 |  | ||||||
| output.close() |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 George Lacey
						George Lacey