Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions gen_mirror_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,23 @@
sha256 = hashlib.sha256()
for buf in iter(lambda : data.read(128 * 1024), b''):
sha256.update(buf)

BASE_PATH = "home/user/updater/builds/"
filepath = filename

try:
with zipfile.ZipFile('{}{}'.format(BASE_PATH, filepath), 'r') as update_zip:
build_prop = update_zip.read('system/build.prop').decode('utf-8')
timestamp = int(re.findall('ro.build.date.utc=([0-9]+)', build_prop)[0])
except:
build_prop = update_zip.read('META-INF/com/android/metadata').decode('utf-8')
timestamp = (re.findall('post-timestamp=([0-9]+)', build_prop)[0])
except Exception as e:
print(e)
timestamp = int(mktime(datetime.strptime(builddate, '%Y%m%d').timetuple()))

builds.setdefault(device, []).append({
'sha256': sha256.hexdigest(),
'size': os.path.getsize(f),
'date': '{}-{}-{}'.format(builddate[0:4], builddate[4:6], builddate[6:8]),
'datetime': timestamp,
'datetime': int(timestamp),
'filename': filename,
'filepath': f.replace(FILE_BASE, ''),
'version': version,
Expand Down