MCPcopy
hub / github.com/saltstack/salt / _query_http

Method _query_http

salt/spm/__init__.py:661–703  ·  view source on GitHub ↗

Download files via http

(self, dl_path, repo_info, decode_body=True)

Source from the content-addressed store, hash-verified

659 callback(repo, repo_data[repo])
660
661 def _query_http(self, dl_path, repo_info, decode_body=True):
662 """
663 Download files via http
664 """
665 query = None
666 response = None
667
668 try:
669 if "username" in repo_info:
670 try:
671 if "password" in repo_info:
672 query = http.query(
673 dl_path,
674 text=True,
675 username=repo_info["username"],
676 password=repo_info["password"],
677 decode_body=decode_body,
678 )
679 else:
680 raise SPMException(
681 "Auth defined, but password is not set for username: '{}'".format(
682 repo_info["username"]
683 )
684 )
685 except SPMException as exc:
686 self.ui.error(str(exc))
687 else:
688 query = http.query(dl_path, text=True, decode_body=decode_body)
689 except SPMException as exc:
690 self.ui.error(str(exc))
691
692 try:
693 if query:
694 if "SPM-METADATA" in dl_path:
695 response = salt.utils.yaml.safe_load(query.get("text", "{}"))
696 else:
697 response = query.get("text")
698 else:
699 raise SPMException("Response is empty, please check for Errors above.")
700 except SPMException as exc:
701 self.ui.error(str(exc))
702
703 return response
704
705 def _download_repo_metadata(self, args):
706 """

Callers 2

_installMethod · 0.95
_update_metadataMethod · 0.95

Calls 5

SPMExceptionClass · 0.85
queryMethod · 0.80
formatMethod · 0.80
errorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected