Esempio n. 1
0
    def test_download_url(self):
        """Test we can download a zip. Uses a mock network stack."""
        myManager = QNetworkAccessManager(PARENT)

        # NOTE(gigih):
        # this is the hash of google front page.
        # I think we can safely assume that the content
        # of google.com never changes (probably).
        #
        myHash = 'd4b691cd9d99117b2ea34586d3e7eeb8'
        myUrl = 'http://google.com'
        myTempFilePath = tempfile.mktemp()

        download_url(myManager, myUrl, myTempFilePath)

        assert_hash_for_file(myHash, myTempFilePath)
Esempio n. 2
0
    def test_download_url(self):
        """Test we can download a zip. Uses a mock network stack."""
        myManager = QNetworkAccessManager(PARENT)

        # NOTE(gigih):
        # this is the hash of google front page.
        # I think we can safely assume that the content
        # of google.com never changes (probably).
        #
        myHash = 'd4b691cd9d99117b2ea34586d3e7eeb8'
        myUrl = 'http://google.com'
        myTempFilePath = tempfile.mktemp()

        download_url(myManager, myUrl, myTempFilePath)

        assert_hash_for_file(myHash, myTempFilePath)
Esempio n. 3
0
    def fetch_zip(self, url, output_path):
        """Download zip containing shp file and write to output_path.

        :param url: URL of the zip bundle.
        :type url: str

        :param output_path: Path of output file,
        :type output_path: str

        :raises: ImportDialogError - when network error occurred
        """

        self.progressDialog.show()
        self.progressDialog.setMaximum(100)
        self.progressDialog.setValue(0)

        # myLabelText = "Begin downloading shapefile from " \
        #               + "%s ..."
        # self.progressDialog.setLabelText(self.tr(myLabelText) % (url))
        myLabelText = self.tr("Downloading shapefile")
        self.progressDialog.setLabelText(myLabelText)

        myResult = download_url(
            self.network_manager, url, output_path,
            self.progressDialog)

        if myResult is not True:
            _, myErrorMessage = myResult
            raise ImportDialogError(myErrorMessage)
Esempio n. 4
0
    def fetch_zip(self, url, output_path):
        """Download zip containing shp file and write to output_path.

        :param url: URL of the zip bundle.
        :type url: str

        :param output_path: Path of output file,
        :type output_path: str

        :raises: ImportDialogError - when network error occurred
        """
        LOGGER.debug('Downloading file from URL: %s' % url)
        LOGGER.debug('Downloading to: %s' % output_path)

        self.progress_dialog.show()
        self.progress_dialog.setMaximum(100)
        self.progress_dialog.setValue(0)

        # label_text = "Begin downloading shapefile from " \
        #               + "%s ..."
        # self.progress_dialog.setLabelText(self.tr(label_text) % (url))
        label_text = self.tr("Downloading shapefile")
        self.progress_dialog.setLabelText(label_text)

        result = download_url(
            self.network_manager, url, output_path,
            self.progress_dialog)

        if result[0] is not True:
            _, error_message = result
            raise ImportDialogError(error_message)
Esempio n. 5
0
    def test_download_url(self):
        """Test we can download a zip. Uses a mock network stack."""
        manager = QNetworkAccessManager(PARENT)

        # NOTE(gigih):
        # this is the hash of google front page.
        # I think we can safely assume that the content
        # of google.com never changes (probably).
        # ...or not...changed on 5 Dec 2013 by Tim to hash below...
        unique_hash = 'd4b691cd9d99117b2ea34586d3e7eeb8'
        url = 'http://google.com'
        path = tempfile.mktemp()

        download_url(manager, url, path)

        assert_hash_for_file(unique_hash, path)
    def test_download_url(self):
        """Test we can download a zip. Uses a mock network stack."""
        manager = QNetworkAccessManager(PARENT)

        # NOTE(gigih):
        # this is the hash of google front page.
        # I think we can safely assume that the content
        # of google.com never changes (probably).
        # ...or not...changed on 5 Dec 2013 by Tim to hash below...
        unique_hash = 'd4b691cd9d99117b2ea34586d3e7eeb8'
        url = 'http://google.com'
        path = tempfile.mktemp()

        download_url(manager, url, path)

        assert_hash_for_file(unique_hash, path)
Esempio n. 7
0
    def fetch_zip(self, url, output_path):
        """Download zip containing shp file and write to output_path.

        :param url: URL of the zip bundle.
        :type url: str

        :param output_path: Path of output file,
        :type output_path: str

        :raises: ImportDialogError - when network error occurred
        """

        self.progressDialog.show()
        self.progressDialog.setMaximum(100)
        self.progressDialog.setValue(0)

        # myLabelText = "Begin downloading shapefile from " \
        #               + "%1 ..."
        # self.progressDialog.setLabelText(self.tr(myLabelText).arg(url))
        myLabelText = self.tr("Downloading shapefile")
        self.progressDialog.setLabelText(myLabelText)

        myResult = download_url(self.network_manager, url, output_path,
                                self.progressDialog)

        if myResult is not True:
            _, myErrorMessage = myResult
            raise ImportDialogError(myErrorMessage)