Commit 07b1a950 authored by Yannik Buch's avatar Yannik Buch
Browse files

Changed behaviour when waitung for servers, added logging at certain places

parent 3fdcac8c
......@@ -9,10 +9,12 @@
import getpass
import time
import traceback
import requests
import datetime
import pytz
from bs4 import BeautifulSoup
import logging
class elog():
......@@ -213,13 +215,14 @@ class elog():
result = self._b2rc_session.get(self._b2rc_url + name, params=params)
result.raise_for_status()
success = True
except:
except Exception as e:
logging.error(traceback.format_exc())
time.sleep(10)
retries += 1
if success:
break
if retries >=10:
result.raise_for_status()
logging.warning('Elog timeout')
return result
def api_post(self, name, data, files=None):
......@@ -257,6 +260,9 @@ class elog():
def get_ref_from_html(self, html):
'''Clean html file to retrieve latest report URL.'''
if html == []:
logging.info('Elog empty or not reachable, no URL for b2rc posting')
return ''
soup = BeautifulSoup(html, "html.parser")
hrefs = soup.find_all("a", href=True)
cleaned_hrefs = []
......@@ -294,13 +300,14 @@ class elog():
result = s.get(url_str)
result.raise_for_status()
success = True
except:
except Exception as e:
logging.error(traceback.format_exc())
time.sleep(10)
retries += 1
if success:
break
if retries >=10:
result.raise_for_status()
logging.warning('B2rc posting timeout')
return result.text
def postMessage(self, msg, ch, alias=None, avatar=None, emoji=None):
......@@ -322,13 +329,14 @@ class elog():
result = self.api_post('/api/v1/chat.postMessage', data)
result.raise_for_status()
success = True
except:
except Exception as e:
logging.error(traceback.format_exc())
time.sleep(10)
retries += 1
if success:
break
if retries >=10:
result.raise_for_status()
logging.warning('B2rc posting timeout')
return result.json()
def postReport(self, url):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment