-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsmfupdate
More file actions
executable file
·61 lines (49 loc) · 1.66 KB
/
Copy pathsmfupdate
File metadata and controls
executable file
·61 lines (49 loc) · 1.66 KB
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
#!/usr/bin/env python3
# -- https://github.com/StormWorld0/storm-framework
# -- SMF License
import requests
import subprocess
import sys
def update():
url = "https://raw.githubusercontent.com/StormWorld0/storm-framework/main/data/data.json"
try:
latest_version = requests.get(url).json()["version"]
except Exception as e:
print(f"ERROR VERSION UPDATE => {e}")
# 1. Get the latest info without changing the locale first
subprocess.run(["git", "fetch", "--all"], stdout=subprocess.DEVNULL)
# 2. CHECK CHANGES: Compare local (HEAD) with server (origin/main)
check_diff = subprocess.run(
["git", "diff", "--name-only", "HEAD", "origin/main"],
capture_output=True,
text=True,
)
# 3. Reset Execution (Update file to the latest version)
process = subprocess.run(
["git", "reset", "--hard", "origin/main"], stdout=subprocess.PIPE, text=True
)
if process.returncode == 0:
print(
f"\n[✓] System updated to version => {latest_version}"
)
# 4. Trigger Compiler ONLY IF needed
try:
from scripts.cpl import compiler
compiler.start_build()
except ImportError as e:
print(f"Error import compiler => {e}")
sys.exit(100)
except Exception as e:
print(f"Error when running the compiler => {e}")
sys.exit(100)
try:
from scripts.security.sign import run_sign
run_sign()
except ImportError as e:
print(f"Error import => {e}")
sys.exit(100)
except Exception as e:
print(f"Error executing signature => {e}")
sys.exit(100)
if __name__ == "__main__":
update()