-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathupdater.py
63 lines (59 loc) · 1.81 KB
/
updater.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# PS3GameUpdateDownloader by shinrax2
# builtin
import time
import tempfile
import os
import platform
import json
import subprocess
import shlex
import sys
# local files
import utils
# pip packages
import FreeSimpleGUI as sg
if os.path.exists(
os.path.join(tempfile.gettempdir(), "PS3GUDUpdate.json")
) and os.path.isfile(os.path.join(tempfile.gettempdir(), "PS3GUDUpdate.json")):
with open(
os.path.join(tempfile.gettempdir(), "PS3GUDUpdate.json"), "r", encoding="utf8"
) as f:
data = json.loads(f.read())
sg.change_look_and_feel("DarkAmber")
layout = [
[
sg.Text(
"Waiting for main application to exit", size=(40, 3), key="updater_text"
)
],
[
sg.ProgressBar(
100, orientation="h", size=(40, 20), key="updater_progressbar"
)
],
]
window = sg.Window("PS3GUD Updater", layout)
window.finalize()
window.Refresh()
text = window["updater_text"]
bar = window["updater_progressbar"]
utils.waitForMainAppExit(pid=data["pid"], window=window)
text.Update("Checking for updates")
window.Refresh()
rel = utils.UpdaterGithubRelease(os.path.join(data["dir"], "release.json"))
resp = rel.checkForNewRelease()
if isinstance(resp, dict):
text.Update("Found new release!")
rel.downloadNewRelease(data["dir"], window)
exename = utils.getMainExecutableBasename() + utils.getExecutableSuffix()
if utils.isAppFrozen():
file = os.path.join(data["dir"], exename)
else:
file = "python3 " + os.path.join(data["dir"], exename)
if platform.system() == "Linux":
file = shlex.split(file)
subprocess.Popen(file)
window.close()