# under the License.
import glob
-import hashlib
import logging
import os
import shutil
from osm_im import im_translation
from osmclient.common import package_handling as package_handling
from osmclient.common.exceptions import ClientException
+from osmclient.common import utils
from .sol004_package import SOL004Package
from .sol007_package import SOL007Package
import yaml
self._logger.debug("")
# print("location: {}".format(osmclient.__path__))
file_loader = PackageLoader("osmclient")
- env = Environment(loader=file_loader)
+ env = Environment(loader=file_loader, autoscape=True)
if package_type == "ns":
template = env.get_template("nsd.yaml.j2" if not old else "nsd_old.yaml.j2")
content = {
for file_item in files:
if "checksums.txt" in file_item:
continue
- # from https://www.quickprogrammingtips.com/python/how-to-calculate-md5-hash-of-a-file-in-python.html
- md5_hash = hashlib.md5()
- with open(file_item, "rb") as f:
- # Read and update hash in chunks of 4K
- for byte_block in iter(lambda: f.read(4096), b""):
- md5_hash.update(byte_block)
- checksum.write("{}\t{}\n".format(md5_hash.hexdigest(), file_item))
+ checksum.write("{}\t{}\n".format(utils.md5(file_item), file_item))
def create_folders(self, folders, package_type):
"""