[FL-2230] SubGhz: protocol API refactoring (#969)
* SubGhz: protocols library refactoring * SubGhz: new architecture and refactoring * SubGhz: simplify protocol structure, remove unused types * SubGhz: rename Subghz to SubGhz * SubGhz: add environment concept Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com> Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
This commit is contained in:
@@ -16,8 +16,6 @@ class App:
|
||||
|
||||
def __call__(self):
|
||||
self.args, _ = self.parser.parse_known_args()
|
||||
if "func" not in self.args:
|
||||
self.parser.error("Choose something to do")
|
||||
# configure log output
|
||||
self.log_level = logging.DEBUG if self.args.debug else logging.INFO
|
||||
self.logger.setLevel(self.log_level)
|
||||
@@ -29,7 +27,7 @@ class App:
|
||||
|
||||
# execute requested function
|
||||
self.before()
|
||||
return_code = self.args.func()
|
||||
return_code = self.call()
|
||||
self.after()
|
||||
if isinstance(return_code, int):
|
||||
exit(return_code)
|
||||
@@ -37,6 +35,11 @@ class App:
|
||||
self.logger.error(f"Missing return code")
|
||||
exit(255)
|
||||
|
||||
def call(self):
|
||||
if "func" not in self.args:
|
||||
self.parser.error("Choose something to do")
|
||||
return self.args.func()
|
||||
|
||||
def init(self):
|
||||
raise Exception("init() is not implemented")
|
||||
|
||||
|
46
scripts/guruguru.py
Executable file
46
scripts/guruguru.py
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from flipper.app import App
|
||||
|
||||
|
||||
class Main(App):
|
||||
def init(self):
|
||||
self.parser.add_argument("watch_list", nargs="+", help="Directories to watch")
|
||||
self.is_building = False
|
||||
|
||||
def clearConsole(self):
|
||||
os.system("cls" if os.name in ("nt", "dos") else "clear")
|
||||
|
||||
async def rebuild(self, line):
|
||||
self.clearConsole()
|
||||
self.logger.info(f"Triggered by: {line}")
|
||||
proc = await asyncio.create_subprocess_exec("make")
|
||||
await proc.wait()
|
||||
await asyncio.sleep(1)
|
||||
self.is_building = False
|
||||
|
||||
async def run(self):
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
"fswatch", *self.args.watch_list, stdout=asyncio.subprocess.PIPE
|
||||
)
|
||||
|
||||
while True:
|
||||
data = await proc.stdout.readline()
|
||||
line = data.decode().strip()
|
||||
if not self.is_building:
|
||||
self.is_building = True
|
||||
asyncio.create_task(self.rebuild(line))
|
||||
|
||||
def call(self):
|
||||
try:
|
||||
asyncio.run(self.run())
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Main()()
|
Reference in New Issue
Block a user