mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
Merge branch 'ofw_dev' into blerefactr
This commit is contained in:
@@ -30,8 +30,11 @@ class HardwareTargetLoader:
|
||||
if not target_json_file.exists():
|
||||
raise Exception(f"Target file {target_json_file} does not exist")
|
||||
with open(target_json_file.get_abspath(), "r") as f:
|
||||
vals = json.load(f)
|
||||
return vals
|
||||
try:
|
||||
vals = json.load(f)
|
||||
return vals
|
||||
except json.JSONDecodeError as e:
|
||||
raise Exception(f"Failed to parse target file {target_json_file}: {e}")
|
||||
|
||||
def _processTargetDefinitions(self, target_id):
|
||||
target_dir = self._getTargetDir(target_id)
|
||||
|
||||
@@ -63,7 +63,13 @@ class Main(App):
|
||||
return dist_target_path
|
||||
|
||||
def note_dist_component(self, component: str, extension: str, srcpath: str) -> None:
|
||||
self._dist_components[f"{component}.{extension}"] = srcpath
|
||||
component_key = f"{component}.{extension}"
|
||||
if component_key in self._dist_components:
|
||||
self.logger.debug(
|
||||
f"Skipping duplicate component {component_key} in {srcpath}"
|
||||
)
|
||||
return
|
||||
self._dist_components[component_key] = srcpath
|
||||
|
||||
def get_dist_file_name(self, dist_artifact_type: str, filetype: str) -> str:
|
||||
return f"{self.DIST_FILE_PREFIX}{self.target}-{dist_artifact_type}-{self.args.suffix}.{filetype}"
|
||||
@@ -162,8 +168,9 @@ class Main(App):
|
||||
"scripts.dir",
|
||||
)
|
||||
|
||||
sdk_bundle_path = self.get_dist_path(self.get_dist_file_name("sdk", "zip"))
|
||||
with zipfile.ZipFile(
|
||||
self.get_dist_path(self.get_dist_file_name("sdk", "zip")),
|
||||
sdk_bundle_path,
|
||||
"w",
|
||||
zipfile.ZIP_DEFLATED,
|
||||
) as zf:
|
||||
@@ -205,6 +212,10 @@ class Main(App):
|
||||
),
|
||||
)
|
||||
|
||||
self.logger.info(
|
||||
fg.boldgreen(f"SDK bundle can be found at:\n\t{sdk_bundle_path}")
|
||||
)
|
||||
|
||||
def bundle_update_package(self):
|
||||
self.logger.debug(
|
||||
f"Generating update bundle with version {self.args.version} for {self.target}"
|
||||
|
||||
44
scripts/send_firebase_notification.py
Normal file
44
scripts/send_firebase_notification.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import argparse
|
||||
import logging
|
||||
from firebase_admin import messaging, credentials, initialize_app
|
||||
|
||||
|
||||
class FirebaseNotifications:
|
||||
def __init__(self, service_account_file):
|
||||
try:
|
||||
cred = credentials.Certificate(service_account_file)
|
||||
self.firebase_app = initialize_app(cred)
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
raise e
|
||||
|
||||
def send(self, title, body, condition):
|
||||
try:
|
||||
message = messaging.Message(
|
||||
notification=messaging.Notification(title=title, body=body),
|
||||
condition=condition,
|
||||
)
|
||||
messaging.send(message, app=self.firebase_app)
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
raise e
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--token_file", help="Firebase token file", required=True)
|
||||
parser.add_argument(
|
||||
"--version", help="Firmware version to notify with", required=True
|
||||
)
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_args()
|
||||
notification = FirebaseNotifications(args.token_file)
|
||||
notification.send(
|
||||
title="Firmware Update Available",
|
||||
body=f"New firmware version is ready to install: {args.version}",
|
||||
condition="'flipper_update_firmware_release' in topics",
|
||||
)
|
||||
@@ -208,7 +208,7 @@ fbtenv_show_unpack_percentage()
|
||||
fbtenv_unpack_toolchain()
|
||||
{
|
||||
echo "Unpacking toolchain to '$FBT_TOOLCHAIN_PATH/toolchain':";
|
||||
rm $FBT_TOOLCHAIN_PATH/toolchain/current || true;
|
||||
rm "$FBT_TOOLCHAIN_PATH/toolchain/current" || true;
|
||||
tar -xvf "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_TAR" -C "$FBT_TOOLCHAIN_PATH/toolchain" 2>&1 | fbtenv_show_unpack_percentage;
|
||||
mkdir -p "$FBT_TOOLCHAIN_PATH/toolchain" || return 1;
|
||||
mv "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_DIR" "$TOOLCHAIN_ARCH_DIR" || return 1;
|
||||
|
||||
Reference in New Issue
Block a user