Running python-gphoto2 as root or not.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Running python-gphoto2 as root or not.

Bob Smith-2
I didn't get a response (and I know Marcus is on vacation - you deserve
it) but I have an update.

Kind of SOLVED

I left it for a while hoping someone would solve my problem but then
tried some things. I ran strace on the 2 commands and sifted through
(with the help of my son) and found the difference between root and
non-root.

Wehn I run as root:
             pi@slave:~ $ sudo strace ./trigger |& grep gphoto/settings
             open("/root/.gphoto/settings", O_RDONLY|O_LARGEFILE) = 12
             open("/root/.gphoto/settings", O_RDONLY|O_LARGEFILE) = 12

and not:
             pi@slave:~ $ strace ./trigger |& grep gphoto/settings
             open("/home/pi/.gphoto/settings", O_RDONLY|O_LARGEFILE) = 12
             open("/home/pi/.gphoto/settings", O_RDONLY|O_LARGEFILE) = 12

/home/pi/.gphoto/settings contains:
             gphoto2=model=Canon EOS 5D Mark II
             gphoto2=port=usb:001,041
             libgphoto=cached-images=2
             ptp2=capturetarget=card
and this works.

/root/.gphoto/settings contains:
             gphoto2=model=Canon EOS 1D Mark IV
             gphoto2=port=usb:001,036
             libgphoto=cached-images=2

and fails.
Next I attached the 1D Mark IV to the pi and ran as root and it all worked.
However, when I attached a Canon EOS REBEL SL1" it also worked.

Camera     Root     non root
5D MK II     fail        pass
1D Mk IV    pass      pass
SL1            pass      pass
The next time I tried any camera on any setting they all worked. The new
/root/.gphoto/settings now (somehow) looks like this

             gphoto2=model=Canon EOS 1D Mark IV
             gphoto2=port=usb:001,041
             libgphoto=cached-images=2
             ptp2=capturetarget=card

The model has not changed but all 3 cameras now work.

When I ran sudo gphoto2 --summary with the Canon SL1 attached the file
amending the line to
                   gphoto2=model=Canon EOS 100D

All models still work fine.

CONCLUSION: This mysterious file (at least to me) had some bad stuff in
it and running gphoto2 on the command line as root appeared to have
fixed it.
I wrote all this in case anyone else gets here and I can save them a week.

Bob




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Gphoto-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gphoto-user
Reply | Threaded
Open this post in threaded view
|

Re: Running python-gphoto2 as root or not.

Jim Easterbrook
On 20/07/16 14:35, Bob Smith wrote:
> I didn't get a response (and I know Marcus is on vacation - you deserve
> it) but I have an update.
>
> Kind of SOLVED

I'm glad you found a rational explanation for what was happening. You
may be glad to know that, as far as I know, using libgphoto2 via the
Python interface does not use the .gphoto2/settings file - any settings
you need to store will be your program's responsibility.

Looking back at the script in your original post I've just spotted
something I should have seen when you posted your original message.
After using gp_widget_set_value() to set the capture target I think you
need to call gp_camera_set_config() to send the modified configuration
to the camera before calling gp_camera_capture().
--
Jim Easterbrook                 <http://www.jim-easterbrook.me.uk/>

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Gphoto-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gphoto-user
Reply | Threaded
Open this post in threaded view
|

Re: Running python-gphoto2 as root or not.

Marcus Meissner-4
In reply to this post by Bob Smith-2
On Wed, Jul 20, 2016 at 08:35:34AM -0500, Bob Smith wrote:

> I didn't get a response (and I know Marcus is on vacation - you deserve
> it) but I have an update.
>
> Kind of SOLVED
>
> I left it for a while hoping someone would solve my problem but then
> tried some things. I ran strace on the 2 commands and sifted through
> (with the help of my son) and found the difference between root and
> non-root.
>
> Wehn I run as root:
>              pi@slave:~ $ sudo strace ./trigger |& grep gphoto/settings
>              open("/root/.gphoto/settings", O_RDONLY|O_LARGEFILE) = 12
>              open("/root/.gphoto/settings", O_RDONLY|O_LARGEFILE) = 12
>
> and not:
>              pi@slave:~ $ strace ./trigger |& grep gphoto/settings
>              open("/home/pi/.gphoto/settings", O_RDONLY|O_LARGEFILE) = 12
>              open("/home/pi/.gphoto/settings", O_RDONLY|O_LARGEFILE) = 12
>
> /home/pi/.gphoto/settings contains:
>              gphoto2=model=Canon EOS 5D Mark II
>              gphoto2=port=usb:001,041
>              libgphoto=cached-images=2
>              ptp2=capturetarget=card
> and this works.
>
> /root/.gphoto/settings contains:
>              gphoto2=model=Canon EOS 1D Mark IV
>              gphoto2=port=usb:001,036
>              libgphoto=cached-images=2
>
> and fails.
> Next I attached the 1D Mark IV to the pi and ran as root and it all worked.
> However, when I attached a Canon EOS REBEL SL1" it also worked.
>
> Camera     Root     non root
> 5D MK II     fail        pass
> 1D Mk IV    pass      pass
> SL1            pass      pass
> The next time I tried any camera on any setting they all worked. The new
> /root/.gphoto/settings now (somehow) looks like this
>
>              gphoto2=model=Canon EOS 1D Mark IV
>              gphoto2=port=usb:001,041
>              libgphoto=cached-images=2
>              ptp2=capturetarget=card
>
> The model has not changed but all 3 cameras now work.
>
> When I ran sudo gphoto2 --summary with the Canon SL1 attached the file
> amending the line to
>                    gphoto2=model=Canon EOS 100D
>
> All models still work fine.
>
> CONCLUSION: This mysterious file (at least to me) had some bad stuff in
> it and running gphoto2 on the command line as root appeared to have
> fixed it.
> I wrote all this in case anyone else gets here and I can save them a week.

Usual the camera/port entries there are overwritten by the USB autodetection,
what you see with

        gphoto2 --auto-detect

The .gphoto/settings file should not really matter.


What is different above is the
        ptp2=capturetarget=card
line though. This might actually impact operations, as the default otherwise
is "sdram".

This is the  gphoto2 --get-config capturetarget   setting. It might be that
the failing camera does not run SDRAM capture correctly.

Ciao, Marcus

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Gphoto-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gphoto-user
Reply | Threaded
Open this post in threaded view
|

Re: Running python-gphoto2 as root or not.

Marcus Meissner-4
In reply to this post by Jim Easterbrook
On Wed, Jul 20, 2016 at 02:57:01PM +0100, Jim Easterbrook wrote:

> On 20/07/16 14:35, Bob Smith wrote:
> > I didn't get a response (and I know Marcus is on vacation - you deserve
> > it) but I have an update.
> >
> > Kind of SOLVED
>
> I'm glad you found a rational explanation for what was happening. You
> may be glad to know that, as far as I know, using libgphoto2 via the
> Python interface does not use the .gphoto2/settings file - any settings
> you need to store will be your program's responsibility.

The library itself opens the settings file, it is not dependend on the client.

So even when used from python bindings it will be read.

> Looking back at the script in your original post I've just spotted
> something I should have seen when you posted your original message.
> After using gp_widget_set_value() to set the capture target I think you
> need to call gp_camera_set_config() to send the modified configuration
> to the camera before calling gp_camera_capture().

This is correct, setting the config is needed.

Ciao, Marcus

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Gphoto-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gphoto-user
Reply | Threaded
Open this post in threaded view
|

Re: Running python-gphoto2 as root or not.

Jim Easterbrook
On 24/07/16 21:27, Marcus Meissner wrote:

> On Wed, Jul 20, 2016 at 02:57:01PM +0100, Jim Easterbrook wrote:
>>
>> I'm glad you found a rational explanation for what was happening. You
>> may be glad to know that, as far as I know, using libgphoto2 via the
>> Python interface does not use the .gphoto2/settings file - any settings
>> you need to store will be your program's responsibility.
>
> The library itself opens the settings file, it is not dependend on the client.
>
> So even when used from python bindings it will be read.

Thanks for correcting my misunderstanding. I haven't noticed any problem
with not having a .gphoto2/settings file. I assume libgphoto2 has
sensible default values for the missing settings.
--
Jim Easterbrook                 <http://www.jim-easterbrook.me.uk/>

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Gphoto-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gphoto-user