| 102 logging.debug('Log listener thread waiting for entries') |
110 logging.debug('Log listener thread waiting for entries') |
| 103 success=True |
111 success=True |
| 104 for status in iter(self.borg_instance.read_log, None): |
112 for status in iter(self.borg_instance.read_log, None): |
| 105 logging.debug(str(status)) |
113 logging.debug(str(status)) |
| 106 t=status['type'] |
114 t=status['type'] |
| 107 #may_indicate_finished=False |
115 |
| |
116 errors_this_message=False |
| |
117 callback=None |
| |
118 |
| 108 if t=='progress_percent': |
119 if t=='progress_percent': |
| 109 if 'current' in status and 'total' in status: |
120 current=safe_get_int(status, 'current') |
| |
121 total=safe_get_int(status, 'total') |
| |
122 if current is not None and total is not None: |
| 110 with self.lock: |
123 with self.lock: |
| 111 self.current_operation.progress_current=status['current'] |
124 self.current_operation.progress_current=current |
| 112 self.current_operation.progress_total=status['total'] |
125 self.current_operation.progress_total=total |
| 113 status, callback=self.__status_unlocked() |
126 status, callback=self.__status_unlocked() |
| 114 if callback: |
127 |
| 115 callback(self, status) |
|
| 116 elif t=='archive_progress': |
128 elif t=='archive_progress': |
| |
129 original_size=safe_get_int(status, 'original_size') |
| |
130 compressed_size=safe_get_int(status, 'compressed_size') |
| |
131 deduplicated_size=safe_get_int(status, 'deduplicated_size') |
| |
132 if original_size is not None and original_size is not None and deduplicated_size is not None: |
| |
133 with self.lock: |
| |
134 self.current_operation.original_size=original_size |
| |
135 self.current_operation.compressed_size=compressed_size |
| |
136 self.current_operation.deduplicated_size=deduplicated_size |
| |
137 status, callback=self.__status_unlocked() |
| |
138 |
| |
139 elif t=='progress_message': |
| 117 pass |
140 pass |
| 118 elif t=='progress_message': |
141 |
| 119 #may_indicate_finished=True |
|
| 120 pass |
|
| 121 elif t=='file_status': |
142 elif t=='file_status': |
| 122 pass |
143 pass |
| |
144 |
| 123 elif t=='log_message': |
145 elif t=='log_message': |
| 124 if 'levelname' not in status: |
146 if 'levelname' not in status: |
| 125 status['levelname']='ERROR' |
147 status['levelname']='ERROR' |
| 126 if 'message' not in status: |
148 if 'message' not in status: |
| 127 status['message']='UNKNOWN' |
149 status['message']='UNKNOWN' |
| 128 if 'name' not in status: |
150 if 'name' not in status: |
| 129 status['name']='borg' |
151 status['name']='borg' |
| 130 logging.log(translate_loglevel(status['levelname']), |
152 lvl=translate_loglevel(status['levelname']) |
| 131 status['name'] + ': ' + status['message']) |
153 logging.log(lvl, status['name'] + ': ' + status['message']) |
| 132 # set success=False? |
154 if lvl>=logging.WARNING: |
| |
155 errors_this_message=True |
| 133 elif t=='exception': |
156 elif t=='exception': |
| 134 success=False |
157 errors_this_message=True |
| 135 elif t=='unparsed_error': |
158 elif t=='unparsed_error': |
| 136 success=False |
159 errors_this_message=True |
| |
160 |
| |
161 if errors_this_message: |
| |
162 with self.lock: |
| |
163 self.current_operation.errors=True |
| |
164 status, callback=self.__status_unlocked() |
| |
165 |
| |
166 if callback: |
| |
167 callback(self, status) |
| 137 |
168 |
| 138 logging.debug('Waiting for borg subprocess to terminate in log thread') |
169 logging.debug('Waiting for borg subprocess to terminate in log thread') |
| 139 |
170 |
| 140 self.borg_instance.wait() |
171 self.borg_instance.wait() |
| 141 |
172 |