Compare commits
	
		
			2 Commits
		
	
	
		
			1beda9d613
			...
			a540f4336f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a540f4336f | |||
| 643f41d7f7 | 
							
								
								
									
										22
									
								
								backup.py
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								backup.py
									
									
									
									
									
								
							| @@ -29,12 +29,12 @@ def format_size(n: int) -> str: | |||||||
|     return humanfriendly.format_size(n, keep_width=True, binary=True) |     return humanfriendly.format_size(n, keep_width=True, binary=True) | ||||||
|  |  | ||||||
| class Config: | class Config: | ||||||
|     roots: list[bytes] |     roots: typing.List[bytes] | ||||||
|     max_file_size: typing.Optional[int] |     max_file_size: typing.Optional[int] | ||||||
|     one_file_system: bool |     one_file_system: bool | ||||||
|     exclude_caches: bool |     exclude_caches: bool | ||||||
|     exclude: list[bytes] |     exclude: typing.List[bytes] | ||||||
|     force_include: list[bytes] |     force_include: typing.List[bytes] | ||||||
|     notify_email: typing.Optional[str] |     notify_email: typing.Optional[str] | ||||||
|  |  | ||||||
|     def __init__(self, configfile: str): |     def __init__(self, configfile: str): | ||||||
| @@ -93,8 +93,10 @@ class Config: | |||||||
|         self.force_include_re = ([ re.compile(x) for x in a ], |         self.force_include_re = ([ re.compile(x) for x in a ], | ||||||
|                                  [ re.compile(x) for x in b ]) |                                  [ re.compile(x) for x in b ]) | ||||||
|  |  | ||||||
|     def match_re(self, re: tuple[list[typing.Pattern], |     def match_re(self, | ||||||
|                                  list[typing.Pattern]], path: bytes): |                  re: typing.Tuple[typing.List[typing.Pattern], | ||||||
|  |                                   typing.List[typing.Pattern]], | ||||||
|  |                  path: bytes): | ||||||
|         # Path matches if it matches at least one regex in |         # Path matches if it matches at least one regex in | ||||||
|         # re[0] and no regex in re[1]. |         # re[0] and no regex in re[1]. | ||||||
|         for a in re[0]: |         for a in re[0]: | ||||||
| @@ -109,10 +111,10 @@ class Backup: | |||||||
|     def __init__(self, config: Config, dry_run: bool): |     def __init__(self, config: Config, dry_run: bool): | ||||||
|         self.config = config |         self.config = config | ||||||
|         self.dry_run = dry_run |         self.dry_run = dry_run | ||||||
|         self.root_seen: dict[bytes, bool] = {} |         self.root_seen: typing.Dict[bytes, bool] = {} | ||||||
|  |  | ||||||
|         # Saved log messages |         # Saved log messages | ||||||
|         self.logs: list[tuple[str, str]] = [] |         self.logs: typing.List[typing.Tuple[str, str]] = [] | ||||||
|  |  | ||||||
|     def out(self, path: bytes): |     def out(self, path: bytes): | ||||||
|         self.outfile.write(path + (b'\n' if self.dry_run else b'\0')) |         self.outfile.write(path + (b'\n' if self.dry_run else b'\0')) | ||||||
| @@ -227,7 +229,7 @@ class Backup: | |||||||
|             self.log('E', f"can't read {pstr(path)}: {str(e)}") |             self.log('E', f"can't read {pstr(path)}: {str(e)}") | ||||||
|             return |             return | ||||||
|  |  | ||||||
| def main(argv: list[str]): | def main(argv: typing.List[str]): | ||||||
|     import argparse |     import argparse | ||||||
|  |  | ||||||
|     def humansize(string): |     def humansize(string): | ||||||
| @@ -275,7 +277,7 @@ def main(argv: list[str]): | |||||||
|         backup.log('W', f"failed to parse variables from {args.vars}: {str(e)}") |         backup.log('W', f"failed to parse variables from {args.vars}: {str(e)}") | ||||||
|  |  | ||||||
|     # Run backup |     # Run backup | ||||||
|     captured_output: list[bytes] = [] |     captured_output: typing.List[bytes] = [] | ||||||
|  |  | ||||||
|     if args.dry_run: |     if args.dry_run: | ||||||
|         if args.debug: |         if args.debug: | ||||||
| @@ -309,6 +311,8 @@ def main(argv: list[str]): | |||||||
|  |  | ||||||
|         # Use a thread to capture output |         # Use a thread to capture output | ||||||
|         def reader_thread(fh): |         def reader_thread(fh): | ||||||
|  |             nonlocal borg_saw_warnings | ||||||
|  |             nonlocal borg_saw_errors | ||||||
|             last_progress = 0 |             last_progress = 0 | ||||||
|             for line in fh: |             for line in fh: | ||||||
|                 try: |                 try: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user