Skip to content

Commit ec4e238

Browse files
committed
fix size convert
1 parent 4f35451 commit ec4e238

File tree

8 files changed

+34
-10
lines changed

8 files changed

+34
-10
lines changed

OCLP-R-GUI.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ datas = [
2525
if Path("HackdocInternalResources.dmg").exists():
2626
datas.append(('HackdocInternalResources.dmg', '.'))
2727

28-
2928
a = Analysis(['OCLP-R-GUI.command'],
3029
pathex=[],
3130
binaries=[],
@@ -85,3 +84,4 @@ app = BUNDLE(coll,
8584
"NSPrincipalClass": "NSApplication",
8685
"CFBundleIconName": "oclp",
8786
})
87+

oclp_r/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,4 +891,4 @@ def icons_path(self):
891891
"Mac-942B59F58194171B", # iMac12,2
892892
"Mac-94245AF5819B141B", # AppleInternal MacBookPro8,3
893893
"Mac-942B5B3A40C91381", # AppleInternal iMac12,2
894-
]
894+
]

oclp_r/support/kdk_handler.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, global_constants: constants.Constants,
7474
self.kdk_url: str = ""
7575
self.kdk_url_build: str = ""
7676
self.kdk_url_version: str = ""
77-
77+
self.size=0
7878
self.kdk_url_expected_size: int = 0
7979

8080
self.kdk_url_is_exactly_match: bool = False
@@ -259,7 +259,12 @@ def _get_latest_kdk(self, host_build: str = None, host_version: str = None) -> N
259259

260260
self.success = True
261261

262-
262+
def convert_size(self, size_str):
263+
units = {'KB': 1024, 'MB': 1024**2, 'GB': 1024**3, 'TB': 1024**4}
264+
for unit, factor in units.items():
265+
if unit in size_str:
266+
return float(size_str.replace(unit, '')) * factor
267+
return float(size_str)
263268
def retrieve_download(self, override_path: str = "") -> network_handler.DownloadObject:
264269
"""
265270
Returns a DownloadObject for the KDK
@@ -283,15 +288,19 @@ def retrieve_download(self, override_path: str = "") -> network_handler.Download
283288
self.error_msg = "Could not retrieve KDK catalog, no KDK to download"
284289
logging.error(self.error_msg)
285290
return None
286-
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"])
287296
logging.info(f"Returning DownloadObject for KDK: {Path(self.kdk_url).name}")
288297
self.success = True
289298

290299
kdk_download_path = self.constants.kdk_download_path if override_path == "" else Path(override_path)
291300
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}")
292301

293302
self._generate_kdk_info_plist(kdk_plist_path)
294-
return network_handler.DownloadObject(self.kdk_url, kdk_download_path)
303+
return network_handler.DownloadObject(self.kdk_url, kdk_download_path,self.size)
295304

296305

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

oclp_r/sys_patch/patchsets/hardware/misc/Launch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def _modern_audio_patches(self) -> dict:
6666
},
6767
"/System/Applications": {
6868
"Apps.app": f"{self._constants.launchpad_version}",
69-
"Launchpad.app": f"{self._constants.launchpad_version}",
7069
},
7170
},
7271
},

oclp_r/wx_gui/gui_sys_patch_start.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Con
5555

5656
if self.patches == {}:
5757
self.patches = HardwarePatchsetDetection(constants=self.constants).device_properties
58-
58+
def convert_size(self, size_str):
59+
units = {'KB': 1024, 'MB': 1024**2, 'GB': 1024**3, 'TB': 1024**4}
60+
for unit, factor in units.items():
61+
if unit in size_str:
62+
return float(size_str.replace(unit, '')) * factor
63+
return float(size_str)
5964

6065
def _kdk_download(self, frame: wx.Frame = None) -> bool:
6166
frame = self if not frame else frame
@@ -79,7 +84,7 @@ def _kdk_download(self, frame: wx.Frame = None) -> bool:
7984
# Set size of frame
8085
frame.SetSize((-1, progress_bar.GetPosition()[1] + progress_bar.GetSize()[1] + 35))
8186
frame.Show()
82-
87+
8388
# Generate KDK object
8489
self.kdk_obj: kdk_handler.KernelDebugKitObject = None
8590
def _kdk_thread_spawn():
@@ -100,7 +105,7 @@ def _kdk_thread_spawn():
100105
if not kdk_download_obj:
101106
# KDK is already downloaded
102107
return True
103-
108+
104109
gui_download.DownloadFrame(
105110
self,
106111
title=self.title,
1.57 MB
Binary file not shown.

payloads/Icon/AppIcons/Assets.car

1.53 MB
Binary file not shown.

test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
a=[
2+
{
3+
"build":"1",
4+
},
5+
{
6+
"build":"2",
7+
},
8+
{
9+
"build":"3",
10+
},
11+
]

0 commit comments

Comments
 (0)