Пример #1
0
Файл: web.py Проект: srg74/wbld
async def websocket_handler(request):

    ws = web.WebSocketResponse()
    await ws.prepare(request)

    await ws.send_str("hi")

    msg: WSMessage
    async for msg in ws:
        # ws.__next__() automatically terminates the loop
        # after ws.close() or ws.exception() is called
        if msg.type == WSMsgType.TEXT:
            data = json.loads(msg.data)
            peername = request.transport.get_extra_info("peername")

            if data["action"] == "join":
                logger.debug(f"Client joined: {peername}")
                request.app["websockets"].append(ws)
            elif data["action"] == "build":
                for _ws in request.app["websockets"]:
                    await _ws.send_json({
                        "action": "build",
                        "state": data["state"]
                    })
            logger.debug(data)
        elif msg.type == WSMsgType.ERROR:
            logger.debug("ws connection closed with exception %s" %
                         ws.exception())

        logger.debug(request.app["websockets"])

    logger.debug("websocket connection closed")
    await logger.complete()

    return ws
Пример #2
0
 def __init__(self, clone: Clone, snippet):
     logger.debug(f"Custom build in {clone.path} using snippet:\n{snippet}")
     custom_config = CustomConfig(snippet)
     with open(f"{clone.path}/platformio_override.ini", "w") as file:
         logger.debug(f"Writing out custom config to: {file.name}")
         custom_config.write(file)
     super(BuilderCustom, self).__init__(clone, custom_config.env)
     self.kind = Kind.CUSTOM
     self.build.kind = Kind.CUSTOM
     self.build.snippet = snippet
Пример #3
0
    async def healthcheck(self):
        try:
            async with ClientSession(raise_for_status=True) as session:
                await session.get(self.ping_url)
        except ClientError as error:
            logger.error(f"Health check error: {error}")
        else:
            logger.debug(f"Submitted healthcheck ping to: {self.ping_url}")

        logger.complete()
Пример #4
0
    def run(self,
            variables=None,
            targets=None,
            silent=False,
            verbose=False,
            jobs=2):
        timer_start = timer()

        if not variables:
            variables = {
                "pioenv": self.build.env,
                "project_config": self.project_config.path
            }

        if not targets:
            targets = []

        try:
            options = self.project_config.items(env=self.build.env,
                                                as_dict=True)
            platform = options["platform"]
            logger.debug(f"Building {self.build.env} for {platform}")
        except KeyError:
            logger.error(f"Couldn't find platform for: {self.build.env}")
            self.build.state = State.FAILED
            return self.build

        try:
            factory = PlatformFactory.new(platform)
        except UnknownPlatform:
            self.platform_install(platform=platform, skip_default_package=True)
            factory = PlatformFactory.new(platform)

        log_combined = self.build.file_log.open("w")

        with redirect_stdout(log_combined), redirect_stderr(log_combined):
            self.build.state = State.BUILDING

            run = factory.run(variables, targets, silent, verbose, jobs)

        if run and run["returncode"] == 0:
            self.gather_files([open(self.firmware_filename, "rb")])
            self.build.state = State.SUCCESS
        else:
            self.build.state = State.FAILED

        timer_end = timer()
        duration = float(timer_end - timer_start)
        self.build.duration = duration
        return self.build
Пример #5
0
Файл: wbld.py Проект: srg74/wbld
 async def on_command_error(self, ctx, exception):
     if isinstance(exception, TimeoutError):
         logger.debug(exception)
         await ctx.send(exception)
     elif isinstance(
             exception,
         (
             commands.errors.CommandNotFound,
             commands.errors.MissingRequiredArgument,
             commands.errors.MaxConcurrencyReached,
             commands.errors.CommandInvokeError,
         ),
     ):
         await ctx.send(exception)
     await logger.complete()
     raise exception
Пример #6
0
Файл: wbld.py Проект: srg74/wbld
 async def _send_ready(ctx, reference):
     logger.debug(ctx)
     logger.debug(reference)
     await logger.complete()
     embed = Embed(
         title=reference.commit.sha,
         url=reference.commit.commit.html_url,
         description=reference.commit.commit.message,
         color=0x034EFC,
     )
     embed.set_author(
         name=reference.repository.full_name,
         url=reference.repository.html_url,
         icon_url=reference.repository.owner.avatar_url,
     )
     await ctx.send(
         content=
         "OK. Ready to build. Please paste your custom PlatformIO environment config.",
         embed=embed,
     )
Пример #7
0
 def __enter__(self):
     logger.debug(
         f"Entering builder for build {self.build.build_id} at {self.path}")
     self.setup()
     return self
Пример #8
0
 def gather_files(self, files):
     for file in files:
         shutil.copy(file.name, self.build.path)
         file.close()
     logger.debug(f"Files gathered in {self.build.path}: {files}")
Пример #9
0
Файл: wbld.py Проект: srg74/wbld
 async def on_command(self, ctx):
     logger.debug(
         f"Command {ctx.command.qualified_name} called by {str(ctx.author)}"
     )
     await logger.complete()