Exemplo n.º 1
0
def check_for_update(package, version):
    try:
        checker = UpdateChecker()
        result = checker.check(package, version)
        return result.available_version
    except:  # nosec
        return None
Exemplo n.º 2
0
    def version():
        """ Function that returns the version number of different components: classifier and ontology
        """
        config = Config()
        print_header("CLASSIFIER")
        print("CSO Classifier version {}".format(
            config.get_classifier_version()))

        # This section identifies the last version of the CSO Classifier on pipy.

        running_version = config.get_classifier_version()

        checker = UpdateChecker()
        result = checker.check(
            'cso-classifier',
            '2.0')  #checking if there are versions of the package above 2.0
        latest_version = result.available_version

        if latest_version > running_version:
            print(
                "A more recent version ({}) of the CSO Classifier is available."
                .format(latest_version))
            print(
                "You can update this package by running 'pip install cso-classifier -U' or follow the instructions on https://github.com/angelosalatino/cso-classifier"
            )
        elif latest_version == config.get_classifier_version():
            print(
                "The version of the CSO Classifier you are using is already up to date."
            )
        elif latest_version < config.get_classifier_version():
            print(
                "The latest available package is version {} and you are using version {}. There is an error in your configuration file."
                .format(latest_version, config.get_classifier_version()))

        cso = CSO(load_ontology=False)
        cso.version()
Exemplo n.º 3
0
    def __init__(self, config):
        """Initialize an instance of Farcy that monitors owner/repository."""
        # Configure logging
        self.config = config
        self.log = logging.getLogger(__name__)
        self.log.setLevel(config.log_level_int)

        # Prepare logging
        handler = logging.StreamHandler()
        handler.setFormatter(logging.Formatter(
            '%(asctime)s %(levelname)8s %(message)s', '%Y/%m/%d %H:%M:%S'))
        self.log.addHandler(handler)
        self.log.info('Logging enabled at level {0}'.format(config.log_level))

        if config.start_event:
            self.start_time = None
            self.last_event_id = int(config.start_event) - 1
        else:
            self.start_time = datetime.now(UTC())
            self.last_event_id = None

        self._load_handlers()

        # Initialize the repository to monitor
        self.repo = config.session.repository(
            *self.config.repository.split('/'))
        if self.repo is None:
            raise FarcyException('Invalid owner or repository name: {0}'
                                 .format(self.config.repository))
        # Keep track of open pull requests
        self.open_prs = {}
        for pr in self.repo.pull_requests(state='open'):
            self.open_prs[pr.head.ref] = pr

        # Check for farcy package updates
        if not self._update_checked:
            result = UpdateChecker().check(__name__, __version__)
            if result:
                self.log.info(result)
            self._update_checked = True

        self.running = False
Exemplo n.º 4
0
 def test_bad_package(self):
     checker = UpdateChecker()
     self.assertFalse(checker.check('update_checker_slkdflj', '0.0.1'))
Exemplo n.º 5
0
from .config import pg, username, hints
from .posterino import submitRound
from .hosterino import checkAnswers, checkHints
from .Utils.utils import waitForApproval, approved, postDelay, randomColor
from .Loader.loader import getRound
from sty import fg
from importlib.metadata import version
from update_checker import UpdateChecker
from threading import Thread
import time

v = version('botterino')
checker = UpdateChecker()
result = checker.check('botterino', v)
if result:
    print(f'{fg.yellow}{result}')
    print(f'{fg.yellow}run "pip install --upgrade botterino" to update')


def checkType(r):
    types = []
    if 'tolerance' in r and 'answer' in r:
        types.append('coordinates')
    if 'tolerances' in r and 'answers' in r:
        types.append('multiple coordinates')
    if 'text' in r and 'similarity' in r:
        types.append('text match')
    if 'manual' in r:
        types.append('x wrong guesses with manual correct')
    if not types:
        return 'no automatic replies'
Exemplo n.º 6
0
 def test_checker_check__successful(self):
     checker = UpdateChecker()
     checker.bypass_cache = True
     result = checker.check(self.TRACKED_PACKAGE, '1.0.0')
     self.assertTrue(result is not None)
Exemplo n.º 7
0
 def test_checker_check__update_to_rc_version_from_beta_version(self):
     checker = UpdateChecker()
     checker.bypass_cache = True
     self.assertTrue(checker.check(self.TRACKED_PACKAGE, '4.0.0b4'))
Exemplo n.º 8
0
 def test_checker_check__no_update_to_beta_version(self):
     checker = UpdateChecker()
     checker.bypass_cache = True
     self.assertFalse(checker.check(self.TRACKED_PACKAGE, '3.6'))
Exemplo n.º 9
0
__name__ = "pysimplesql"
__version__ = "develop"
__keywords__ = [
    "SQL", "sqlite", "sqlite3", "database", "front-end", "access",
    "libre office", "GUI", "PySimpleGUI"
]
__author__ = "Jonathan Decker"
__author_email__ = "*****@*****.**"
__url__ = "https://github.com/PySimpleSQL/pysimplesql"
__platforms__ = "ALL"
__classifiers__ = [
    "Programming Language :: Python",
    "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
    "Topic :: Database :: Front-Ends",
    "Operating System :: OS Independent",
]
__requires__ = ['PySimpleGUI', 'update_checker']
__extra_requires__ = {}

# -------------------------
# Check for package updates
# -------------------------
checker = UpdateChecker()
result = checker.check('pysimplesql', __version__)
if result is not None:
    release_date = f'(released {result.release_date}) ' if result.release_date is not None else ''
    print(
        f'***** pysimplesql update from {__version__} to {result.available_version} {release_date} available! Be sure to run pip3 install pysimplesql --upgrade *****'
    )
Exemplo n.º 10
0
def run():
    # Get supplied command line arguments
    commandArgs = args()

    if commandArgs.terminal_mode:
        height, width = os.popen('stty size', 'r').read().split()
        termMatrix = TermMatrix()
        termMatrix.width = int(width)
        termMatrix.height = int(height)
        matrix = Matrix(termMatrix)
    else:
        # Check for led configuration arguments
        matrixOptions = led_matrix_options(commandArgs)
        matrixOptions.drop_privileges = False

        # Initialize the matrix
        matrix = Matrix(RGBMatrix(options = matrixOptions))

    # Print some basic info on startup
    debug.info("{} - v{} ({}x{})".format(SCRIPT_NAME, SCRIPT_VERSION, matrix.width, matrix.height))

    # Read scoreboard options from config.json if it exists
    config = ScoreboardConfig("config", commandArgs, (matrix.width, matrix.height))

    debug.set_debug_status(config)

    data = Data(config)

    # Event used to sleep when rendering
    # Allows Web API (coming in V2) and pushbutton to cancel the sleep
    # Will also allow for weather alert to interrupt display board if you want
    sleepEvent = threading.Event()

    if data.config.dimmer_enabled:
        dimmer = Dimmer(data, matrix)
        dimmerThread = threading.Thread(target=dimmer.run, args=())
        dimmerThread.daemon = True
        dimmerThread.start()

    if data.config.pushbutton_enabled:
        pushbutton = PushButton(data,matrix,sleepEvent)
        pushbuttonThread = threading.Thread(target=pushbutton.run, args=())
        pushbuttonThread.daemon = True
        pushbuttonThread.start()
    
    if data.config.weather_enabled:
        if data.config.weather_data_feed.lower() == "owm":
            owmweather = owmWxWorker(data,sleepEvent)
            owmweatherThread = threading.Thread(target=owmweather.run,args=())
            owmweatherThread.daemon = True
            owmweatherThread.start()
        elif data.config.weather_data_feed.lower() == "ec":
            ecweather = ecWxWorker(data,sleepEvent)
            ecweatherThread = threading.Thread(target=ecweather.run,args=())
            ecweatherThread.daemon = True
            ecweatherThread.start()
        else:
            debug.error("No valid weather providers selected, skipping weather feed")
            data.config.weather_enabled = False

    if data.config.weather_show_alerts and data.config.weather_enabled:
        if data.config.weather_alert_feed.lower() == "ec":
            ecalert = ecWxAlerts(data,sleepEvent)
            ecalertThread = threading.Thread(target=ecalert.run,args=())
            ecalertThread.daemon = True
            ecalertThread.start()
        elif data.config.weather_alert_feed.lower() == "nws":
            nwsalert = nwsWxAlerts(data,sleepEvent)
            nwsalertThread = threading.Thread(target=nwsalert.run,args=())
            nwsalertThread.daemon = True
            nwsalertThread.start()
        else:
            debug.error("No valid weather alerts providers selected, skipping alerts feed")
            data.config.weather_show_alerts = False
    
    #
    # Run check for updates against github on a background thread on a scheduler
    #     
    updateCheck= True
    if updateCheck:
        scheduler = BackgroundScheduler()
        checkupdate = UpdateChecker(data,scheduler)
        scheduler.start()

    MainRenderer(matrix, data, sleepEvent).render()
Exemplo n.º 11
0
def test_checker_check__unsuccessful(mock_get):
    mock_get.side_effect = requests.exceptions.RequestException
    checker = UpdateChecker(bypass_cache=True)
    assert checker.check(PACKAGE, "1.0.0") is None
Exemplo n.º 12
0
def test_checker_check__successful(mock_get):
    mock_response(mock_get.return_value)
    checker = UpdateChecker(bypass_cache=True)
    result = checker.check(PACKAGE, "1.0.0")
    assert result.available_version == "5.0.0"
Exemplo n.º 13
0
def test_checker_check__update_to_rc_version_from_beta_version(mock_get):
    mock_response(mock_get.return_value, "4.0.0rc1")
    checker = UpdateChecker(bypass_cache=True)
    result = checker.check(PACKAGE, "4.0.0b4")
    assert result.available_version == "4.0.0rc1"
Exemplo n.º 14
0
def test_checker_check__no_update_to_beta_version(mock_get):
    mock_response(mock_get.return_value, "3.7.0b1")
    checker = UpdateChecker(bypass_cache=True)
    assert checker.check(PACKAGE, "3.6") is None
Exemplo n.º 15
0
 def test_check_check__untracked_package(self):
     checker = UpdateChecker()
     checker.bypass_cache = True
     self.assertEqual("update_checker does not support 'requests'",
                      checker.check(self.UNTRACKED_PACKAGE, '0.0.1'))
Exemplo n.º 16
0
 def test_bad_url(self):
     checker = UpdateChecker('http://sdlkjsldfkjsdlkfj.com')
     self.assertFalse(checker.check('praw', '0.0.1'))
Exemplo n.º 17
0
 def test_successful(self):
     checker = UpdateChecker()
     result = checker.check('update_checker', '0.0.1')
     self.assertTrue(result is not None)
Exemplo n.º 18
0
 def test_check_check__bad_package(self):
     checker = UpdateChecker()
     checker.bypass_cache = True
     self.assertFalse(checker.check(self.UNTRACKED_PACKAGE, '0.0.1'))
Exemplo n.º 19
0
def run():
    # Kill the splash screen if active
    stop_splash_service()

    # Get supplied command line arguments
    commandArgs = args()

    if commandArgs.terminal_mode and sys.stdin.isatty():
        height, width = os.popen('stty size', 'r').read().split()
        termMatrix = TermMatrix()
        termMatrix.width = int(width)
        termMatrix.height = int(height)
        matrix = Matrix(termMatrix)
    else:
        # Check for led configuration arguments
        matrixOptions = led_matrix_options(commandArgs)
        matrixOptions.drop_privileges = False

        # Initialize the matrix
        matrix = Matrix(RGBMatrix(options = matrixOptions))

     #Riff to add loading screen here
    loading = Loading(matrix)
    loading.render()

    # Read scoreboard options from config.json if it exists
    config = ScoreboardConfig("config", commandArgs, (matrix.width, matrix.height))

    data = Data(config)

    #If we pass the logging arguments on command line, override what's in the config.json, else use what's in config.json (color will always be false in config.json)
    if commandArgs.logcolor and commandArgs.loglevel != None:
        debug.set_debug_status(config,logcolor=commandArgs.logcolor,loglevel=commandArgs.loglevel)
    elif not commandArgs.logcolor and commandArgs.loglevel != None:
        debug.set_debug_status(config,loglevel=commandArgs.loglevel)
    elif commandArgs.logcolor and commandArgs.loglevel == None:
        debug.set_debug_status(config,logcolor=commandArgs.logcolor,loglevel=config.loglevel)
    else:
        debug.set_debug_status(config,loglevel=config.loglevel)

    # Print some basic info on startup
    debug.info("{} - v{} ({}x{})".format(SCRIPT_NAME, SCRIPT_VERSION, matrix.width, matrix.height))
    
    if data.latlng is not None:
        debug.info(data.latlng_msg)
    else:
        debug.error("Unable to find your location.")

    # Event used to sleep when rendering
    # Allows Web API (coming in V2) and pushbutton to cancel the sleep
    # Will also allow for weather alert to interrupt display board if you want
    sleepEvent = threading.Event()


    # Start task scheduler, used for UpdateChecker and screensaver, forecast, dimmer and weather
    scheduler = BackgroundScheduler()
    scheduler.start()

    # Any tasks that are scheduled go below this line

    # Make sure we have a valid location for the data.latlng as the geocode can return a None
    # If there is no valid location, skip the weather boards
    
    #Create EC data feed handler
    if data.config.weather_enabled or data.config.wxalert_show_alerts:
        if data.config.weather_data_feed.lower() == "ec" or data.config.wxalert_alert_feed.lower() == "ec":
            try:
                data.ecData = ECData(coordinates=(data.latlng))
            except Exception as e:
                debug.error("Unable to connect to EC, try running again in a few minutes")
                sys.exit(0)

    if data.config.weather_enabled:
        if data.config.weather_data_feed.lower() == "ec":
            ecWxWorker(data,scheduler)
        elif data.config.weather_data_feed.lower() == "owm":
            owmweather = owmWxWorker(data,scheduler)
        else:
            debug.error("No valid weather providers selected, skipping weather feed")
            data.config.weather_enabled = False


    if data.config.wxalert_show_alerts:
        if data.config.wxalert_alert_feed.lower() == "ec":
            ecalert = ecWxAlerts(data,scheduler,sleepEvent)
        elif data.config.wxalert_alert_feed.lower() == "nws":
            nwsalert = nwsWxAlerts(data,scheduler,sleepEvent)
        else:
            debug.error("No valid weather alerts providers selected, skipping alerts feed")
            data.config.weather_show_alerts = False

    if data.config.weather_forecast_enabled and data.config.weather_enabled:
        wxForecast(data,scheduler)
    #
    # Run check for updates against github on a background thread on a scheduler
    #
    if commandArgs.updatecheck:
        data.UpdateRepo = commandArgs.updaterepo
        checkupdate = UpdateChecker(data,scheduler,commandArgs.ghtoken)

    if data.config.dimmer_enabled:
        dimmer = Dimmer(data, matrix,scheduler)

    screensaver = None
    if data.config.screensaver_enabled:
        screensaver = screenSaver(data, matrix, sleepEvent, scheduler)
        if data.config.screensaver_motionsensor:
            motionsensor = Motion(data,matrix,sleepEvent,scheduler,screensaver)
            motionsensorThread = threading.Thread(target=motionsensor.run, args=())
            motionsensorThread.daemon = True
            motionsensorThread.start()

    if data.config.pushbutton_enabled:
        pushbutton = PushButton(data,matrix,sleepEvent)
        pushbuttonThread = threading.Thread(target=pushbutton.run, args=())
        pushbuttonThread.daemon = True
        pushbuttonThread.start()
    

    MainRenderer(matrix, data, sleepEvent).render()
Exemplo n.º 20
0
 def test_checker_check__bad_url(self):
     checker = UpdateChecker('http://sdlkjsldfkjsdlkfj.com')
     checker.bypass_cache = True
     self.assertFalse(checker.check(self.TRACKED_PACKAGE, '0.0.1'))