def test_esky_locking(self): """Test that locking an Esky works correctly.""" platform = get_platform() appdir = tempfile.mkdtemp() try: vdir = os.path.join(appdir, ESKY_APPDATA_DIR, "testapp-0.1.%s" % (platform, )) os.makedirs(vdir) os.mkdir(os.path.join(vdir, ESKY_CONTROL_DIR)) open( os.path.join(vdir, ESKY_CONTROL_DIR, "bootstrap-manifest.txt"), "wb").close() e1 = esky.Esky(appdir, "http://example.com/downloads/") assert e1.name == "testapp" assert e1.version == "0.1" assert e1.platform == platform e2 = esky.Esky(appdir, "http://example.com/downloads/") assert e2.name == "testapp" assert e2.version == "0.1" assert e2.platform == platform locked = [] errors = [] trigger1 = threading.Event() trigger2 = threading.Event() def runit(e, t1, t2): def runme(): try: e.lock() except Exception, err: errors.append(err) else: locked.append(e)
def test_esky_lock_breaking(self): """Test that breaking the lock on an Esky works correctly.""" appdir = tempfile.mkdtemp() try: os.makedirs( os.path.join(appdir, ESKY_APPDATA_DIR, "testapp-0.1", ESKY_CONTROL_DIR)) open( os.path.join(appdir, ESKY_APPDATA_DIR, "testapp-0.1", ESKY_CONTROL_DIR, "bootstrap-manifest.txt"), "wb").close() e1 = esky.Esky(appdir, "http://example.com/downloads/") e2 = esky.Esky(appdir, "http://example.com/downloads/") trigger1 = threading.Event() trigger2 = threading.Event() errors = [] def run1(): try: e1.lock() except Exception, err: errors.append(err) trigger1.set() trigger2.wait() def run2(): trigger1.wait() try: e2.lock() except esky.EskyLockedError: pass except Exception, err: errors.append(err) else:
def InitUpdates(self, updatesURL, changelogURL=None, icon=None): """ Set up the Esky object for doing software updates. Passing either the base URL (with a trailing '/') for the location of the update packages, or an instance of a class derived from the esky.finder.VersionFinder class is required. A custom VersionFinder can be used to find and fetch the newer verison of the software in some other way, if desired. Call this method from the app's OnInit method. """ if isFrozenApp: self._esky = esky.Esky(sys.executable, updatesURL) self._updatesURL = updatesURL self._changelogURL = changelogURL self._icon = icon self._pd = None self._checkInProgress = False try: # get rid of the prior version if it is still here. if self._esky.needs_cleanup(): self._esky.cleanup() except: pass self._fixSysExecutable()
def __init__(self, url): QThread.__init__(self) self.url = url self.new_version = None self.frozenapp = esky.Esky(sys.executable, self.url) try: log.Debug('Checking for new version at {0}'.format(self.url)) self.new_version = self.frozenapp.find_update() except Exception, e: log.Error(str(e))
def auto_update(scheduler): if hasattr(sys, "frozen"): app = esky.Esky(sys.executable, Config.update_config["update_url"]) try: if app.find_update() is not None: app.auto_update(callback=Updater.update_callback) app_exe = esky.util.appexe_from_executable(sys.executable) os.execv(app_exe, [app_exe] + sys.argv[1:]) except Exception, e: Config.logger.warn("Error updating app") Config.logger.error(e) app.cleanup()
def update(version=None): ''' Update the salt minion from the URL defined in opts['update_url'] This feature requires the minion to be running a bdist_esky build. The version number is optional and will default to the most recent version available at opts['update_url']. Returns details about the transaction upon completion. CLI Example: .. code-block:: bash salt '*' saltutil.update 0.10.3 ''' if not HAS_ESKY: return 'Esky not available as import' if not getattr(sys, 'frozen', False): return 'Minion is not running an Esky build' if not __salt__['config.option']('update_url'): return '"update_url" not configured on this minion' app = esky.Esky(sys.executable, __opts__['update_url']) oldversion = __grains__['saltversion'] try: if not version: version = app.find_update() if not version: return 'No updates available' app.fetch_version(version) app.install_version(version) app.cleanup() except Exception as err: return err restarted = {} for service in __opts__['update_restart_services']: restarted[service] = __salt__['service.restart'](service) return { 'comment': 'Updated from {0} to {1}'.format(oldversion, version), 'restarted': restarted }
def update(version=None): ''' Update the salt minion from the URL defined in opts['update_url'] SaltStack, Inc provides the latest builds here: update_url: https://repo.saltstack.com/windows/ Be aware that as of 2014-8-11 there's a bug in esky such that only the latest version available in the update_url can be downloaded and installed. This feature requires the minion to be running a bdist_esky build. The version number is optional and will default to the most recent version available at opts['update_url']. Returns details about the transaction upon completion. CLI Examples: .. code-block:: bash salt '*' saltutil.update salt '*' saltutil.update 0.10.3 ''' ret = {} if not HAS_ESKY: ret['_error'] = 'Esky not available as import' return ret if not getattr(sys, 'frozen', False): ret['_error'] = 'Minion is not running an Esky build' return ret if not __salt__['config.option']('update_url'): ret['_error'] = '"update_url" not configured on this minion' return ret app = esky.Esky(sys.executable, __opts__['update_url']) oldversion = __grains__['saltversion'] if not version: try: version = app.find_update() except URLError as exc: ret['_error'] = 'Could not connect to update_url. Error: {0}'.format(exc) return ret if not version: ret['_error'] = 'No updates available' return ret try: app.fetch_version(version) except EskyVersionError as exc: ret['_error'] = 'Unable to fetch version {0}. Error: {1}'.format(version, exc) return ret try: app.install_version(version) except EskyVersionError as exc: ret['_error'] = 'Unable to install version {0}. Error: {1}'.format(version, exc) return ret try: app.cleanup() except Exception as exc: ret['_error'] = 'Unable to cleanup. Error: {0}'.format(exc) restarted = {} for service in __opts__['update_restart_services']: restarted[service] = __salt__['service.restart'](service) ret['comment'] = 'Updated from {0} to {1}'.format(oldversion, version) ret['restarted'] = restarted return ret
# função para apagar a onu def apagarOnu(self, event): # pega onu selecionada onuSel = self.listbox.selection_get() for x in onuSel.split(":"): apag = Apagar(onuLista[int(x) - 1], self.serial) break showinfo("Apagar ONU", "Exclusão Realizada!") self.voltarTelaInicial(event) if hasattr(sys, "frozen"): app = esky.Esky( sys.executable, "https://drive.google.com/drive/folders/1NiFKAG88Du1JpLMjjpwVCemHGiLuPnOy?usp=sharing" ) app.auto_update() root = Tk() root.iconbitmap('ico/spu.ico') root.title("Sistema de Provisionamento Unificado (Ísis)") TelaInicial(root) # posiciona a janela de acordo com a resolução da tela if GetSystemMetrics(1) == 1080: root.geometry("550x385-650+300") elif GetSystemMetrics(1) == 768 or GetSystemMetrics(1) == 720: root.geometry("550x385-400+150") else: root.geometry("550x385") root.mainloop()
import sys import os import esky if getattr(sys, "frozen", False): app = esky.Esky(sys.executable, "https://example-app.com/downloads/") print "You are running: %s" % app.active_version try: if (app.find_update() != None): app.auto_update() appexe = esky.util.appexe_from_executable(sys.executable) os.execv(appexe, [appexe] + sys.argv[1:]) except Exception, e: print "ERROR UPDATING APP:", e app.cleanup() print "HELLO WORLD"
#CHECK_PETALS_URL = 'http://localhost:8080/checkPetalsTest' CRF_SYNCH_TIME_INTERVAL = 15 * 60 ACTIVE_CRFS_TIME_INTERVAL = 15 * 60 DB_SYNCH_TIME_INTERVAL = 1 * 60 CONNECTION_CHECK_TIME_INTERVAL = 5 * 60 SOFTWARE_UPDATE_TIME_INTERVAL = 15 * 60 EVALUATION_TIME_INTERVAL = 15 * 60 import os from psversion import PROSAFE_VERSION try: import esky import sys eskyApp = esky.Esky(sys.executable) imagesPath = eskyApp.get_abspath("images") isFrozen = True except: imagesPath = "images" isFrozen = False def abspath(path='./', verpath=False): if not isFrozen: returnpath = os.path.join(os.getcwd(), path) else: if not verpath: wrapperpath = os.path.join(eskyApp.get_abspath(''), '../') returnpath = os.path.join(wrapperpath, path)
from __future__ import print_function import sys import esky if getattr(sys, "frozen", False): app = esky.Esky(sys.executable, "http://localhost:8000") try: app.auto_update() except Exception as e: print("ERROR UPDATING APP:", e) print("HELLO AGAIN WORLD Stage - 3")
target=ReactiveControl.temperature_updated, args=(temperature, )) temperature_thread.daemon = True temperature_thread.start() @staticmethod def exposed_motion_updated(standard_deviation): motion_thread = threading.Thread(target=ReactiveControl.motion_updated, args=(standard_deviation, )) motion_thread.daemon = True motion_thread.start() if __name__ == "__main__": Config.initialize() if hasattr(sys, "frozen"): app = esky.Esky(sys.executable, Config.update_config["update_url"]) Config.logger.info("SPOTlight control worker %s started..." % app.active_version) app.cleanup() try: spotlight_collection = collection.Collection( Config.db_client.spotlight, "Devices") spotlight_collection.update_one( {"device_id": Config.service_config["device_id"]}, {"$set": { "control_app_version": app.active_version }}) except Exception, e: Config.handle_access_db_error(e) else: Config.logger.info("SPOTlight control worker started...")
# # se for rodar pelo script, dê pythonw.exe boneca.py # Para aparecer a boneca pressione Print Screen # Para fechar o programa pressione Windows + F4 # # # import os import sys import ctypes from ctypes import wintypes import win32con import esky if hasattr(sys, "frozen"): app = esky.Esky(sys.executable, "http://teenspirit.com.br/exemplo_boneca/") app.auto_update() byref = ctypes.byref user32 = ctypes.windll.user32 HOTKEYS = { 1: (win32con.VK_SNAPSHOT, 0), ####Essa Linha Pega a entrada "PRINT SCREEN" do teclado 2: (win32con.VK_F4, win32con.MOD_WIN) } def handle_win_f3(): os.startfile( os.path.join(os.path.realpath(os.path.dirname(sys.argv[0])),
timestamp = math.fabs(time.time() - config.last_sanity_check_timestamp) if timestamp > config.interval_between_network_sanity_checks: # if the last check was before more than interval_between_network_sanity_checks # Newest version check - old # try: # newest_version = WebParser.WebServices.get_newestversion() # if newest_version > float(__version__): # log.warning("A new version of iQuality is available (%s)." % newest_version) # _warnings.append(NewerVersionWarning(newest_version)) # except IOError as e: # log.error("Could not check for the newest version (%s)" % unicode(e)) # Newest version check - esky if hasattr(sys, "frozen"): try: eskyObj = esky.Esky(sys.executable, config.esky_zipfiles_download_page) v = eskyObj.find_update() if v: log.warning( "A new version of iQuality is available (%s, via esky)." % v) _warnings.append( NewerVersionWarning(v, eskyObj.version, eskyObj)) # print "Found %s --> %s (%s)!" % (app.version, v, app.version_finder.version_graph.get_best_path(app.version,v)) except IOError as e: log.error("Could not check for the newest version (%s)" % unicode(e)) # External Components Check hash_failed = [] not_exists = []
def checkSoftwareUpdate(self, centreCode, stopServicesCallback): if self.checkingSoftwareUpdate: return False self.checkingSoftwareUpdate = True try: import esky from versionfinder import ProsafeVersionFinder except: print 'WARNING: No Esky module found' self.checkingSoftwareUpdate = False return False updated = False if QueryServer(centreCode, 'UpdateSW', 'Allow', True): try: if getattr(sys, "frozen", False): updateStopped = False lockfile = os.path.join(os.getcwd(), 'download.lock') try: os.unlink(lockfile) except: pass import psconstants as psc #if psc.appName == 'prosafe': # vfinder = ProsafeVersionFinder(psconstants.ESKY_FILES_DOWNLOAD_URL + centreCode, lockfile) #else: # vfinder = ProsafeVersionFinder(psconstants.ESKY_FILES_DOWNLOAD_URL, lockfile) vfinder = ProsafeVersionFinder( psconstants.ESKY_FILES_DOWNLOAD_URL + centreCode, lockfile) eskyApp = esky.Esky(sys.executable, vfinder) #self.progressDlg.Show() #self.progressDlg.SetFocus() tr = EskyDownloader(eskyApp) print "starting Esky downloader" tr.start() keepGoing = True while tr.is_alive() and keepGoing: if not MasterTimeSleep(1): keepGoing = False # (keepGoing, skip) = self.progressDlg.UpdatePulse() if not keepGoing: updateStopped = True #TODO: what is this lockfile here for? if updateStopped: l = open(lockfile, "wb") l.close() #self.progressDlg.Destroy() if tr.downloaded == True: print "cleanup" eskyApp.cleanup() updated = True #stop Pyro services and threads stopServicesCallback() #notify server of update done ... if we restart this #is the last place where we can do it QueryServer(centreCode, 'UpdateSW', 'Done', True) #TODO: "prosafe.exe" is not crossplatform #TODO: avoid doing this in network manager #command = abspath("prosafe.exe") #os.execl(command, ' ') import wx wx.CallAfter(sys.exit, 0) except BaseException, e: print e self.checkingSoftwareUpdate = False QueryServer(centreCode, 'UpdateSW', 'Done', True)