def update_ledfx(): # in future we can use the defined consts, but for now for dev # initialize & refresh in one update check client class ClientConfig(object): PUBLIC_KEY = 'Txce3TE9BUixsBtqzDba6V5vBYltt/0pw5oKL8ueCDg' APP_NAME = PROJECT_NAME COMPANY_NAME = 'LedFx Developers' HTTP_TIMEOUT = 30 MAX_DOWNLOAD_RETRIES = 3 UPDATE_URLS = ['https://ledfx.app/downloads/'] client = Client(ClientConfig(), refresh=True) _LOGGER.info('Checking for updates...') # First we check for updates. # If an update is found an update object will be returned # If no updates are available, None will be returned ledfx_update = client.update_check(PROJECT_NAME, PROJECT_VERSION) # Download the update if ledfx_update is not None: _LOGGER.info("Update found!") _LOGGER.info("Downloading update, please wait...") ledfx_update.download() # Install and restart if ledfx_update.is_downloaded(): _LOGGER.info("Update downloaded, extracting and restarting...") ledfx_update.extract_restart() else: _LOGGER.info("Unable to download update.") else: # No Updates, into main we go _LOGGER.info("You're all up to date, enjoy the light show!")
def main(): print(VERSION) data_dir = None config = client_config.ClientConfig() if getattr(config, 'USE_CUSTOM_DIR', False): if (sys.platform == 'darwin' and os.path.dirname(sys.executable ).endswith('MacOS')): data_dir = os.path.join(get_mac_dot_app_dir(os.path.dirname( sys.executable)), '.update') else: data_dir = os.path.join(os.path.dirname(os.path.dirname( sys.executable)), '.update') client = Client(config, refresh=True, progress_hooks=[cb], data_dir=data_dir) update = client.update_check(APPNAME, VERSION) if update is not None: success = update.download() print('') if success is True: print('Update download successful') print('Extracting & overwriting') update.extract_overwrite() else: print('Failed to download update') return VERSION
def test_bad_pub_key(self): t_config = TConfig() # If changed ensure it's a valid key format t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM' t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) assert client.update_check(client.app_name, '0.0.0') is None
def run(self): try: latest_version = core.utils.get_latest_version() except Exception as e: logger.warning(f"Could not get release data. Error {e}") return if latest_version == VERSION: return client = Client(ClientConfig()) client.refresh() app_update = client.update_check(ClientConfig.APP_NAME, PYU_VERSION) if app_update is None: return app_update.download() self.signals.ask_for_permission.emit(latest_version) self.mutex.lock() try: self.cond.wait(self.mutex) finally: self.mutex.unlock() if not self.allowed_download: logger.debug("Update declined") return if app_update.is_downloaded(): logger.debug("Update: Extract and Restart") app_update.extract_restart()
def run(self): """Run the initial process.""" try: from scctool.settings.client_config import ClientConfig from scctool.tasks.updater import extractData from pyupdater.client import Client client = Client(ClientConfig()) client.refresh() client.add_progress_hook(self.setProgress) channel = scctool.tasks.updater.getChannel() lib_update = client.update_check( scctool.tasks.updater.VersionHandler.ASSET_NAME, self.version, channel=channel) if lib_update is not None: lib_update.download(async=False) self.setValue(500) self.setLabelText(_("Extracting data...")) extractData(lib_update, self.setCopyProgress) self.setLabelText(_("Done.")) time.sleep(1) self.setValue(1010) except Exception as e: module_logger.exception("message")
def main(): print(VERSION) data_dir = None config = client_config.ClientConfig() if getattr(config, 'USE_CUSTOM_DIR', False): print("Using custom directory") if (sys.platform == 'darwin' and os.path.dirname(sys.executable ).endswith('MacOS')): data_dir = os.path.join(get_mac_dot_app_dir(os.path.dirname( sys.executable)), '.update') else: data_dir = os.path.join(os.path.dirname(sys.executable), '.update') client = Client(config, refresh=True, progress_hooks=[cb], data_dir=data_dir) update = client.update_check(APPNAME, VERSION) if update is not None: print("We have an update") retry_count = 0 while retry_count < 5: success = update.download() if success is True: break print("Retry Download. Count {}".format(retry_count + 1)) retry_count += 1 if success: print('Update download successful') print('Restarting') update.extract_restart() else: print('Failed to download update') print("Leaving main()")
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__}')
def CheckForUpdates(fileServerPort, debug): """ Check for updates. Channel options are stable, beta & alpha Patches are only created & applied on the stable channel """ assert CLIENT_CONFIG.PUBLIC_KEY is not None client = Client(CLIENT_CONFIG, refresh=True) appUpdate = client.update_check(CLIENT_CONFIG.APP_NAME, wxupdatedemo.__version__, channel='stable') if appUpdate: if hasattr(sys, "frozen"): downloaded = appUpdate.download() if downloaded: status = UpdateStatus.EXTRACTING_UPDATE_AND_RESTARTING if 'WXUPDATEDEMO_TESTING_FROZEN' in os.environ: sys.stderr.write("Exiting with status: %s\n" % UPDATE_STATUS_STR[status]) ShutDownFileServer(fileServerPort) sys.exit(0) ShutDownFileServer(fileServerPort) if debug: logger.debug('Extracting update and restarting...') time.sleep(10) appUpdate.extract_restart() else: status = UpdateStatus.UPDATE_DOWNLOAD_FAILED else: status = UpdateStatus.UPDATE_AVAILABLE_BUT_APP_NOT_FROZEN else: status = UpdateStatus.NO_AVAILABLE_UPDATES return status
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
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
def main(): print(VERSION) data_dir = None config = client_config.ClientConfig() if getattr(config, "USE_CUSTOM_DIR", False): if sys.platform == "darwin" and os.path.dirname( sys.executable).endswith("MacOS"): data_dir = os.path.join( get_mac_dot_app_dir(os.path.dirname(sys.executable)), ".update") else: data_dir = os.path.join( os.path.dirname(os.path.dirname(sys.executable)), ".update") client = Client(config, refresh=True, progress_hooks=[cb], data_dir=data_dir) update = client.update_check(APPNAME, VERSION) if update is not None: success = update.download() print("") if success is True: print("Update download successful") print("Extracting & overwriting") update.extract_overwrite() else: print("Failed to download update") return VERSION
def test_http(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'Acme' assert update.download() is True assert update.is_downloaded() is True
def main(): print(VERSION) client = Client(client_config.ClientConfig(), refresh=True) update = client.update_check(APPNAME, VERSION) if update is not None: update.download() update.extract_overwrite() return VERSION
def test_manifest_filesystem(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) filesystem_data = client._get_manifest_from_disk() assert filesystem_data is not None filesystem_data = filesystem_data.decode() filesystem_data = json.loads(filesystem_data) del filesystem_data["signature"] assert client.json_data == filesystem_data
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 = {}
def test_callback(self): def cb(status): print(status) def cb2(status): raise IndexError t_config = TConfig() t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM' t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True, progress_hooks=[cb]) client.add_progress_hook(cb2) assert client.update_check(client.app_name, '0.0.0') is None
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__)
def main(): print(VERSION) client = Client(client_config.ClientConfig(), refresh=True, progress_hooks=[cb]) update = client.update_check(APPNAME, VERSION) if update is not None: success = update.download() if success is True: print('Update download successful') print('Restarting') update.extract_overwrite() else: print('Failed to download update') return VERSION
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
def test_background_http(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'Acme' update.download(background=True) count = 0 while count < 61: if update.is_downloaded() is True: break time.sleep(1) count += 1 assert update.is_downloaded() is True
def __init__(self, callback=None, options=None): self._sendMidiCallback = callback self._update_paths = None self._client_config = None self._isUpdating = False if options is not None: self._update_paths = options.update_paths self._client_config = options.client_config self._update_urls = options.update_urls # Client for pyupdate if self._client_config is None: self._client_config = client_config.ClientConfig() self.client = Client(self._client_config, downloader=self.createDownloader) self.client.add_progress_hook(print_status_info)
def test_multiple_background_calls(self, client): t_config = TConfig() t_config.DATA_DIR = os.getcwd() t_config.VERIFY_SERVER_CERT = False client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'Acme' update.download(background=True) count = 0 assert update.download(background=True) is None assert update.download() is None while count < 61: if update.is_downloaded() is True: break time.sleep(1) count += 1 assert update.is_downloaded() is True
def main(): print(VERSION) data_dir = None config = client_config.ClientConfig() if getattr(config, 'USE_CUSTOM_DIR', False): data_dir = os.path.join(os.path.dirname(sys.executable), '.update') client = Client(config, refresh=True, progress_hooks=[cb], data_dir=data_dir) update = client.update_check(APPNAME, VERSION) if update is not None: success = update.download() if success is True: print('Update download successful') print('Restarting') update.extract_overwrite() else: print('Failed to download update') return VERSION
def check_for_updates(update_checker_url=None): """Controllo nuovi aggiornamenti. :param update_checker_url: Url server degli aggiornamenti, defaults to None :type update_checker_url: str, optional :return: UpdateObject utilizzato per aggiornare i binari :rtype: AppUpdate """ assert CLIENT_CONFIG.PUBLIC_KEY is not None # Se update_checker_url è presente nel json, allora il controllo degli aggiornamenti viene # fatto su quell'URL altrimenti prendo il default dal file di configurazione if update_checker_url is not None: CLIENT_CONFIG.UPDATE_URLS[0] = update_checker_url.rstrip( '/') + '/deploy/' client = Client(CLIENT_CONFIG, refresh=True, progress_hooks=[progress]) log.info("Actual client version: %s" % digital_signature.__version__) appUpdate = client.update_check(CLIENT_CONFIG.APP_NAME, digital_signature.__version__, channel='stable') return appUpdate
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()
def update_ledfx(): # initialize & refresh in one update, check client class ClientConfig(object): PUBLIC_KEY = "Txce3TE9BUixsBtqzDba6V5vBYltt/0pw5oKL8ueCDg" APP_NAME = PROJECT_NAME COMPANY_NAME = "LedFx Developers" HTTP_TIMEOUT = 5 MAX_DOWNLOAD_RETRIES = 2 UPDATE_URLS = ["https://ledfx.app/downloads/"] client = Client(ClientConfig(), refresh=True) _LOGGER.log(PYUPDATERLOGLEVEL, "Checking for updates...") # First we check for updates. # If an update is found, an update object will be returned # If no updates are available, None will be returned ledfx_update = client.update_check(PROJECT_NAME, PROJECT_VERSION) # Download the update if ledfx_update is not None: _LOGGER.log(PYUPDATERLOGLEVEL, "Update found!") _LOGGER.log(PYUPDATERLOGLEVEL, "Downloading update, please wait...") ledfx_update.download() # Install and restart if ledfx_update.is_downloaded(): _LOGGER.log( PYUPDATERLOGLEVEL, "Update downloaded, extracting and restarting...", ) ledfx_update.extract_restart() else: _LOGGER.error("Unable to download update.") else: # No Updates, into main we go _LOGGER.log( PYUPDATERLOGLEVEL, "You're all up to date, enjoy the light show!", )
def __init__(self, mw=None, test_version=None, channel='stable', dev_channel=False): client_config = ClientConfig() self.client = Client(client_config, progress_hooks=[self.print_status_info]) # set dev channel to alpha internally based on bool if dev_channel: channel = 'alpha' warnings.simplefilter( 'ignore', DeprecationWarning) # pyupdater turns this on, annoying _version = VERSION if test_version is None else test_version update_available = False app_update = None status = 'initialized' self.url_changelog = 'https://raw.githubusercontent.com/jaymegordo/SMSEventLog/main/CHANGELOG.md' f.set_self(vars())
class VersionHandler(TasksThread): """Check for new version and update or notify.""" newVersion = pyqtSignal(str) newData = pyqtSignal(str) noNewVersion = pyqtSignal() progress = pyqtSignal(dict) updated_data = pyqtSignal(str) # Constants APP_NAME = ClientConfig.APP_NAME APP_VERSION = scctool.__version__ ASSET_NAME = 'SCCT-data' ASSET_VERSION = '0.0.0' client = Client(ClientConfig()) app_update = None asset_update = None def __init__(self, controller): """Init the thread.""" super().__init__() self.__controller = controller self.setTimeout(10) self.addTask('version_check', self.__version_check) self.addTask('update_data', self.__update_data) self.addTask('update_app', self.__update_app) self.updated_data.connect(controller.displayWarning) # self.disableCB.connect(controller.uncheckCB) def isCompatible(self): """Check if data update is needed.""" return compareVersions(self.asset_update.latest, self.APP_VERSION, 3) < 1 def update_progress(self, data): """Process progress updates.""" self.progress.emit(data) def __version_check(self): try: self.client.add_progress_hook(self.update_progress) self.client.refresh() self.ASSET_VERSION = getDataVersion() channel = getChannel(self.APP_VERSION) self.app_update = self.client.update_check(self.APP_NAME, self.APP_VERSION, channel=channel) if self.asset_update is not None: self.newData.emit(self.asset_update.latest) module_logger.info("Asset: " + self.asset_update.latest) if self.isCompatible(): self.activateTask("update_data") if self.app_update is not None: scctool.__latest_version__ = self.app_update.latest scctool.__new_version__ = True self.newVersion.emit(self.app_update.latest) module_logger.info("App: " + self.app_update.latest) else: self.noNewVersion.emit() except Exception: module_logger.exception("message") finally: self.deactivateTask('version_check') def __update_data(self): try: module_logger.info("Start to update data files!") if self.asset_update is None: self.deactivateTask('update_data') return self.asset_update.download() extractData(self.asset_update) module_logger.info("Updated data files!") self.updated_data.emit(_("Updated data files!")) except Exception: module_logger.exception("message") finally: self.deactivateTask('update_data') def __update_app(self): try: if self.app_update is None: self.deactivateTask('update_app') return if hasattr(sys, "frozen"): module_logger.info("Start to update app!") self.app_update.download(False) if self.app_update.is_downloaded(): module_logger.info("Download sucessfull.") self.__controller.cleanUp() setRestartFlag() module_logger.info("Restarting...") self.app_update.extract_restart() except Exception: module_logger.exception("message") finally: self.deactivateTask('update_app')
def client(): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) client.FROZEN = True return client
def test_url_str_attr(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() t_config.UPDATE_URLS = 'http://acme.com/update' client = Client(t_config, test=True) assert isinstance(client.update_urls, list)