[{"id":24734,"web_url":"https://patchwork.libcamera.org/comment/24734/","msgid":"<166120811996.3484129.11839074161187906775@Monstersaurus>","date":"2022-08-22T22:41:59","subject":"Re: [libcamera-devel] [PATCH v8 8/8] 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-10 16:03:49)\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> Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n> ---\n> Difference from v7:\n>         1. Moved firstCameraSelect_ to 3/8\n>  src/qcam/main.cpp        |  3 +++\n>  src/qcam/main_window.cpp | 10 ++++++++++\n>  src/qcam/main_window.h   |  1 +\n>  3 files changed, 14 insertions(+)\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 753e1af9..ce70cc02 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -147,6 +147,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>         /* Open the camera and start capture. */\n>         ret = openCamera();\n>         if (ret < 0) {\n> @@ -325,6 +328,13 @@ void MainWindow::loadCaptureScript()\n>                 QMessageBox::critical(this, \"Invalid Script\",\n>                                       \"Couldn't load the capture script\");\n>  \n> +               /*\n> +                * Close the camera if started by command line and its the first capture\n> +                * script.\n> +                */\n> +               if (firstCameraSelect_ && options_.isSet(OptCaptureScript))\n> +                       quit();\n\nThis feels clunky. It might be better if loadCaptureScript() had a\nreturn value, that the call from command line could check and quit if it\ndidn't load successfully.\n\nBut - Does the loadCaptureScript only get called from the MainWindow\ncontrustructor ?\n\nI think I'd have it called directly from the dialog acceptance, and\nhere.\n\n\n> +\n>         } else\n>                 cameraSelectorDialog_->informScriptRunning(scriptPath_);\n>  \n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index 10994b67..c7cba5e9 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.25.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 1B4AABE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 22 Aug 2022 22:42:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 02A2061FC0;\n\tTue, 23 Aug 2022 00:42:04 +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 9CEE060E25\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Aug 2022 00:42:02 +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 273742B3;\n\tTue, 23 Aug 2022 00:42:02 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661208124;\n\tbh=uvowZVc2b880Sa9HoH/SSc9smljT3BKLWPWxixmnVj4=;\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=IvlWOpj1yFPjY8zH/Ks/wkF+9NnnKsZ+Vvy/cfqS1ZNCVKOxug5SZclQ1l7owQQB0\n\tRi3jFg+bs9VmA7gIlE0oE/Wu+PK0ah7zShK0YvRy7kpu2seslMlDBrBs9Nkni9IteG\n\tZWfH1vdrAru92nYUJMLV5u+W9YnYAQBDUWmFaIJYyht8aH71lyWPt2IQ2yPqgXkt9X\n\tR5bA7rumVGrHnnNEOL/BM6bUN2wy4vQl8dEH+N0rg0FiYOqItp0Q4VtiW5v3E7YNOP\n\tyJzH9eG2Q+C5++xBhuWS6DFpzdcbCaAeesqIN1P2t3/puwFag/FEZAiQl97dWGi3+E\n\tvvoNsMdYn9IfA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661208122;\n\tbh=uvowZVc2b880Sa9HoH/SSc9smljT3BKLWPWxixmnVj4=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=v9e1Fz35g9WTXPSa3tyvbN9w5XekJe4kpx3Vi1LMYOR/CaNPftRIG4L/MJ0fsITV6\n\tWOaC7wSjKst/Jw3b6SujbbptVdsvBrc5tTd/gTNo95Riv42i+0uP/36jXapIuhBjBI\n\t7GfZtz6+s3x2DXHyowjV9lFjiVY1Nv1/YCTE/EnU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"v9e1Fz35\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220810150349.414043-9-utkarsh02t@gmail.com>","References":"<20220810150349.414043-1-utkarsh02t@gmail.com>\n\t<20220810150349.414043-9-utkarsh02t@gmail.com>","To":"Utkarsh Tiwari <utkarsh02t@gmail.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 22 Aug 2022 23:41:59 +0100","Message-ID":"<166120811996.3484129.11839074161187906775@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v8 8/8] 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":24744,"web_url":"https://patchwork.libcamera.org/comment/24744/","msgid":"<YwQ/x/OymtzzjfmS@pendragon.ideasonboard.com>","date":"2022-08-23T02:47:35","subject":"Re: [libcamera-devel] [PATCH v8 8/8] 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 Mon, Aug 22, 2022 at 11:41:59PM +0100, Kieran Bingham via libcamera-devel wrote:\n> Quoting Utkarsh Tiwari via libcamera-devel (2022-08-10 16:03:49)\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> > Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n> > ---\n> > Difference from v7:\n> >         1. Moved firstCameraSelect_ to 3/8\n> >  src/qcam/main.cpp        |  3 +++\n> >  src/qcam/main_window.cpp | 10 ++++++++++\n> >  src/qcam/main_window.h   |  1 +\n> >  3 files changed, 14 insertions(+)\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 753e1af9..ce70cc02 100644\n> > --- a/src/qcam/main_window.cpp\n> > +++ b/src/qcam/main_window.cpp\n> > @@ -147,6 +147,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> >         /* Open the camera and start capture. */\n> >         ret = openCamera();\n> >         if (ret < 0) {\n> > @@ -325,6 +328,13 @@ void MainWindow::loadCaptureScript()\n> >                 QMessageBox::critical(this, \"Invalid Script\",\n> >                                       \"Couldn't load the capture script\");\n> >  \n> > +               /*\n> > +                * Close the camera if started by command line and its the first capture\n> > +                * script.\n> > +                */\n> > +               if (firstCameraSelect_ && options_.isSet(OptCaptureScript))\n> > +                       quit();\n> \n> This feels clunky. It might be better if loadCaptureScript() had a\n> return value, that the call from command line could check and quit if it\n> didn't load successfully.\n\nI like that better too.\n\n> But - Does the loadCaptureScript only get called from the MainWindow\n> contrustructor ?\n> \n> I think I'd have it called directly from the dialog acceptance, and\n> here.\n> \n> > +\n> >         } else\n> >                 cameraSelectorDialog_->informScriptRunning(scriptPath_);\n> >  \n> > diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> > index 10994b67..c7cba5e9 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 44BADC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Aug 2022 02:47:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B337D61FC0;\n\tTue, 23 Aug 2022 04:47:40 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BEBAB60E25\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Aug 2022 04:47:39 +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 1A09C2B3;\n\tTue, 23 Aug 2022 04:47:39 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661222860;\n\tbh=owVupL7LpkrSJPgOjGbDloGg+IcA7fBwAdTvhACjBWY=;\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=g2oMVMggUYSUYBs3QQrpn6OkOBNLPqH6A0o6bPXSNCru4Kn+/wk+hblVfC6oZXoNn\n\t9ignagBG9WYzzDKJ7HocJZqc+HQUH5Ffe3/5cA3foZhTqbSOMV7rTubBHm9rYuZ52K\n\t2pVmr/wbsvZtsXW8vPeAOwpom2vCwrGQ0eoF09lcYvmk8BrAgucGbUN3j6KcMlNvn/\n\tDRT8zn+hzSDBm15oB7yvTgnoLW0RGWjJ82HQM0OMdlcoG5+9twv0nwGokPr3klv0hz\n\tyhL2ZdJ9zIH4oXCnC5/mh8b4Ov0YB9g6MmucEvTzM/qLgIYfIr+vLHtj540JFEVt/y\n\t5+GQ200tUkPtA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661222859;\n\tbh=owVupL7LpkrSJPgOjGbDloGg+IcA7fBwAdTvhACjBWY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=HPj4efjmFtxg7Bcbg3buesXUwNKC+RuHPzImZg7X39sIAJ7IYYl5sf+5PVaQtPFI0\n\t+aPYKno8+4UfSfSkqn4X7A9Ed/XgXesG83Kv/Nj0AoO3221sSJAezGusmAQdvqQQmd\n\tMazJWgq/o1J0hp05UK7LsXk0fBU6+YW/nLvq5m2I="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"HPj4efjm\"; dkim-atps=neutral","Date":"Tue, 23 Aug 2022 05:47:35 +0300","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YwQ/x/OymtzzjfmS@pendragon.ideasonboard.com>","References":"<20220810150349.414043-1-utkarsh02t@gmail.com>\n\t<20220810150349.414043-9-utkarsh02t@gmail.com>\n\t<166120811996.3484129.11839074161187906775@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<166120811996.3484129.11839074161187906775@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH v8 8/8] 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>"}}]