Skip to content

Commit d98901c

Browse files
committed
fix kdk handler bugs
1 parent ac5d580 commit d98901c

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

oclp_r/support/kdk_handler.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,24 +283,18 @@ def retrieve_download(self, override_path: str = "") -> network_handler.Download
283283
logging.info("No download required, KDK already installed")
284284
self.success = True
285285
return None
286-
287286
if self.kdk_url == "":
288287
self.error_msg = "Could not retrieve KDK catalog, no KDK to download"
289288
logging.error(self.error_msg)
290289
return None
291-
re=requests.get(self.kdk_url)
292-
json=re.json()
293-
for i in json:
294-
if i["build"]==self.kdk_url_build:
295-
self.size=self.convert_size(i["fileSize"])
296290
logging.info(f"Returning DownloadObject for KDK: {Path(self.kdk_url).name}")
297291
self.success = True
298292

299293
kdk_download_path = self.constants.kdk_download_path if override_path == "" else Path(override_path)
300294
kdk_plist_path = Path(f"{kdk_download_path.parent}/{KDK_INFO_PLIST}") if override_path == "" else Path(f"{Path(override_path).parent}/{KDK_INFO_PLIST}")
301295

302296
self._generate_kdk_info_plist(kdk_plist_path)
303-
return network_handler.DownloadObject(self.kdk_url, kdk_download_path,self.size)
297+
return network_handler.DownloadObject(self.kdk_url, kdk_download_path)
304298

305299

306300
def _generate_kdk_info_plist(self, plist_path: str) -> None:

oclp_r/support/network_handler.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ def _get_filename(self) -> str:
261261
return Path(self.url).name
262262

263263
def convert_size(self, size_str):
264+
if isinstance(size_str, float):
265+
return float(size_str)
266+
if isinstance(size_str, int):
267+
return float(size_str)
268+
264269
units = {'KB': 1024, 'MB': 1024**2, 'GB': 1024**3, 'TB': 1024**4}
265270
for unit, factor in units.items():
266271
if unit in size_str:
@@ -354,7 +359,7 @@ def _download(self, display_progress: bool = False) -> None:
354359
if self._prepare_working_directory(self.filepath) is False:
355360
raise Exception(self.error_msg)
356361

357-
response = NetworkUtilities().get(self.url, stream=True, timeout=10)
362+
response = NetworkUtilities().get(self.url, stream=True, timeout=100)
358363

359364
with open(self.filepath, 'wb') as file:
360365
atexit.register(self.stop)
@@ -437,7 +442,6 @@ def get_file_size(self) -> float:
437442
Returns:
438443
float: The file size in bytes, or 0.0 if unknown
439444
"""
440-
441445
return self.total_file_size
442446

443447

oclp_r/wx_gui/gui_kdk_dl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ def is_dir_writable(dirpath):
268268
file_name = selected_installer['name']+".dmg"
269269
self.frame_modal.Close()
270270
self.path_validate=self.constants.user_download_file+"/"+file_name
271-
size=selected_installer['fileSize']
272-
download_obj = network_handler.DownloadObject(selected_installer['url'], self.constants.user_download_file+"/"+file_name,self.convert_size(size))
271+
size=int(selected_installer['fileSize'])
272+
download_obj = network_handler.DownloadObject(selected_installer['url'], self.constants.user_download_file+"/"+file_name,size)
273273
gui_download.DownloadFrame(
274274
self,
275275
title=self.title,

0 commit comments

Comments
 (0)