Resolves issue #5 for now
This commit is contained in:
parent
ca9ab0401d
commit
d1d1a39a30
3 changed files with 20 additions and 4 deletions
8
main.py
8
main.py
|
@ -45,9 +45,16 @@ def loadUrl(url):
|
||||||
|
|
||||||
headers = { 'User-Agent': 'Monutil monitor' }
|
headers = { 'User-Agent': 'Monutil monitor' }
|
||||||
|
|
||||||
|
@retry(stop_max_attempt_number=3)
|
||||||
|
def submitRequest(url):
|
||||||
|
|
||||||
response = requests.get(url, timeout=config.urlTimeout, headers=headers)
|
response = requests.get(url, timeout=config.urlTimeout, headers=headers)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
response = submitRequest(url)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
def prepareUrl(src, baseUrl):
|
def prepareUrl(src, baseUrl):
|
||||||
|
|
||||||
if not src.startswith("http://") and not src.startswith("https://"):
|
if not src.startswith("http://") and not src.startswith("https://"):
|
||||||
|
@ -233,6 +240,7 @@ if __name__ == "__main__":
|
||||||
import threading
|
import threading
|
||||||
import signal
|
import signal
|
||||||
import socket
|
import socket
|
||||||
|
from retrying import retry
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
13
rabbitmq.py
13
rabbitmq.py
|
@ -28,6 +28,7 @@ import base64
|
||||||
import config
|
import config
|
||||||
import log
|
import log
|
||||||
import datetime
|
import datetime
|
||||||
|
from retrying import retry
|
||||||
|
|
||||||
class rabbitMQClient:
|
class rabbitMQClient:
|
||||||
|
|
||||||
|
@ -42,6 +43,13 @@ class rabbitMQClient:
|
||||||
|
|
||||||
def publish(self, message):
|
def publish(self, message):
|
||||||
|
|
||||||
|
@retry(stop_max_attempt_number=3)
|
||||||
|
def publishMessage(conn):
|
||||||
|
|
||||||
|
ch = conn.channel()
|
||||||
|
|
||||||
|
ch.basic_publish(exchange='', routing_key=self.routingKey, body=message, properties=pika.BasicProperties(delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE))
|
||||||
|
|
||||||
message = base64.b64encode(message.encode('utf-8'))
|
message = base64.b64encode(message.encode('utf-8'))
|
||||||
|
|
||||||
context = ssl.create_default_context(
|
context = ssl.create_default_context(
|
||||||
|
@ -55,10 +63,9 @@ class rabbitMQClient:
|
||||||
|
|
||||||
with pika.BlockingConnection(connParams) as conn:
|
with pika.BlockingConnection(connParams) as conn:
|
||||||
|
|
||||||
ch = conn.channel()
|
publishMessage(conn)
|
||||||
|
|
||||||
ch.basic_publish(exchange='', routing_key=self.routingKey, body=message, properties=pika.BasicProperties(delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE))
|
|
||||||
|
|
||||||
|
@retry(stop_max_attempt_number=3)
|
||||||
def retrieve(self):
|
def retrieve(self):
|
||||||
|
|
||||||
def callback(ch, method, properties, body):
|
def callback(ch, method, properties, body):
|
||||||
|
|
|
@ -2,3 +2,4 @@ psutil
|
||||||
requests
|
requests
|
||||||
bs4
|
bs4
|
||||||
datetime
|
datetime
|
||||||
|
retrying
|
||||||
|
|
Loading…
Reference in a new issue