reorganize

This commit is contained in:
Minecon724 2024-06-16 14:01:08 +02:00
parent ca6744f9e0
commit d0ba477db8
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
6 changed files with 13 additions and 8 deletions

View file

@ -1 +0,0 @@
{"label": "0.9-alpha.1", "id": 1, "timestamp": 1718449299, "file": "realweather-0.9-SNAPSHOT.jar"}

1
latest/latest-v1.json Normal file
View file

@ -0,0 +1 @@
{"label": "0.9-alpha.1", "id": 1, "timestamp": 1718539114, "file": "realweather-0.9-SNAPSHOT.jar"}

View file

@ -3,13 +3,17 @@
import json, os, time import json, os, time
from typing import Tuple from typing import Tuple
meta_file_name = 'meta-v1.json'
latest_file_name = 'latest-v1.json'
latest_file_path = os.path.join('latest', latest_file_name)
def confirm(prompt: str) -> bool: def confirm(prompt: str) -> bool:
confirmed = input(prompt + ' (Y/N) ') confirmed = input(prompt + ' (Y/N) ')
return confirmed.lower() == 'y' return confirmed.lower() == 'y'
def load_latest_data() -> dict: def load_latest_data() -> dict:
if os.path.isfile('latest.json'): if os.path.isfile(latest_file_path):
return json.loads(open('latest.json').read()) return json.loads(open(latest_file_path).read())
return {'id': 0} return {'id': 0}
def match_name(filename: str, extension: str=None, exact_name: str=None): def match_name(filename: str, extension: str=None, exact_name: str=None):
@ -55,7 +59,7 @@ def wait_for_file(waiting_dir: str, extension: str=None, exact_name: str=None) -
def write_metadata(metadata: dict): def write_metadata(metadata: dict):
dir = metadata['label'] dir = metadata['label']
metadata = json.dumps(metadata) metadata = json.dumps(metadata)
for filepath in [os.path.join('releases', dir, 'meta.json'), 'latest.json']: for filepath in [os.path.join('releases', dir, meta_file_name), latest_file_path]:
file = open(filepath, 'w') file = open(filepath, 'w')
file.write(metadata) file.write(metadata)
file.close() file.close()

View file

@ -0,0 +1 @@
{"label": "0.9-alpha.1", "id": 1, "timestamp": 1718539114, "file": "realweather-0.9-SNAPSHOT.jar"}

View file

@ -1 +0,0 @@
{"label": "0.9-alpha.1", "id": 1, "timestamp": 1718449299, "file": "realweather-0.9-SNAPSHOT.jar"}

View file

@ -4,12 +4,13 @@ from shutil import rmtree
from os import remove, mkdir from os import remove, mkdir
confirmation = input('If you really want to delete all releases, type CONFIRM: ') confirmation = input('If you really want to delete all releases, type CONFIRM: ')
if confirmation != 'CONFIRM': if confirmation != 'CONFIRM':
print('Cancelled') print('Cancelled')
exit() exit()
remove('latest.json') for dir in ['releases', 'latest']:
rmtree('releases') rmtree(dir)
mkdir('releases') mkdir(dir)
print('Reset complete') print('Reset complete')