Handle OfflineImapError of severity REPO and CRIT
By aborting the account syncing, the looping and logging an error message. We will introduce a ui.error() rather than a ui.warn() function which saves all Exceptions in a Queue and outputs them at the end of the program. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
		 Sebastian Spaeth
					Sebastian Spaeth
				
			
				
					committed by
					
						 Nicolas Sebrecht
						Nicolas Sebrecht
					
				
			
			
				
	
			
			
			 Nicolas Sebrecht
						Nicolas Sebrecht
					
				
			
						parent
						
							0f45d89e34
						
					
				
				
					commit
					4608d14836
				
			| @@ -15,7 +15,7 @@ | |||||||
| #    along with this program; if not, write to the Free Software | #    along with this program; if not, write to the Free Software | ||||||
| #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA | #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA | ||||||
|  |  | ||||||
| from offlineimap import threadutil, mbnames, CustomConfig | from offlineimap import threadutil, mbnames, CustomConfig, OfflineImapError | ||||||
| from offlineimap.repository import Repository | from offlineimap.repository import Repository | ||||||
| from offlineimap.ui import getglobalui | from offlineimap.ui import getglobalui | ||||||
| from offlineimap.threadutil import InstanceLimitedThread | from offlineimap.threadutil import InstanceLimitedThread | ||||||
| @@ -202,21 +202,28 @@ class SyncableAccount(Account): | |||||||
|         self.localrepos  = Repository(self, 'local') |         self.localrepos  = Repository(self, 'local') | ||||||
|         self.statusrepos = Repository(self, 'status') |         self.statusrepos = Repository(self, 'status') | ||||||
|  |  | ||||||
|         # Might need changes here to ensure that one account sync does |  | ||||||
|         # not crash others... |  | ||||||
|         # Loop account synchronization if needed |         # Loop account synchronization if needed | ||||||
|         looping = 1 |         looping = True | ||||||
|         while looping: |         while looping: | ||||||
|             try: |             try: | ||||||
|                 try: |                 try: | ||||||
|                     self.sync(siglistener) |                     self.sync(siglistener) | ||||||
|                 except (KeyboardInterrupt, SystemExit): |                 except (KeyboardInterrupt, SystemExit): | ||||||
|                     raise |                     raise | ||||||
|  |                 except OfflineImapError, e:                     | ||||||
|  |                     self.ui.warn(e.reason) | ||||||
|  |                     #stop looping and bubble up Exception if needed | ||||||
|  |                     if e.severity >= OfflineImapError.ERROR.REPO: | ||||||
|  |                         looping = 0 | ||||||
|  |                         if e.severity > OfflineImapError.ERROR.REPO: | ||||||
|  |                             raise | ||||||
|                 except: |                 except: | ||||||
|                     self.ui.warn("Error occured attempting to sync account " + self.name \ |                     self.ui.warn("Error occured attempting to sync "\ | ||||||
|                                  + ": " + traceback.format_exc()) |                                  "account '%s':\n"% (self, traceback.format_exc())) | ||||||
|             finally: |             finally: | ||||||
|                 looping = self.refreshperiod and self.sleeper(siglistener) != 2 |                 looping = looping and \ | ||||||
|  |                     self.refreshperiod and \ | ||||||
|  |                     self.sleeper(siglistener) != 2 | ||||||
|                 self.ui.acctdone(self.name) |                 self.ui.acctdone(self.name) | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user