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 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 _overwrite(self): # Unix: Overwrites the running applications binary if get_system() == 'mac': if self._current_app_dir.endswith('MacOS') is True: log.debug('Looks like we\'re dealing with a Mac Gui') temp_dir = get_mac_dot_app_dir(self._current_app_dir) self._current_app_dir = temp_dir app_update = os.path.join(self.update_folder, self.name) # Must be dealing with Mac .app application if not os.path.exists(app_update): app_update += '.app' log.debug('Update Location:\n%s', os.path.dirname(app_update)) log.debug('Update Name: %s', os.path.basename(app_update)) current_app = os.path.join(self._current_app_dir, self.name) # Must be dealing with Mac .app application if not os.path.exists(current_app): current_app += '.app' log.debug('Current App location:\n\n%s', current_app) # Remove current app to prevent errors when moving # update to new location if os.path.exists(current_app): remove_any(current_app) log.debug('Moving app to new location:\n\n%s', self._current_app_dir) shutil.move(app_update, self._current_app_dir)
def _overwrite(self): # pragma: no cover # Unix: Overwrites the running applications binary if dsdev_utils.system.get_system() == 'mac': if self.current_app_dir.endswith('MacOS') is True: log.debug('Looks like we\'re dealing with a Mac Gui') temp_dir = get_mac_dot_app_dir(self.current_app_dir) self.current_app_dir = temp_dir app_update = os.path.join(self.update_folder, self.name) # Must be dealing with Mac .app application if not os.path.exists(app_update): app_update += '.app' log.debug('Update Location:\n%s', os.path.dirname(app_update)) log.debug('Update Name: %s', os.path.basename(app_update)) current_app = os.path.join(self.current_app_dir, self.name) # Must be dealing with Mac .app application if not os.path.exists(current_app): current_app += '.app' log.debug('Current App location:\n\n%s', current_app) # Remove current app to prevent errors when moving # update to new location if os.path.exists(current_app): remove_any(current_app) log.debug('Moving app to new location:\n\n%s', self.current_app_dir) shutil.move(app_update, self.current_app_dir)
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 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 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 _overwrite(self): # Unix: Overwrites the running applications binary if get_system() == "mac": if self._current_app_dir.endswith("MacOS") is True: log.debug("Looks like we're dealing with a Mac Gui") temp_dir = get_mac_dot_app_dir(self._current_app_dir) self._current_app_dir = temp_dir app_update = os.path.join(self.update_folder, self.name) # Must be dealing with Mac .app application if not os.path.exists(app_update) and sys.platform == "darwin": app_update += ".app" log.debug("Update Location:\n%s", os.path.dirname(app_update)) log.debug("Update Name: %s", os.path.basename(app_update)) current_app = os.path.join(self._current_app_dir, self.name) # Must be dealing with Mac .app application if not os.path.exists(current_app): current_app += ".app" log.debug("Current App location:\n\n%s", current_app) # Remove current app to prevent errors when moving # update to new location # if update_app is a directory, then we are updating a directory if os.path.isdir(app_update): if os.path.isdir(current_app): shutil.rmtree(current_app) else: shutil.rmtree(os.path.dirname(current_app)) if os.path.exists(current_app): remove_any(current_app) log.debug("Moving app to new location:\n\n%s", self._current_app_dir) shutil.move(app_update, self._current_app_dir)
def _overwrite(self): # Unix: Overwrites the running applications binary if get_system() == 'mac': if self._current_app_dir.endswith('MacOS') is True: log.debug('Looks like we\'re dealing with a Mac Gui') temp_dir = get_mac_dot_app_dir(self._current_app_dir) self._current_app_dir = temp_dir app_update = os.path.join(self.update_folder, self.name) # Must be dealing with Mac .app application if not os.path.exists(app_update) and sys.platform == "darwin": app_update += '.app' log.debug('Update Location:\n%s', os.path.dirname(app_update)) log.debug('Update Name: %s', os.path.basename(app_update)) current_app = os.path.join(self._current_app_dir, self.name) # Must be dealing with Mac .app application if not os.path.exists(current_app): current_app += '.app' log.debug('Current App location:\n\n%s', current_app) # Remove current app to prevent errors when moving # update to new location # if update_app is a directory, then we are updating a directory if os.path.isdir(app_update): if (os.path.isdir(current_app)): shutil.rmtree(current_app) else: shutil.rmtree(os.path.dirname(current_app)) if os.path.exists(current_app): remove_any(current_app) log.debug('Moving app to new location:\n\n%s', self._current_app_dir) shutil.move(app_update, self._current_app_dir)
def test_get_mac_app_dir(): main = 'Main' path = os.path.join(main, 'Contents', 'MacOS', 'app') assert get_mac_dot_app_dir(path) == main