Example #1
0
def download(url, output_path, no_progress):
    response = requests.get(url, stream=True)
    streamed_response = client.StreamedResponse(response)
    progress_handler = None
    if not no_progress:
        progress_handler = generate_progress_handler(output_path)
    bytes_stream_utils.write_response_stream_to_file(
        buffer_size=constants.BUFFER_SIZE,
        streamed_response=streamed_response,
        output_file=output_path,
        progress_callback=progress_handler)
    def download(self, plugin_id, output_file):
        """
        Downloads a previously uploaded plugin archive from the
        Cloudify manager.
        :param plugin_id: The plugin ID of the plugin to be downloaded.
        :param output_file: The file path of the downloaded plugin file
        :return: The file path of the downloaded plugin.
        """
        assert plugin_id
        uri = '/plugins/{0}/archive'.format(plugin_id)
        with contextlib.closing(self.api.get(uri, stream=True)) as response:
            output_file = bytes_stream_utils.write_response_stream_to_file(
                response, output_file)

            return output_file
Example #3
0
    def download_yaml(self, plugin_id, output_file, progress_callback=None):
        """Downloads a previously uploaded plugin archive from the manager

        :param plugin_id: The plugin ID of the plugin yaml to be downloaded.
        :param output_file: The file path of the downloaded plugin yaml file
        :param progress_callback: Callback function - can be used to print
        a progress bar
        :return: The file path of the downloaded plugin yaml.
        """
        uri = '/plugins/{0}/yaml'.format(plugin_id)
        with contextlib.closing(self.api.get(uri, stream=True)) as response:
            output_file = bytes_stream_utils.write_response_stream_to_file(
                response, output_file, progress_callback=progress_callback)

            return output_file
Example #4
0
    def download(self, log_bundle_id, output_file, progress_callback=None):
        """Downloads a previously created log bundle from a manager.
        :param log_bundle_id: The id of the log bundle to be downloaded.
        :param progress_callback: Callback function for printing a progress bar
        :param output_file: The file path of the downloaded log bundle file
         (optional)
        :return: The file path of the downloaded log bundle.
        """
        uri = self.base_url + '{}/archive'.format(log_bundle_id)

        with contextlib.closing(self.api.get(uri, stream=True)) as response:
            output_file = bytes_stream_utils.write_response_stream_to_file(
                response, output_file, progress_callback=progress_callback)

            return output_file
    def download(self, plugin_id, output_file, progress_callback=None):
        """Downloads a previously uploaded plugin archive from the manager

        :param plugin_id: The plugin ID of the plugin to be downloaded.
        :param output_file: The file path of the downloaded plugin file
        :param progress_callback: Callback function - can be used to print
        a progress bar
        :return: The file path of the downloaded plugin.
        """
        assert plugin_id
        uri = '/plugins/{0}/archive'.format(plugin_id)
        with contextlib.closing(self.api.get(uri, stream=True)) as response:
            output_file = bytes_stream_utils.write_response_stream_to_file(
                response, output_file, progress_callback=progress_callback)

            return output_file
    def download(self,
                 plugin_id,
                 output_file):
        """
        Downloads a previously uploaded plugin archive from the
        Cloudify manager.
        :param plugin_id: The plugin ID of the plugin to be downloaded.
        :param output_file: The file path of the downloaded plugin file
        :return: The file path of the downloaded plugin.
        """
        assert plugin_id
        uri = '/plugins/{0}/archive'.format(plugin_id)
        with contextlib.closing(self.api.get(uri, stream=True)) as response:
            output_file = bytes_stream_utils.write_response_stream_to_file(
                response, output_file)

            return output_file
Example #7
0
    def download(self, snapshot_id, output_file):
        """
        Downloads a previously created/uploaded snapshot archive from
        Cloudify's manager.

        :param snapshot_id: The id of the snapshot to be downloaded.
        :param output_file: The file path of the downloaded snapshot file
         (optional)
        :return: The file path of the downloaded snapshot.
        """
        uri = '/snapshots/{0}/archive'.format(snapshot_id)

        with contextlib.closing(self.api.get(uri, stream=True)) as response:
            output_file = bytes_stream_utils.write_response_stream_to_file(
                response, output_file)

            return output_file
    def download(self, snapshot_id, output_file):
        """
        Downloads a previously created/uploaded snapshot archive from
        Cloudify's manager.

        :param snapshot_id: The id of the snapshot to be downloaded.
        :param output_file: The file path of the downloaded snapshot file
         (optional)
        :return: The file path of the downloaded snapshot.
        """
        uri = '/snapshots/{0}/archive'.format(snapshot_id)

        with contextlib.closing(self.api.get(uri, stream=True)) as response:
            output_file = bytes_stream_utils.write_response_stream_to_file(
                response, output_file)

            return output_file
    def download(self, blueprint_id, output_file=None):
        """
        Downloads a previously uploaded blueprint from Cloudify's manager.

        :param blueprint_id: The Id of the blueprint to be downloaded.
        :param output_file: The file path of the downloaded blueprint file
         (optional)
        :return: The file path of the downloaded blueprint.
        """
        uri = '/blueprints/{0}/archive'.format(blueprint_id)

        with contextlib.closing(
                self.api.get(uri, stream=True)) as streamed_response:

            output_file = bytes_stream_utils.write_response_stream_to_file(
                streamed_response, output_file)

            return output_file
    def download(self, blueprint_id, output_file=None):
        """
        Downloads a previously uploaded blueprint from Cloudify's manager.

        :param blueprint_id: The Id of the blueprint to be downloaded.
        :param output_file: The file path of the downloaded blueprint file
         (optional)
        :return: The file path of the downloaded blueprint.
        """
        uri = '/blueprints/{0}/archive'.format(blueprint_id)

        with contextlib.closing(self.api.get(
                uri, stream=True)) as streamed_response:

            output_file = bytes_stream_utils.write_response_stream_to_file(
                streamed_response, output_file)

            return output_file
Example #11
0
    def download(self, blueprint_id, output_file=None, progress_callback=None):
        """
        Downloads a previously uploaded blueprint from Cloudify's manager.

        :param blueprint_id: The Id of the blueprint to be downloaded.
        :param progress_callback: Callback function for printing a progress bar
        :param output_file: The file path of the downloaded blueprint file
         (optional)
        :return: The file path of the downloaded blueprint.
        """
        uri = '/{self._uri_prefix}/{id}/archive'.format(self=self,
                                                        id=blueprint_id)

        with contextlib.closing(self.api.get(
                uri, stream=True)) as streamed_response:

            output_file = bytes_stream_utils.write_response_stream_to_file(
                streamed_response,
                output_file,
                progress_callback=progress_callback)

            return output_file
    def download(self, blueprint_id, output_file=None, progress_callback=None):
        """
        Downloads a previously uploaded blueprint from Cloudify's manager.

        :param blueprint_id: The Id of the blueprint to be downloaded.
        :param progress_callback: Callback function for printing a progress bar
        :param output_file: The file path of the downloaded blueprint file
         (optional)
        :return: The file path of the downloaded blueprint.
        """
        uri = '/{self._uri_prefix}/{id}/archive'.format(self=self,
                                                        id=blueprint_id)

        with contextlib.closing(
                self.api.get(uri, stream=True)) as streamed_response:

            output_file = bytes_stream_utils.write_response_stream_to_file(
                streamed_response,
                output_file,
                progress_callback=progress_callback)

            return output_file