Pyautoupdate API¶
Launcher¶
-
class
pyautoupdate.
Launcher
(filepath, url, newfiles='project.zip', log_level=30, *args, **kwargs)[source]¶ Creates a
Launcher
object. This class provides the main functionality of the Pyautoupdate module.Parameters: Note
This must be an HTTPS url. HTTP urls are silently changed into HTTPS. Use of HTTPS is strictly enforced.
Parameters, queries, and fragments will be stripped from the URL.
Parameters: When the code is launched, the following variables are already defined:
Variable Name Value Description filepath
Path to the file that was initially launched url
Base url to check and download new versions newfiles
Name of the archive to download from the server check_new
Method to check for updated code pid
PID of parent process that spawns the code log
Logger for Pyautoupdate and for the executed code args
args
tuple for the spawned codekwargs
kwargs
dict for the spawned codeWarning
The
Launcher
usesmultiprocessing.Process
to run the code.Please ensure that all arguments passed in as
args
andkwargs
can be pickled. Non-pickleable arguments cannot be passed to the child process on Windows, and an error will be raised when attempting to run user code.-
_call_code
(*args, **kwargs)[source]¶ Internal function to execute the user code.
This is used as target of a
multiprocessing.Process
instance.Parameters: Warning
End users should never call this directly. Please use the
run()
method instead.
-
_get_new
(allow_redirects=True, chunk_size=512)[source]¶ Retrieves the new archive and extracts it to self.updatedir.
-
_replace_files
()[source]¶ Replaces the existing files with the downloaded files.
Returns: Whether update succeeded Return type: bool
-
_reset_update_files
()[source]¶ Resets the update files to its default state.
It empties the existing update directory or creates a new one if it doesn’t exist.
-
check_new
()[source]¶ Retrieves the latest version number from the remote host.
Returns: Whether a newer version is available Return type: bool Note
This function internally uses setuptool’s
parse_version
to compare versions.Any versioning scheme conforming to PEP 440 can be used.
When the server contains an invalid version specification, this returns
false
.Changed in version 1.0.0: Previously, an invalid server version would cause an exception.
-
file_list
= 'filelist.txt'¶
-
process_code_running
¶ Property indicating whether the user code is running
To see if the process has started, please use
Launcher.process_is_alive()
. Note that the process needs to initialize itself before it can run user code.
-
process_exitcode
¶ Property indicating the process exitcode, if it exists
-
process_is_alive
¶ Property indicating whether the process is alive
To see if user code is running, please use
Launcher.process_code_running()
. Note that the process needs to initialize itself before it can run user code.
-
process_pid
¶ Property indicating the process PID, if it exists
-
process_terminate
()[source]¶ Terminates the process.
Warning
All the provisos of
multiprocessing.Process.terminate()
apply.Attempts are made in the code to ensure that internal variables inside the Launcher class are properly cleaned up. However, there is little protection for user supplied code in case of termination.
Returns: Whether process was terminated Return type: bool
-
queue_update
= '.queue'¶
-
run
(background=False)[source]¶ Runs the user code.
If background is
False
, returns the Process’s exitcode.Parameters: background (bool) – Whether to run code in background Returns: the exit code if background is False
Return type: int
orNone
-
update_code
()[source]¶ Updates the code if necessary.
Returns: Whether update succeeded Return type: bool
-
updatedir
= '.pyautodownloads'¶
-
version_check_log
= 'version_check.log'¶
-
version_doc
= 'version.txt'¶
-