[{"id":24856,"web_url":"https://patchwork.libcamera.org/comment/24856/","msgid":"<166193889259.15972.1860928056948599703@Monstersaurus>","date":"2022-08-31T09:41:32","subject":"Re: [libcamera-devel] [PATCH v9 7/7] qcam: Add --script to load\n\tcapture script","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Utkarsh Tiwari via libcamera-devel (2022-08-31 06:49:38)\n> Add --script as an individual option to load capture scripts.\n> Load the capture script before starting the capture.\n> \n> If an invalid capture script has been given, display an critical error\n> QMessageBox and close the application.\n> ---\n>  Differences from v8:\n>     1. Functionally the patch remains same.\n>     2. The difference is that checking for OptCaptureScript is now done\n>     in MainWindow::MainWindow()\n>  src/qcam/main.cpp        |  3 +++\n>  src/qcam/main_window.cpp | 11 +++++++++--\n>  src/qcam/main_window.h   |  1 +\n>  3 files changed, 13 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp\n> index d3f01a85..91166be5 100644\n> --- a/src/qcam/main.cpp\n> +++ b/src/qcam/main.cpp\n> @@ -43,6 +43,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])\n>                          \"Set configuration of a camera stream\", \"stream\", true);\n>         parser.addOption(OptVerbose, OptionNone,\n>                          \"Print verbose log messages\", \"verbose\");\n> +       parser.addOption(OptCaptureScript, OptionString,\n> +                        \"Load a capture session configuration script from a file\",\n> +                        \"script\", ArgumentRequired, \"script\");\n>  \n>         OptionsParser::Options options = parser.parse(argc, argv);\n>         if (options.isSet(OptHelp))\n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index af992b94..e488b67f 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -145,6 +145,9 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n>         cm_->cameraAdded.connect(this, &MainWindow::addCamera);\n>         cm_->cameraRemoved.connect(this, &MainWindow::removeCamera);\n>  \n> +       if (options_.isSet(OptCaptureScript))\n> +               scriptPath_ = options_[OptCaptureScript].toString();\n> +\n>         cameraSelectorDialog_ = new CameraSelectorDialog(cm_, scriptPath_, this);\n>         connect(cameraSelectorDialog_, &CameraSelectorDialog::stopCaptureScript,\n>                 this, &MainWindow::stopCaptureScript);\n> @@ -157,9 +160,13 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n>         }\n>  \n>         /* Start capture script. */\n> -       if (!scriptPath_.empty())\n> +       if (!scriptPath_.empty()) {\n>                 ret = loadCaptureScript();\n> -\n> +               if (options_.isSet(OptCaptureScript)) {\n\nIsn't ret supposed to be checked here ?\n\n> +                       quit();\n> +                       return;\n> +               }\n> +       }\n>         startStopAction_->setChecked(true);\n>  }\n>  \n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index 7c877ae1..24ebd019 100644\n> --- a/src/qcam/main_window.h\n> +++ b/src/qcam/main_window.h\n> @@ -45,6 +45,7 @@ enum {\n>         OptRenderer = 'r',\n>         OptStream = 's',\n>         OptVerbose = 'v',\n> +       OptCaptureScript = 256,\n>  };\n>  \n>  class MainWindow : public QMainWindow\n> -- \n> 2.34.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id ECDECC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 31 Aug 2022 09:41:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5052B61FBE;\n\tWed, 31 Aug 2022 11:41:36 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 48607603E1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 31 Aug 2022 11:41:35 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C00C1481;\n\tWed, 31 Aug 2022 11:41:34 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661938896;\n\tbh=nOV4qhqvvGNV1OXtU3lZAQIqHkzO9b7PgRxV7HGpX0A=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=rUwl2IhYopwwOYlUZoVfWlkKd8RT1FGCai6pNxXEkTGYq6bs9ede3fFd4f0U6v1Fb\n\tM4U3rg4whj8ja3UcIZUUrCo5GpP+ufp0uRtdGUmSNJFO6NQLJk0pnoNUB7R25BdwzK\n\trKvXStizjtc4O1pW0RBywS3womrZtk1uotqNUEqKKJARwwUMoMkOVoU4i3Hh+3oXX4\n\t6GC0RoavoQxmcpaq7EYehiWdAxuRTGFNq8cY6Mmct5YvtwsnWlKPGk7VJCaza2Rgfw\n\tP+Xm/GEdB4AJI3wJ2odvwkvFTMRx3ZKCTHXFDeAMIJsEqrn93E4hYC98cYrtok1oQ4\n\tNbGq3NY2DCX3A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661938894;\n\tbh=nOV4qhqvvGNV1OXtU3lZAQIqHkzO9b7PgRxV7HGpX0A=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=S/lX2735j5E0TAiIhCW12seJlSUBnDSwCqT/iKilKtTXd/qw3vW/D3ooZwNIOeC9/\n\t1voxaJaLXPujlZTR7b2vMvpMEc7EbblTVlLuhV8Br1NgevsXFurFejFUDlUlZ4UXM2\n\tPSj2kDyP1uX1GZF5RaYXRVYD/MeczVpro1vuQy8g="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"S/lX2735\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220831054938.21617-8-utkarsh02t@gmail.com>","References":"<20220831054938.21617-1-utkarsh02t@gmail.com>\n\t<20220831054938.21617-8-utkarsh02t@gmail.com>","To":"Utkarsh Tiwari <utkarsh02t@gmail.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 31 Aug 2022 10:41:32 +0100","Message-ID":"<166193889259.15972.1860928056948599703@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v9 7/7] qcam: Add --script to load\n\tcapture script","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24859,"web_url":"https://patchwork.libcamera.org/comment/24859/","msgid":"<Yw8yi7pEteIZtcnI@pendragon.ideasonboard.com>","date":"2022-08-31T10:06:03","subject":"Re: [libcamera-devel] [PATCH v9 7/7] qcam: Add --script to load\n\tcapture script","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Aug 31, 2022 at 10:41:32AM +0100, Kieran Bingham via libcamera-devel wrote:\n> Quoting Utkarsh Tiwari via libcamera-devel (2022-08-31 06:49:38)\n> > Add --script as an individual option to load capture scripts.\n> > Load the capture script before starting the capture.\n> > \n> > If an invalid capture script has been given, display an critical error\n> > QMessageBox and close the application.\n> > ---\n> >  Differences from v8:\n> >     1. Functionally the patch remains same.\n> >     2. The difference is that checking for OptCaptureScript is now done\n> >     in MainWindow::MainWindow()\n> >  src/qcam/main.cpp        |  3 +++\n> >  src/qcam/main_window.cpp | 11 +++++++++--\n> >  src/qcam/main_window.h   |  1 +\n> >  3 files changed, 13 insertions(+), 2 deletions(-)\n> > \n> > diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp\n> > index d3f01a85..91166be5 100644\n> > --- a/src/qcam/main.cpp\n> > +++ b/src/qcam/main.cpp\n> > @@ -43,6 +43,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])\n> >                          \"Set configuration of a camera stream\", \"stream\", true);\n> >         parser.addOption(OptVerbose, OptionNone,\n> >                          \"Print verbose log messages\", \"verbose\");\n> > +       parser.addOption(OptCaptureScript, OptionString,\n> > +                        \"Load a capture session configuration script from a file\",\n> > +                        \"script\", ArgumentRequired, \"script\");\n> >  \n> >         OptionsParser::Options options = parser.parse(argc, argv);\n> >         if (options.isSet(OptHelp))\n> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> > index af992b94..e488b67f 100644\n> > --- a/src/qcam/main_window.cpp\n> > +++ b/src/qcam/main_window.cpp\n> > @@ -145,6 +145,9 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n> >         cm_->cameraAdded.connect(this, &MainWindow::addCamera);\n> >         cm_->cameraRemoved.connect(this, &MainWindow::removeCamera);\n> >  \n> > +       if (options_.isSet(OptCaptureScript))\n> > +               scriptPath_ = options_[OptCaptureScript].toString();\n\nAt this point the script isn't selected yet, it's only a default. I'd\nstore it in a local variable, passed to the camera selector dialog box\nconstructor, and let the normal capture script selection mechanism then\nset scriptPath_.\n\nAdding the script path parameter to the camera selector dialog box in\nthis patch instead of 6/7 would also be better, to make 6/7 clearer.\n\n> > +\n> >         cameraSelectorDialog_ = new CameraSelectorDialog(cm_, scriptPath_, this);\n> >         connect(cameraSelectorDialog_, &CameraSelectorDialog::stopCaptureScript,\n> >                 this, &MainWindow::stopCaptureScript);\n> > @@ -157,9 +160,13 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n> >         }\n> >  \n> >         /* Start capture script. */\n> > -       if (!scriptPath_.empty())\n> > +       if (!scriptPath_.empty()) {\n> >                 ret = loadCaptureScript();\n> > -\n> > +               if (options_.isSet(OptCaptureScript)) {\n> \n> Isn't ret supposed to be checked here ?\n> \n> > +                       quit();\n\nI don't think quitting is right here. Imagine the following scenerio:\n\n- The user selects a capture script on the command line\n- When the camera selection dialog box is opened, the user picks a\n  different script\n- The script fails to load\n\nWhy should we quit in that case, compared to the case where the user\nwill not have selected a script on the command line ?\n\n> > +                       return;\n> > +               }\n> > +       }\n> >         startStopAction_->setChecked(true);\n> >  }\n> >  \n> > diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> > index 7c877ae1..24ebd019 100644\n> > --- a/src/qcam/main_window.h\n> > +++ b/src/qcam/main_window.h\n> > @@ -45,6 +45,7 @@ enum {\n> >         OptRenderer = 'r',\n> >         OptStream = 's',\n> >         OptVerbose = 'v',\n> > +       OptCaptureScript = 256,\n> >  };\n> >  \n> >  class MainWindow : public QMainWindow","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DE7ECC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 31 Aug 2022 10:06:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8F96761FC0;\n\tWed, 31 Aug 2022 12:06:16 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CDFBF61F9F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 31 Aug 2022 12:06:14 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 29EDE481;\n\tWed, 31 Aug 2022 12:06:14 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661940376;\n\tbh=mEfUFyynjPSlYXqhp8Hi/6iWveIVCmpgoubTKRUyMK0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=q4UBFuueOUgkwj56XSDWr3iS0cmWbxF39Az98Xm0pZIOVlfY+z8fI4aaSjwv3tcv7\n\ttIT578J49grFwCWD/e40bZf8oS+0dvEEH33lPI6yQRjD8R0bPPnTWmQO6Kx2HUfagq\n\t7O5Wz572Ir9CdZzeW36IcSVOMNrJh5yTu2ny5AVp1CJwvvyxtYZBtI1Vl1nglaCYqU\n\t/ItCEFv0gaNzaMPktR0/ImICHvO0+uoNzVStWyLs1CqdbqP8UppupY3g/wp3hiPYLf\n\tOjkI6dCtpWxhc6Q2mFYSDUYqbsEI4FuuFznigUraMB/BNWyUWXfdU0nCMLqvu4vYii\n\tnr79EcqMgMkjQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661940374;\n\tbh=mEfUFyynjPSlYXqhp8Hi/6iWveIVCmpgoubTKRUyMK0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FtiZmiCd8YFpK1v6I8xQuT6vDnSSn7G2qdwQ4CBPULsr7U1lIPIhNArC3eguYuSUx\n\tT54bgjIy3r2w3bThoGy+bXrVIMbh5w1ScxGfaa7eBoJiGz/oYL78wo3eKHtFyzcktz\n\t3c6HGswnYa9zjjz/TybnqLD/vSZsQeGunB/JHj7w="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"FtiZmiCd\"; dkim-atps=neutral","Date":"Wed, 31 Aug 2022 13:06:03 +0300","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<Yw8yi7pEteIZtcnI@pendragon.ideasonboard.com>","References":"<20220831054938.21617-1-utkarsh02t@gmail.com>\n\t<20220831054938.21617-8-utkarsh02t@gmail.com>\n\t<166193889259.15972.1860928056948599703@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<166193889259.15972.1860928056948599703@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH v9 7/7] qcam: Add --script to load\n\tcapture script","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]