Skip to content

Commit e24b7c7

Browse files
committed
fix wrong version being fetched
1 parent 4492f1d commit e24b7c7

File tree

6 files changed

+120
-206
lines changed

6 files changed

+120
-206
lines changed

app/core.py

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import asyncio
22
import os
3+
import subprocess
34
import time
45
from datetime import datetime
56
from threading import Event
67

7-
import clr
88
from pypdl import Pypdl
99
from PyQt6.QtCore import QThreadPool
1010
from PyQt6.QtGui import QIcon
@@ -15,7 +15,6 @@
1515
from utls import Worker, default_logger
1616

1717
script_dir = os.path.dirname(os.path.abspath(__file__))
18-
clr.AddReference(rf"{script_dir}\data\System.Management.Automation.dll")
1918

2019

2120
class internal_func(Ui_MainProgram):
@@ -105,7 +104,7 @@ def log_error():
105104
current_time = datetime.now().strftime("[%d-%m-%Y %H:%M:%S]")
106105
f.write(f"[python logs] \n{current_time}\n\n")
107106
f.write(n[2])
108-
f.write(f'{82*"-"}\n')
107+
f.write(f"{82 * '-'}\n")
109108

110109
# if normal show a simple popup
111110
if normal:
@@ -322,58 +321,45 @@ async def new_url_gen():
322321
self.threadpool.start(worker)
323322

324323
def install(self, arg, **kwargs):
325-
# importing the system management.Automation dlls powershell funcs
326-
from System.Management.Automation import PowerShell
327-
328324
self.stop_btn.hide()
329325
self.pushButton.show()
330326

331327
def install_thread(path, progress_current, progress_main, uwp, val=True):
328+
def run(command):
329+
output = subprocess.run(
330+
[
331+
"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
332+
command,
333+
],
334+
creationflags=subprocess.CREATE_NO_WINDOW,
335+
capture_output=True,
336+
text=True,
337+
)
338+
return output
339+
332340
flag = 0
333341
main_prog_error = 0
334342
part = int((100 - self.mainprogressBar.value()) / len(path))
335343

336-
# helper func for getting progress from powershell
337-
def Progress(source, e):
338-
prog = int(source[e.Index].PercentComplete)
339-
# to remove -1 from the progress bar
340-
progress_current.emit(prog if prog > 0 else 0)
341-
if not val:
342-
progress_main.emit(prog if prog > 0 else 0)
343-
344-
# helper func for getting error from powershell
345-
def error(source, e):
346-
nonlocal flag, main_prog_error
347-
348-
flag = 1
349-
if path[s_path] == 1:
350-
main_prog_error = 1
351-
352-
with open(f"{script_dir}/log.txt", "a") as f:
353-
current_time = datetime.now().strftime("[%d-%m-%Y %H:%M:%S]")
354-
f.write(f"[powershell logs] \n{current_time}\n\n")
355-
f.write(f'Package Name: {s_path.split("/")[-1]}\n\n')
356-
f.write(str(source[e.Index].Exception.Message))
357-
f.write(f'{82*"-"}\n')
358-
359344
for s_path in path.keys():
360-
# C# command run using pythonnet via system.management.automation dll
361-
ps = PowerShell.Create()
362-
ps.Streams.Progress.DataAdded += Progress
363-
ps.Streams.Error.DataAdded += error
364-
345+
progress_current.emit(10)
365346
if uwp:
366-
ps.AddCommand("Add-AppxPackage")
367-
ps.AddParameter("Path", s_path)
347+
output = run(f'Add-AppPackage "{s_path}"')
368348
else:
369-
ps.AddCommand("Start-Process")
370-
ps.AddParameter("FilePath", s_path)
371-
372-
try:
373-
ps.Invoke()
374-
except Exception as e:
375-
print(e)
376-
349+
output = run(f'Start-Process "{s_path}"')
350+
351+
if not output.returncode == 0:
352+
flag = 1
353+
if path[s_path] == 1:
354+
main_prog_error = 1
355+
356+
with open(f"{script_dir}/log.txt", "a") as f:
357+
current_time = datetime.now().strftime("[%d-%m-%Y %H:%M:%S]")
358+
f.write(f"[powershell logs] \n{current_time}\n\n")
359+
f.write(f"command: {output.args[1]}\n\n")
360+
f.write(output.stderr)
361+
f.write(f"{82 * '-'}\n")
362+
progress_current.emit(100)
377363
time.sleep(0.3)
378364
progress_main.emit(part)
379365

@@ -391,7 +377,6 @@ def error(source, e):
391377
detail_msg += "if the app is not installed, Enable [Advanced --> Dependencies --> Ignore Version], "
392378
detail_msg += "If the problem still exists Enable [Advanced --> Dependencies --> Ignore All Filters]"
393379
endresult = (msg, detail_msg, "Warning")
394-
395380
return endresult
396381
return 0
397382

-2.87 MB
Binary file not shown.

app/data/xml/FE3FileUrl.xml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
1+
<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope"
2+
xmlns:a="http://www.w3.org/2005/08/addressing"
3+
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
24
<Header>
3-
<a:Action mustUnderstand="1">http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetExtendedUpdateInfo2</a:Action>
4-
<a:To mustUnderstand="1">https://fe3cr.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured</a:To>
5-
<Security mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
6-
<WindowsUpdateTicketsToken xmlns="http://schemas.microsoft.com/msus/2014/10/WindowsUpdateAuthorization" u:id="ClientMSA">
5+
<a:Action mustUnderstand="1">
6+
http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetExtendedUpdateInfo2</a:Action>
7+
<a:To mustUnderstand="1">
8+
https://fe3cr.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured</a:To>
9+
<Security mustUnderstand="1"
10+
xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
11+
<WindowsUpdateTicketsToken
12+
xmlns="http://schemas.microsoft.com/msus/2014/10/WindowsUpdateAuthorization"
13+
u:id="ClientMSA">
714
<!-- <TicketType Name="MSA" Version="1.0" Policy="MBI_SSL"><User/></TicketType> -->
815
</WindowsUpdateTicketsToken>
916
</Security>
1017
</Header>
1118
<Body>
12-
<GetExtendedUpdateInfo2 xmlns="http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService">
19+
<GetExtendedUpdateInfo2
20+
xmlns="http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService">
1321
<updateIDs>
1422
<UpdateIdentity>
1523
<UpdateID>{0}</UpdateID>
@@ -20,6 +28,7 @@
2028
<XmlUpdateFragmentType>FileUrl</XmlUpdateFragmentType>
2129
<XmlUpdateFragmentType>FileDecryption</XmlUpdateFragmentType>
2230
</infoTypes>
23-
<DeviceAttributes>FlightRing={2};</DeviceAttributes> </GetExtendedUpdateInfo2>
31+
<deviceAttributes>FlightRing={2};</deviceAttributes>
32+
</GetExtendedUpdateInfo2>
2433
</Body>
2534
</Envelope>

app/data/xml/WUIDRequest.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
xmlns:a="http://www.w3.org/2005/08/addressing"
33
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
44
<s:Header>
5-
<a:Action s:mustUnderstand="1">http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/SyncUpdates</a:Action>
5+
<a:Action s:mustUnderstand="1">
6+
http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/SyncUpdates</a:Action>
67
<a:MessageID>urn:uuid:175df68c-4b91-41ee-b70b-f2208c65438e</a:MessageID>
7-
<a:To s:mustUnderstand="1">https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx</a:To>
8+
<a:To s:mustUnderstand="1">
9+
https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx</a:To>
810
<o:Security s:mustUnderstand="1"
911
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
1012
<Timestamp
@@ -655,7 +657,7 @@
655657
</FilterAppCategoryIds>
656658
<TreatAppCategoryIdsAsInstalled>true</TreatAppCategoryIdsAsInstalled>
657659
<AlsoPerformRegularSync>false</AlsoPerformRegularSync>
658-
<ComputerSpec/>
660+
<ComputerSpec />
659661
<ExtendedUpdateInfoParameters>
660662
<XmlUpdateFragmentTypes>
661663
<XmlUpdateFragmentType>Extended</XmlUpdateFragmentType>
@@ -670,9 +672,11 @@
670672
</ClientPreferredLanguages>
671673
<ProductsParameters>
672674
<SyncCurrentVersionOnly>false</SyncCurrentVersionOnly>
673-
<DeviceAttributes>BranchReadinessLevel=CB;CurrentBranch=rs_prerelease;OEMModel=Virtual Machine;FlightRing={2};AttrDataVer=21;SystemManufacturer=Microsoft Corporation;InstallLanguage=en-US;OSUILocale=en-US;InstallationType=Client;FlightingBranchName=external;FirmwareVersion=Hyper-V UEFI Release v2.5;SystemProductName=Virtual Machine;OSSkuId=48;FlightContent=Branch;App=WU;OEMName_Uncleaned=Microsoft Corporation;AppVer=10.0.16184.1001;OSArchitecture=AMD64;SystemSKU=None;UpdateManagementGroup=2;IsFlightingEnabled=1;IsDeviceRetailDemo=0;TelemetryLevel=3;OSVersion=10.0.16184.1001;DeviceFamily=Windows.Desktop;</DeviceAttributes>
675+
<DeviceAttributes>
676+
BranchReadinessLevel=CB;CurrentBranch=rs_prerelease;FlightRing={2};FlightingBranchName=external;IsFlightingEnabled=1;InstallLanguage=en-US;OSUILocale=en-US;InstallationType=Client;DeviceFamily=Windows.Desktop;
677+
</DeviceAttributes>
674678
<CallerAttributes>Interactive=1;IsSeeker=0;</CallerAttributes>
675-
<Products/>
679+
<Products />
676680
</ProductsParameters>
677681
</parameters>
678682
</SyncUpdates>

0 commit comments

Comments
 (0)