updater4pyi.upd_core module¶
-
class
updater4pyi.upd_core.
FileToUpdate
(fn, reltype, executable)¶ Bases:
tuple
-
executable
¶ Alias for field number 2
-
fn
¶ Alias for field number 0
-
reltype
¶ Alias for field number 1
-
-
class
updater4pyi.upd_core.
Updater
(current_version, update_source)[source]¶ Bases:
object
The main Updater object.
This class is responsible for actually checking for updates and performing the software update.
It does not take care of scheduling the checks, however. That’s done with an UpdaterInterface.
This class needs to be specified a source for updates. See
upd_source.UpdateSource
.-
SPECIAL_ZIP_FILES
= ('_updater4pyi_metainf.json', '_METAINF')¶
-
check_for_updates
()[source]¶ Perform an update check.
Queries the source for possible updates, which matches our system. If a software update is found, then a
upd_source.BinReleaseInfo
object is returned, describing the software update. Otherwise, if no update is available, None is returned.
-
current_version
()[source]¶ Return the current version of the running program, as given to the constructor.
-
download_file
(theurl, fdst)[source]¶ Download the file given at location theurl to the destination file fdst.
You may reimplement this function to customize the download process. Check out upd_downloader.url_opener if you want to download stuff from an HTTPS url, it may be useful.
The default implementation downloads the file with the upd_downloader utility which provides secure downloads with certificate validation for HTTPS downloads.
This function should return nothing. If an error occurs, this function should raise an IOError.
-
file_to_update
()[source]¶ Return the file one should update. See
determine_file_to_update()
.
-
install_update
(rel_info)[source]¶ Install a given update. rel_info should be a
upd_source.BinReleaseInfo
returned bycheck_for_updates()
.The actual updates are downloaded by calling
download_file()
. You may overload that function if you need to customize the download process. You may also overrideverify_download()
to implement some download integrity verification.This function does not return anything. If an error occurred,
upd_defs.Updater4PyiError
is raised.
-
restart_app
()[source]¶ Utility to restart the application. This is meant for graphical applications which start in the background.
The application exit is done by calling
sys.exit(0)
.
-
verify_download
(rel_info, tmpfile)[source]¶ Verify the integrity of the downloaded file. Return True if the download succeeded or False if not.
Arguments:
- rel_info is the release information as a
upd_source.BinReleaseInfo
instance, as given toinstall_update()
. - tmpfile is a python
tempfile.NamedTemporaryFile
instance where the file was downloaded. This function should in principle check the validity of the contents of this file.
You may reimplement this function to implement integrity check. The default implementation does nothing and returns True.
Don’t raise arbitrary exceptions here because they might not be caught. You may raise
upd_defs.Updater4PyiError
for serious errors, though.- rel_info is the release information as a
-
-
updater4pyi.upd_core.
determine_file_to_update
()[source]¶ Inspects the program currently running, and determines the location of the file one should replace in the event of a software update.
Returns a named tuple FileToUpdate(fn=.., reltype=.., executable=...). The values are:
- fn: the actual file we should update. This could be a directory in the case of a onedir PyInstaller package. For a MAC OS X bundle, it is the XYZ.app file.
- reltype: the release type we have. This may be one of
upd_defs.RELTYPE_EXE
,upd_defs.RELTYPE_ARCHIVE
,upd_defs.RELTYPE_BUNDLE_ARCHIVE
. - executable: the actual executable file. This may be different from fn, for example in Mac OS X bundles, where executable is the actual file being executed within the bundle.