eric7.MicroPython.MipLocalInstaller

Module implementing a MicroPython package installer for devices missing the onboard 'mip' package.

Global Attributes

MicroPythonPackageIndex

Classes

MipLocalInstaller Class implementing a MicroPython package installer ('mip' replacement).

Functions

None


MipLocalInstaller

Class implementing a MicroPython package installer ('mip' replacement).

Derived from

QObject

Class Attributes

None

Class Methods

None

Methods

MipLocalInstaller Constructor
__getFile Private method to download the requested file.
__installFile Private method to download a file and copy the data to the given target directory.
__installJson Private method to install a package and its dependencies as defined by the package JSON file.
__rewriteUrl Private method to rewrite the given URL in case of a Github URL.
errorString Public method to get the last error as a string.
installPackage Public method to install a MicroPython package.

Static Methods

None

MipLocalInstaller (Constructor)

MipLocalInstaller(device, parent=None)

Constructor

device (BaseDevice)
reference to the connected device
parent (QObject (optional))
reference to the parent object (defaults to None)

MipLocalInstaller.__getFile

__getFile(fileUrl)

Private method to download the requested file.

fileUrl (QUrl)
URL of the requested file
Return:
package data or an error message and a success flag
Return Type:
tuple of (bytes or str, bool)

MipLocalInstaller.__installFile

__installFile(fileUrl, targetDir, targetFile)

Private method to download a file and copy the data to the given target directory.

fileUrl (str)
URL of the file to be downloaded and installed
targetDir (str)
target directory on the device
targetFile (str)
file name on the device
Return:
flag indicating success
Return Type:
bool

MipLocalInstaller.__installJson

__installJson(packageJson, version, mpy, target, index)

Private method to install a package and its dependencies as defined by the package JSON file.

packageJson (dict)
dictionary containing the package data
version (str)
package version
mpy (bool)
flag indicating to install as '.mpy' file
target (str)
target directory on the device
index (str)
URL of the package index to be used
Return:
flag indicating success
Return Type:
bool

MipLocalInstaller.__rewriteUrl

__rewriteUrl(url, branch=None)

Private method to rewrite the given URL in case of a Github URL.

url (str)
URL to be checked and potentially changed
branch (str (optional))
branch name (defaults to None)
Return:
rewritten URL
Return Type:
str

MipLocalInstaller.errorString

errorString()

Public method to get the last error as a string.

Return:
latest error
Return Type:
str

MipLocalInstaller.installPackage

installPackage(package, index=None, target=None, version=None, mpy=True)

Public method to install a MicroPython package.

package (str)
package name
index (str (optional))
URL of the package index to be used (defaults to None)
target (str (optional))
target directory on the device (defaults to None)
version (str (optional))
package version (defaults to None)
mpy (bool (optional))
flag indicating to install as '.mpy' file (defaults to True)
Return:
flag indicating success
Return Type:
bool
Up