parameters: (mirror_url, scr=False)
docstring: Check for and apply an update to myself
docstring_summary: Check for and apply an update to myself
docstring_tokens: Check for and apply an update to myself
function: def self_update(mirror_url, scr=False):
      '''Check for and apply an update to myself'''
      from os import execv, chmod
      from sys import argv
      
      # See if there is a newer version available
  
      url = "/".join((mirror_url.rstrip('/'), 'fslinstaller.py'))
      web_version = get_web_version('-'.join((url, "version.txt"))).result
      if web_version <= version:
          MsgUser.debug("Installer is up-to-date." )
          return FslIResult(True, FslIResult.SUCCESS, 'Installer is current')
      
      # There is a new version available - download it
      MsgUser.message("There is a newer version (%s) of the installer (you have %s) updating..." % (web_version, version))
      (_, tmpfname) = tempFileName(mode='w', close=True)
      
      a_result = download_file(url, tmpfname)
      if a_result.status == FslIResult.SUCCESS:
          url = "/".join((mirror_url.rstrip('/'), 'md5sums', 'fslinstaller.py.md5'))
          # Got the new version, now get the MD5 of the file
          MsgUser.debug("Downloading %s to check %s" % (url,tmpfname))
          m_result = getAndVerifyMD5(url, tmpfname)
          if m_result.status != FslIResult.SUCCESS:
              return FslIResult(False, FslIResult.ERROR, m_result.message)
      else:
          MsgUser.debug("Failed to update installer %s." % (a_result.message))
          return FslIResult(False, FslIResult.ERROR, 'Found update to installer but unable to download the new version. Please try again.')
      # Now run the new installer
      # EXEC new script with the options we were given
      chmod(tmpfname, 0555)
      execv(tmpfname, argv)
function_tokens: def self_update ( mirror_url , scr = False ) : from os import execv , chmod from sys import argv # See if there is a newer version available url = "/" . join ( ( mirror_url . rstrip ( '/' ) , 'fslinstaller.py' ) ) web_version = get_web_version ( '-' . join ( ( url , "version.txt" ) ) ) . result if web_version <= version : MsgUser . debug ( "Installer is up-to-date." ) return FslIResult ( True , FslIResult . SUCCESS , 'Installer is current' ) # There is a new version available - download it MsgUser . message ( "There is a newer version (%s) of the installer (you have %s) updating..." % ( web_version , version ) ) ( _ , tmpfname ) = tempFileName ( mode = 'w' , close = True ) a_result = download_file ( url , tmpfname ) if a_result . status == FslIResult . SUCCESS : url = "/" . join ( ( mirror_url . rstrip ( '/' ) , 'md5sums' , 'fslinstaller.py.md5' ) ) # Got the new version, now get the MD5 of the file MsgUser . debug ( "Downloading %s to check %s" % ( url , tmpfname ) ) m_result = getAndVerifyMD5 ( url , tmpfname ) if m_result . status != FslIResult . SUCCESS : return FslIResult ( False , FslIResult . ERROR , m_result . message ) else : MsgUser . debug ( "Failed to update installer %s." % ( a_result . message ) ) return FslIResult ( False , FslIResult . ERROR , 'Found update to installer but unable to download the new version. Please try again.' ) # Now run the new installer # EXEC new script with the options we were given chmod ( tmpfname , 0555 ) execv ( tmpfname , argv )