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.pyfile (ie:pharmaship.inventory.import_data)inside this file, a
DataImportclassthis class must have an
updatemethod
- The package to import must:
be an armored GPG-signed file
be a tar file
a
package.yamlfile conform to theschemas/package.jsonschemaa
MANIFESTfile withsha256checksums of all files inside the package
DataImportclass 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.yamlfileThe
package.yamlfile is conform to the schemaThe modules concerned by the update are installed in Pharmaship
Tar file is stored in
self.archiveproperty.Configuration from
package.yamlis stored inself.confproperty.- Returns
Trueif the package is conform,Falseotherwise.- Return type
-
check_signature()¶ Check the signature of the package.
Decoded data is stored in
self.dataproperty.- Returns
Trueif the signature is correct,Falseotherwise.- Return type
-
deploy()¶ Propagate the import to concerned modules.
For each module listed in the configuration, the import class
update()method is called.- Returns
Trueif all updates are applied correctly,Falseotherwise- 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.contentproperty.
-
pharmaship.core.import_data.check_integrity(tar_file)¶ Check the files listed in the
MANIFESTand their checksum.- Parameters
tar_file (tarfile.Tarfile) – The tar file to check
- Returns
Trueif 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
MANIFESTinformation 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,
Falseotherwise.- Return type
DataImport or bool