threedi / hhnk-threedi-tools

1 stars 0 forks source link

downloaden werkt niet in jupyterlab wel in vs-code #102

Open wvangerwen opened 3 months ago

wvangerwen commented 3 months ago

Reproduce: Voor callantsoog notebook server starten met de plugin Downloader, reivisie 9, download wdept op 25m.

image

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
File d:\github\wvangerwen\hhnk-threedi-tools\hhnk_threedi_tools\core\api\download_gui_class.py:752, in DownloadWidgetsInteraction.__init__.<locals>.download(action)
    746     self.vars.dl_raster_settings = dl_raster_settings
    747     logging_batch_path = os.path.join(
    748         output_folder,
    749         "download_raster_batch_{}.csv".format(datetime.datetime.now().strftime("%Y-%m-%d %Hh%M")),
    750     )
--> 752     dl.download_raster(
    753         scenario=dl_raster_settings.scenario_uuid_list,
    754         raster_code=dl_raster_settings.raster_code_list,
    755         projection=dl_raster_settings.projection_list,
    756         resolution=dl_raster_settings.resolution_list,
    757         bbox=dl_raster_settings.bbox_list,
    758         time=dl_raster_settings.time_list,
    759         pathname=dl_raster_settings.pathname_list,
    760         export_task_csv=logging_batch_path,
    761     )
    763     print("Download of rasters finished")
    765 # Re enable download button

File ~\AppData\Roaming\3Di\QGIS3\profiles\default\python\plugins\hhnk_threedi_plugin\external-dependencies\threedi_scenario_downloader\downloader.py:462, in download_raster(scenario, raster_code, projection, resolution, bbox, time, pathname, is_threedi_scenario, export_task_csv)
    458     logging.debug(
    459         "Task succeeded, start downloading url: {}".format(get_task_download_url(task_uuid))
    460     )
    461     logging.debug("Remaining tasks: {}".format(processed_list.count(False) - 1))
--> 462     download_task(task_uuid, pathname)
    463     processed_list[index] = True
    465 except HTTPError as err:

File ~\AppData\Roaming\3Di\QGIS3\profiles\default\python\plugins\hhnk_threedi_plugin\external-dependencies\threedi_scenario_downloader\downloader.py:308, in download_task(task_uuid, pathname)
    306     pathname = os.path.basename(urlparse(download_url).path)
    307     logging.debug(pathname)
--> 308 download_file(download_url, pathname)

File ~\AppData\Roaming\3Di\QGIS3\profiles\default\python\plugins\hhnk_threedi_plugin\external-dependencies\threedi_scenario_downloader\downloader.py:293, in download_file(url, path)
    291 logging.debug("Start downloading file: {}".format(url))
    292 r = requests.get(url, auth=("__key__", get_api_key()), stream=True)
--> 293 r.raise_for_status()
    294 with open(path, "wb") as file:
    295     for chunk in r.iter_content(1024 * 1024 * 10):

File C:\PROGRA~1\3DIMOD~1.34\apps\Python39\lib\site-packages\requests\models.py:941, in Response.raise_for_status(self)
    938     http_error_msg = u'%s Server Error: %s for url: %s' % (self.status_code, reason, self.url)
    940 if http_error_msg:
--> 941     raise HTTPError(http_error_msg, response=self)

HTTPError: 400 Client Error: Bad Request for url: FAKEURL

De url werkt wel gewoon, hier even weg gehaald ivm access code.

Logger uitlezen in de output gaat ook niet helemaal lekker. werkt wel in vs-code

import sys
import logging
import threedi_scenario_downloader

logger = logging.getLogger("threedi_scenario_downloader")

logger.setLevel("DEBUG")
# add handler for console printing
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)

file_hand = logging.FileHandler(
    r"E:\02.modellen\callantsoog\03_3di_results\1d2d_results\callantsoog #9 1d2d_test\log.txt"
)

logger.addHandler(file_hand)
logger.addHandler(handler)