Ejemplo n.º 1
0
def CheckForUpdates():
    """
    Check for updates.
    Channel options are stable, beta & alpha
    Patches are only created & applied on the stable channel
    """
    CLIENT_CFG = ClientConfig()

    # refresh to get the online manifest for version checking
    client = Client(ClientConfig(), refresh=True)

    #logger.info('Checkung for updates')
    appUpdate = client.update_check(CLIENT_CFG.APP_NAME,
                                    app.__version__,
                                    channel='stable')  # alpha, beta
    if appUpdate:
        if hasattr(sys, "frozen"):
            downloaded = appUpdate.download()
            if downloaded:
                status = 'Extracting update and restarting.'
                appUpdate.extract_restart()
            else:
                status = 'Update download failed.'
        else:
            status = 'Update available but application is not frozen.'
    else:
        status = 'No available updates were found.'

    return status
Ejemplo n.º 2
0
def update():
    logger = logging.getLogger(__name__)
    if not is_frozen_app():
    #if False:
        logger.info('App not frozen, app update ignored.')
    else:
        #d = show_progress_window()
        # app=wx.GetApp()
        # d=wx.ProgressDialog('Updating Analytics Assist', 'Checking for updates, the application will restart automatically.')
        # d.Show()
        logger = logging.getLogger(__name__)
        client_config = ClientConfig()
        client = Client(client_config)
        client.refresh()

        client.add_progress_hook(lambda x: update_progress(x, d))
        app_update = client.update_check(client_config.APP_NAME, __version__)

        if app_update is not None:
            logger.info(
                f'There is an update for the app, current version: {__version__}, new version: {app_update.version}')
            app_update.download()
            if app_update.is_downloaded():
                logger.info('Extracting and restarting')
                app_update.extract_restart()
                #d.Destroy()
        else:
            logger.info(
                f'App is up to date, current version: {__version__}')
Ejemplo n.º 3
0
def is_update_avail():
    client = Client(ClientConfig(),
                    refresh=True,
                    progress_hooks=[print_status_info])

    app_update = client.update_check(APP_NAME, APP_VERSION)
    return app_update
Ejemplo n.º 4
0
    def __init__(self):
        """Constructor."""
        # Do singleton checking.
        if Scavenger.INSTANCE != None:
            raise SingletonException('A Scavenger instance already exists.')

        # Initialize the object.
        super(Scavenger, self).__init__()

        # Create a context monitor.
        self._monitor = ContextMonitor()

        # Create the schedulers.
        self._schedulers = {}
        self._schedulers['basic'] = BasicScheduler(self._monitor._context, Scavenger)
        self._schedulers['dc'] = DCScheduler(self._monitor._context, Scavenger)
        self._schedulers['gprofile'] = GlobalProfilingScheduler(self._monitor._context, Scavenger)
        self._schedulers['lprofile'] = LocalProfilingScheduler(self._monitor._context, Scavenger)
        self._schedulers['cprofile'] = CombinedProfilingScheduler(self._monitor._context, Scavenger)
        self._schedulers['batch'] = BatchScheduler(self._monitor._context, Scavenger)
        self._schedulers['aprofile'] = AdaptiveProfScheduler(self._monitor._context, Scavenger)
        self._schedulers['mprofile'] = MultiFacetedScheduler(self._monitor._context, Scavenger)

        # Load in the config.
        self._config = ClientConfig.get_instance()

        # Set the local activity count.
        self._activity = LocalActivity()
        
        # Assign the instance pointer.
        Scavenger.INSTANCE = self
Ejemplo n.º 5
0
    def OnBtnClick(self, evt):
        ccf = ClientConfig(timeout=self.ctrls[0].GetValue(),
                           max_download_num=int(self.ctrls[1].GetValue()),
                           max_connect_num=int(self.ctrls[2].GetValue()),
                           port=(self.ctrls[3].GetValue()))

        save_config(ccf)
        self.Close()
Ejemplo n.º 6
0
    def __init__(self, settings):
        self.APP_NAME = 'BHBot'
        self.APP_VERSION = '3.5.1'
        self.APP_CHANGELOGS = {
            'English': [
                f'Updated to {self.APP_VERSION} \\o/',
                'If it\'s your first time using the bot or seeing this message, please click "Instructions" and read them carefully',
                '- Bot is no longer maintained',
            ],
            'Русский': [
                f'Обновился до {self.APP_VERSION} \\o/',
                'Если вы используете бота или видите это сообщение впервые, пожалуйста, нажмите на "Инструкции" и тщательно их прочтите',
                '- Бот больше не поддерживается',
            ]
        }

        self.compiled = getattr(sys, 'frozen', False)

        self.load_installation_info()
        self.clear_old_logs()
        self.add_file_handlers()
        self.load_fonts()

        pyupdater_client = Client(ClientConfig(),
                                  refresh=True,
                                  progress_hooks=[self.print_update_status])

        self.branch = settings.get('branch', 'stable')

        self.new_version = pyupdater_client.update_check(
            self.APP_NAME,
            self.APP_VERSION,
            channel=self.branch,
            strict=self.branch != 'beta')

        self.languages = self.get_languages()
        if not self.languages:
            logger.error(
                'No languages found. Program will not function with empty languages directory.'
            )
        self.language_name = settings.get('language_name', 'English')

        self.APP_CHANGELOG = self.APP_CHANGELOGS.get(
            self.language_name, self.APP_CHANGELOGS.get('English'))

        self.fonts = self.get_fonts()
        self.font = settings.get('font', 'Cousine Regular')

        self.autostart = settings.get('autostart', False)

        self.icon = self.installation_folder / 'icon.ico'

        self.debug = settings.get('debug', False)
        self.gui_handler = None
        self.loaded_modes = {}
Ejemplo n.º 7
0
    def __init__(self):
        super(Updater, self).__init__()
        self.title("Application updater")
        self.minsize(self.WIDTH, self.HEIGHT)
        self.wm_iconbitmap('./assets/icons/icon.ico')

        self.client = Client(ClientConfig(), progress_hooks=[self.print_status_info])
        self.client.refresh()
        self.pb = None
        self.frame_updater = None
        self.label = None
        self.waiting_image = None
        self.lib_update = self.client.update_check('Application', application.__version__)
Ejemplo n.º 8
0
def check_for_update():
    client = Client(ClientConfig(), refresh=True)
    app_update = client.update_check(ClientConfig.APP_NAME,
                                     ClientConfig.APP_VERSION)

    if app_update is not None:  # is there a new update
        if app_update.download():  # the update download is made here
            if isinstance(app_update, AppUpdate):  # you should freeze it
                app_update.extract_restart()
                return True
            else:
                app_update.extract()
                return True
    return False
Ejemplo n.º 9
0
    def pyupdater():
            
            from client_config import ClientConfig
            from pyupdater.client import Client
            APP_NAME = ClientConfig.APP_NAME
            APP_VERSION = ClientConfig.APP_VERSION
            client = Client(ClientConfig())
            client.refresh()


            

            app_update = client.update_check(APP_NAME, APP_VERSION)

            if app_update is not None:
                    app_update.download()
                        
                        

            if app_update is not None and app_update.is_downloaded():
                print("tryin to extract")
                app_update.extract_restart()
Ejemplo n.º 10
0
    def __init__(self, queue, app_name, app_version):

        # OS
        PLATFORM = platform.system()  # -> 'Windows' / 'Linux' / 'Darwin'

        # SET WORKING DIRECTORY
        # This is required for the PATHS to work properly when app is frozen
        if PLATFORM == 'Windows':
            cwd = os.path.dirname(os.path.abspath(sys.argv[0]))
        elif PLATFORM == 'Linux':
            cwd = os.path.abspath(
                os.path.join(os.path.dirname(__file__), os.pardir))
        else:
            logging.warning(('This app has not been yet '
                             'tested for platform_system={}').format(PLATFORM))
            cwd = os.path.abspath(
                os.path.join(os.path.dirname(__file__), os.pardir))
        os.chdir(cwd)

        #A callback to print download progress.
        def downloadStatus(info):
            total = info.get(u'total')
            downloaded = info.get(u'downloaded')
            progress = str(round(int(downloaded) * 100 / int(total)))
            status = info.get(u'status')

            if status == "finished":
                logging.info("Download finished")
            elif status == "downloading":
                logging.debug("Download progress: %s" % progress + "%")
                queue.put(progress)
            else:
                logging.warning(
                    "Unexpected download status: %s".format(status))

        #Initialize client with ClientConfig & later call refresh to get latest update data.
        #This HTTP key is needed to access to my repository.

        logging.debug("Opening client...")
        #client = Client(ClientConfig(),http = "reuMxY8PxCnrHctZyh29")
        client = Client(ClientConfig())
        client.refresh()

        #A hook to track download information
        client.add_progress_hook(downloadStatus)

        #Update_check returns an AppUpdate object if there is an update available
        logging.debug("Checking for updates...")
        app_update = client.update_check(app_name, app_version)

        #If we get an update object we can proceed to download the update.
        if app_update is not None:
            logging.info("A newer version was found")
            logging.debug("Downloading update...")
            app_update.download()
        else:
            logging.info("No update avalable")
            queue.put("NO_UPDATE")

        #Ensure file downloaded successfully, extract update, overwrite and restart current application
        if app_update is not None and app_update.is_downloaded():
            logging.debug("Overwriting current application...")
            app_update.extract_overwrite()
            logging.info("Succefuly overwrited")
            queue.put("DONE")
Ejemplo n.º 11
0
APP_NAME = 'p2'
APP_VERSION = '1.1.1'

ASSET_NAME = 'ffmpeg'
ASSET_VERSION = '2.3.2'


def print_status_info(info):
    total = info.get(u'total')
    downloaded = info.get(u'downloaded')
    status = info.get(u'status')
    print(downloaded, total, status)


client = Client(ClientConfig())
client.refresh()

client.add_progress_hook(print_status_info)
client = Client(ClientConfig(),
                refresh=True,
                progress_hooks=[print_status_info])
app_update = client.update_check(APP_NAME, APP_VERSION)
app_update = client.update_check(APP_NAME, APP_VERSION, channel='beta')
if app_update is not None:
    app_update.download()

if app_update is not None:
    app_update.download(background=True)
    if app_update.is_downloaded():
        app_update.extract_overwrite()
Ejemplo n.º 12
0
 def __init__(self, version):
     self.version = version
     self.cfg = ClientConfig()
     self.cfg.UPDATE_URLS = UPDATE_URLS
     self.cli = Client(self.cfg, headers=AUTHORIZE_HEADER, refresh=True, data_dir=DOWNLOAD_FOLDER)
     self.app_update = None
Ejemplo n.º 13
0
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
# OR OTHER DEALINGS IN THE SOFTWARE.


from PyQt5.QtCore    import *
from PyQt5.QtWidgets import *
import os
# from pyupdater.client import Client
from client_config import ClientConfig

APP_NAME = ClientConfig().APP_NAME
try:
    from app_version import APP_VERSION
except:
    APP_VERSION = '0.0.1beta1'


class autoUpdaterWorker(QThread):
    sessionUpdateStatus    = pyqtSignal(int,int)
    def __init__(self,update,client):
        super(QThread, self).__init__()

        self.update = update

        client.add_progress_hook(self.print_status_info)
Ejemplo n.º 14
0
        # pylint: disable=too-few-public-methods
        APP_NAME = 'PyUpdaterWxDemo'
        COMPANY_NAME = 'Company Name'
        MAX_DOWNLOAD_RETRIES = 3
        PUBLIC_KEY = None
        UPDATE_URLS = []
else:
    try:
        from client_config import ClientConfig  # pylint: disable=import-error
    except ImportError:
        sys.stderr.write("client_config.py is missing.\n"
                         "You need to run: pyupdater init\n"
                         "See: http://www.pyupdater.org/usage-cli/\n")
        sys.exit(1)

CLIENT_CONFIG = ClientConfig()
if 'WXUPDATEDEMO_TESTING_APP_NAME' in os.environ:
    CLIENT_CONFIG.APP_NAME = os.environ['WXUPDATEDEMO_TESTING_APP_NAME']
if 'WXUPDATEDEMO_TESTING_COMPANY_NAME' in os.environ:
    CLIENT_CONFIG.COMPANY_NAME = os.environ[
        'WXUPDATEDEMO_TESTING_COMPANY_NAME']
if 'WXUPDATEDEMO_TESTING_APP_VERSION' in os.environ:
    wxupdatedemo.__version__ = os.environ['WXUPDATEDEMO_TESTING_APP_VERSION']
if 'WXUPDATEDEMO_TESTING_PUBLIC_KEY' in os.environ:
    CLIENT_CONFIG.PUBLIC_KEY = os.environ['WXUPDATEDEMO_TESTING_PUBLIC_KEY']


def UpdatePyUpdaterClientConfig(clientConfig, port):
    """
    Update PyUpdater client config.
import digital_signature
import tkinter as tk
import tkinter.ttk as ttk
import time
import sys
from pyupdater.client import Client
from client_config import ClientConfig
from my_logger import MyLogger

log = MyLogger().my_logger()
CLIENT_CONFIG = ClientConfig()
progbar = None
root = None


class UpdateStatus(object):
    """Enumerated data type"""
    # pylint: disable=invalid-name
    # pylint: disable=too-few-public-methods
    UNKNOWN = 0
    NO_AVAILABLE_UPDATES = 1
    UPDATE_DOWNLOAD_FAILED = 2
    EXTRACTING_UPDATE_AND_RESTARTING = 3
    UPDATE_AVAILABLE_BUT_APP_NOT_FROZEN = 4
    COULDNT_CHECK_FOR_UPDATES = 5


UPDATE_STATUS_STR = \
    ['Unknown', 'No available updates were found.',
     'Update download failed.', 'Extracting update and restarting.',
     'Update available but application is not frozen.',