From 0b30e0e9dd03d93eef8bdd7040f4716124d01d14 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Mon, 3 Oct 2016 09:04:56 +0000 Subject: [PATCH] Improved owncloud quota monitor backend resiliance to connection errors --- TODO.md | 6 ------ orchestra/contrib/saas/backends/owncloud.py | 7 ++++++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index f02e8e1a..ed996aea 100644 --- a/TODO.md +++ b/TODO.md @@ -467,9 +467,3 @@ with open(file) as handler: # SAVE INISTIAL PASSWORD from all services, and just use it to create the service, never update it - - -# Eliminar tots els serveis de l'account no elimina les factures, pero crec que queda pendent arreglar el missatge summary, perque allĂ  diu que s'eliminaran N factures, xo no surten llistades a la llista d'objectes oi? - -# Make owncloud quota backend more resilient to HTTP/connection errors - diff --git a/orchestra/contrib/saas/backends/owncloud.py b/orchestra/contrib/saas/backends/owncloud.py index aaf8c616..b9544f68 100644 --- a/orchestra/contrib/saas/backends/owncloud.py +++ b/orchestra/contrib/saas/backends/owncloud.py @@ -1,6 +1,7 @@ import re import sys import textwrap +import time import xml.etree.ElementTree as ET from urllib.parse import urlparse @@ -159,7 +160,11 @@ class OwnCloudDiskQuota(OwnClouwAPIMixin, ServiceMonitor): return replace(context, "'", '"') def get_quota(self, saas, server): - user = self.get_user(saas) + try: + user = self.get_user(saas) + except requests.exceptions.ConnectionError: + time.sleep(2) + user = self.get_user(saas) context = { 'object_id': saas.pk, 'used': int(user['quota'].get('used', 0)),