pharmaship.core.import_data¶
Import package utilities.
-
class
pharmaship.core.import_data.
Importer
¶ Class used to import a data file in Pharmaship.
- The modules available for importation must have:
an
import_data.py
file (ie:pharmaship.inventory.import_data
)inside this file, a
DataImport
classthis class must have an
update
method
- The package to import must:
be an armored GPG-signed file
be a tar file
a
package.yaml
file conform to theschemas/package.json
schemaa
MANIFEST
file withsha256
checksums of all files inside the package
DataImport
class must have the follwing arguments:tar
- the tar file of the packageconf
- the configuration of the package (frompackage.yaml
)key
- for the GPG key ID used to sign the package
- Example
>>> from pharmaship.core.import_data import Importer >>> my_importer = Importer() >>> my_importer.read_package("my/path/archive.tar.asc") True >>> my_importer.check_signature() True >>> my_importer.check_conformity() True >>> my_importer.deploy() True
-
check_conformity
()¶ Check the package is importable in Pharmaship.
- What is checked:
The package is a valid tar file
The package has a
package.yaml
fileThe
package.yaml
file is conform to the schemaThe modules concerned by the update are installed in Pharmaship
Tar file is stored in
self.archive
property.Configuration from
package.yaml
is stored inself.conf
property.- Returns
True
if the package is conform,False
otherwise.- Return type
-
check_signature
()¶ Check the signature of the package.
Decoded data is stored in
self.data
property.- Returns
True
if the signature is correct,False
otherwise.- Return type
-
deploy
()¶ Propagate the import to concerned modules.
For each module listed in the configuration, the import class
update()
method is called.- Returns
True
if all updates are applied correctly,False
otherwise- Return type
-
read_package
(filename)¶ Read the package content.
It is normally an armored PGP file with signature. The signed file contains a Tar file.
Content is stored in
self.content
property.
-
pharmaship.core.import_data.
check_integrity
(tar_file)¶ Check the files listed in the
MANIFEST
and their checksum.- Parameters
tar_file (tarfile.Tarfile) – The tar file to check
- Returns
True
if the content is conform to the MANIFEST.- Return type
-
pharmaship.core.import_data.
check_tarfile
(data)¶ Check that the data input is a valid Tar file.
- Parameters
data (bytes) – binary string issued from GPG armor decoding containing a tar file.
- Returns
A Tarfile object.
- Return type
-
pharmaship.core.import_data.
extract_manifest
(manifest_descriptor)¶ Extract the
MANIFEST
information and put it into a list of dict.
-
pharmaship.core.import_data.
load_module
(module)¶ Load import_data submodule if existing.
- Parameters
module (str) – parent module for importing
import_data
.- Returns
The DataImport class of the selected module if any,
False
otherwise.- Return type
DataImport or bool