Skip to content

Commit

Permalink
PostBot: Update script according to the latest changes [skip ci]
Browse files Browse the repository at this point in the history
- Commit: 74a28b0

Change-Id: Ibcb80904843d403f9efc5cbc521ab39fed39afc4
Signed-off-by: PrajjuS <theprajjus@gmail.com>
  • Loading branch information
PrajjuS committed Jun 6, 2024
1 parent 74a28b0 commit 46ff892
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions .github/scripts/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def getConfig(config_name: str):
)

# File directories
jsonDir = "builds"
jsonDir = {
"Gapps": "builds/gapps",
"Vanilla": "builds/vanilla"
}
idDir = ".github/scripts"

# Store IDs in a file to compare
Expand All @@ -64,12 +67,13 @@ def update(IDs):
# Return IDs of all latest files from json files
def get_new_id():
files = []
file_id = []
for all in os.listdir(jsonDir):
if all.endswith('.json'):
files.append(all)
file_id = []
for type, dirName in jsonDir.items():
for all in os.listdir(dirName):
if all.endswith('.json'):
files.append({"type": type, "dir": dirName, "file": all})
for all_files in files:
with open(f"{jsonDir}/{all_files}", "r") as file:
with open(f"{all_files['dir']}/{all_files['file']}", "r") as file:
data = json.loads(file.read())['response'][0]
file_id.append(data['md5'])
return file_id
Expand All @@ -91,16 +95,18 @@ def get_diff(new_id, old_id):
# Grab needed info using ID of the file
def get_info(ID):
files = []
for all in os.listdir(jsonDir):
if all.endswith('.json'):
files.append(all)
for type, dirName in jsonDir.items():
for all in os.listdir(dirName):
if all.endswith('.json'):
files.append({"type": type, "dir": dirName, "file": all})
for all_files in files:
with open(f"{jsonDir}/{all_files}", "r") as file:
with open(f"{all_files['dir']}/{all_files['file']}", "r") as file:
data = json.loads(file.read())['response'][0]
if data['md5'] == ID:
device = all_files
build_type = all_files['type']
break
with open(f"{jsonDir}/{device}") as device_file:
with open(f"{jsonDir[build_type]}/{device}") as device_file:
info = json.loads(device_file.read())['response'][0]
DROIDX_VERSION = info['version']
OEM = info['oem']
Expand Down Expand Up @@ -206,11 +212,12 @@ def send_log(chat_id, text, button):
def get_devices():
files = []
devices = []
for all in os.listdir(jsonDir):
if all.endswith('.json'):
files.append(all)
for type, dirName in jsonDir.items():
for all in os.listdir(dirName):
if all.endswith('.json'):
files.append({"type": type, "dir": dirName, "file": all})
for device in files:
with open(f"{jsonDir}/{device}", "r") as file:
with open(f"{device['dir']}/{device['file']}", "r") as file:
data = json.loads(file.read())['response'][0]
devices.append({
"device_name": data['device'],
Expand Down

0 comments on commit 46ff892

Please sign in to comment.