Download the pack and move it to /opt/stackstorm/packs. :param abs_repo_base: Path where the pack should be installed to. :type abs_repo_base: ``str`` :param pack: Pack name. :rtype pack: ``str`` :param force_owner_group: Set owner group of the pack directory to the value
(
pack,
abs_repo_base="/opt/stackstorm/packs",
verify_ssl=True,
force=False,
proxy_config=None,
force_owner_group=True,
force_permissions=True,
logger=LOG,
)
| 75 | |
| 76 | |
| 77 | def download_pack( |
| 78 | pack, |
| 79 | abs_repo_base="/opt/stackstorm/packs", |
| 80 | verify_ssl=True, |
| 81 | force=False, |
| 82 | proxy_config=None, |
| 83 | force_owner_group=True, |
| 84 | force_permissions=True, |
| 85 | logger=LOG, |
| 86 | ): |
| 87 | """ |
| 88 | Download the pack and move it to /opt/stackstorm/packs. |
| 89 | |
| 90 | :param abs_repo_base: Path where the pack should be installed to. |
| 91 | :type abs_repo_base: ``str`` |
| 92 | |
| 93 | :param pack: Pack name. |
| 94 | :rtype pack: ``str`` |
| 95 | |
| 96 | :param force_owner_group: Set owner group of the pack directory to the value defined in the |
| 97 | config. |
| 98 | :type force_owner_group: ``bool`` |
| 99 | |
| 100 | :param force_permissions: True to force 770 permission on all the pack content. |
| 101 | :type force_permissions: ``bool`` |
| 102 | |
| 103 | :param force: Force the installation and ignore / delete the lock file if it already exists. |
| 104 | :type force: ``bool`` |
| 105 | |
| 106 | :return: (pack_url, pack_ref, result) |
| 107 | :rtype: tuple |
| 108 | """ |
| 109 | proxy_config = proxy_config or {} |
| 110 | |
| 111 | try: |
| 112 | pack_url, pack_version = get_repo_url(pack, proxy_config=proxy_config) |
| 113 | except Exception as e: |
| 114 | # Pack not found or similar |
| 115 | result = [None, pack, (False, six.text_type(e))] |
| 116 | return result |
| 117 | |
| 118 | result = [pack_url, None, None] |
| 119 | |
| 120 | temp_dir_name = hashlib.md5( |
| 121 | pack_url.encode(), **hashlib_kwargs |
| 122 | ).hexdigest() # nosec. remove nosec after py3.8 drop |
| 123 | lock_file = LockFile("/tmp/%s" % (temp_dir_name)) |
| 124 | lock_file_path = lock_file.lock_file |
| 125 | |
| 126 | if force: |
| 127 | logger.debug("Force mode is enabled, deleting lock file...") |
| 128 | |
| 129 | try: |
| 130 | os.unlink(lock_file_path) |
| 131 | except OSError: |
| 132 | # Lock file doesn't exist or similar |
| 133 | pass |
| 134 |
no test coverage detected