コード例 #1
0
            query = urllib.parse.urlencode(query)
            path = path + "?" + query
        return path

    @staticmethod
    def quote(value):
        """Quote value for use in a URL"""
        return urllib.parse.quote(value)

    @staticmethod
    def raise_not_found(exc, response, exception_type=errors.ImageNotFound):
        """helper function to raise a not found exception of exception_type"""
        body = json.loads(response.read())
        logging.info(body["cause"])
        raise exception_type(body["message"]) from exc

    def __exit__(self, exc_type, exc_value, traceback):
        super().close()


if __name__ == "__main__":  # pragma: no cover
    with ApiConnection("unix:///run/podman/podman.sock") as api:
        print(system.version(api))
        print(images.list_images(api))
        print(containers.list_containers(api))

        try:
            images.inspect(api, "bozo the clown")
        except errors.ImageNotFound as e:
            print(e)
コード例 #2
0
ファイル: test_system.py プロジェクト: simhaonline/podman-py
 def test_version(self):
     """integration: system version call"""
     output = system.version(self.api)
     self.assertTrue('Platform' in output)
     self.assertTrue('Version' in output)
     self.assertTrue('ApiVersion' in output)