# Path: lib/sentry/sentry.py

# 
# Path: lib/clint/progress.py
# STREAM = sys.stdout
# BAR_TEMPLATE = '[\x1b[93m+\x1b[0m] %s [%s%s] [%3.2f%%] - %s\r'
# BAR_FILLED_CHAR = '\033[01m#\033[0m'
# BAR_EMPTY_CHAR = ' '
# ETA_INTERVAL = 1
# ETA_SMA_WINDOW = 9
# class Bar(object):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def __init__(self, label='', width=32, hide=None, empty_char=BAR_EMPTY_CHAR,
#                  filled_char=BAR_FILLED_CHAR, expected_size=None, every=1):
#     def show(self, progress, count=None):
#     def done(self):
#     def format_time(self, seconds):
# def bar(it, label='', width=32, hide=None, empty_char=BAR_EMPTY_CHAR,
#         filled_char=BAR_FILLED_CHAR, expected_size=None, every=1):


import os
import shutil
import os.path
import tarfile
import requests
from sys import exit
from bs4 import BeautifulSoup
from ...base import *
from ...sentry import sentry
from ...clint import progress
'''
Module that update the software and its databases
'''



class Updater(object):
    def __init__(self, path, ver, url):
        self.inst_path = path
        self.repo_url = url
        self.version = ver

    def update_all(self):
        '''
        Upgrade BigBrother completely
        '''
        print(color.info.info("Fetching version from Github..."))
        # Retrieving github releases
        try:
            response = requests.get(self.repo_url)
        except requests.exceptions.RequestException as e:
            print(color.info.error(e))
            return
        # Getting latest release
        soup = BeautifulSoup(response.content, 'html.parser')
        try:    # Parsing info from page
            version = soup.select("ul.tag-references > li > a > span")[0].text
            download_url = "https://github.com" + \
                soup.select(".release-downloads > li > a")[1]['href']
        except Exception as e:

# Path: lib/sentry/sentry.py

# 
# Path: lib/clint/progress.py
# STREAM = sys.stdout
# BAR_TEMPLATE = '[\x1b[93m+\x1b[0m] %s [%s%s] [%3.2f%%] - %s\r'
# BAR_FILLED_CHAR = '\033[01m#\033[0m'
# BAR_EMPTY_CHAR = ' '
# ETA_INTERVAL = 1
# ETA_SMA_WINDOW = 9
# class Bar(object):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def __init__(self, label='', width=32, hide=None, empty_char=BAR_EMPTY_CHAR,
#                  filled_char=BAR_FILLED_CHAR, expected_size=None, every=1):
#     def show(self, progress, count=None):
#     def done(self):
#     def format_time(self, seconds):
# def bar(it, label='', width=32, hide=None, empty_char=BAR_EMPTY_CHAR,
#         filled_char=BAR_FILLED_CHAR, expected_size=None, every=1):


# Path: lib/bbro/core/update.py
import os
import shutil
import os.path
import tarfile
import requests
from sys import exit
from bs4 import BeautifulSoup
from ...base import *
from ...sentry import sentry
from ...clint import progress

'''
Module that update the software and its databases
'''



class Updater(object):
    def __init__(self, path, ver, url):
        self.inst_path = path
        self.repo_url = url
        self.version = ver

    def update_all(self):
        '''
        Upgrade BigBrother completely
        '''
        print(color.info.info("Fetching version from Github..."))
        # Retrieving github releases
        try:
            response = requests.get(self.repo_url)
        except requests.exceptions.RequestException as e:
            print(color.info.error(e))
            return
        # Getting latest release
        soup = BeautifulSoup(response.content, 'html.parser')
        try:    # Parsing info from page
            version = soup.select("ul.tag-references > li > a > span")[0].text
            download_url = "https://github.com" + \
                soup.select(".release-downloads > li > a")[1]['href']
        except Exception as e:

            sentry.client.captureException()