TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: R.WIESER
date: 2019-11-03 08:20:00
subject: Re: Python - set current

Dennis,

>>But ... Really no method to do it from within python (even if I would have
>>to use "sudo python3 {script.py}")?    Bizarre.
>>
> Why bizarre?

A very basic property of the OS (which you can /read/ from in a slew of
ways), but no way to set it.

I can understand, in a multi-user machine, why not just anybody should be
able to muck around with it, but disallowing even root users to easily
change it ...

> Okay -- it appears the C runtime supports a settimeofday()... So using
> the Python ctypes library/module should permit you to access that
> function.

Yep, that (ctypes library/module) is something I need to take a better look
at.   I must say that I rather like it that python has such an "you can call
anything you like, just use this interface" method.

> and user applications normally don't need access to
> functions that can change the system environment

True.

Than again, I'm not just a linux user.  I've bought a Raspberry for a reason
(so many GPIO pins, my preciousss). :-)

> I presume [snip] > time.clock_settime(clk_id, time: float) [snip] doesn't
> affect the desired clock.

I don't know either.   But its certainly something to pursue.   Although ...
having to convert a set of simple date & time values into a datetime float
might be its own challenge ...

> (I don't know how often ntp does updates)

In my case I often run my Pi disconnected from the 'web.   Hence my wish to
be able to update the system clock from an RTC.   I've currently got no
problem with, when connected to the 'web,  the NTP service overruling it.

Regards,
Rudy Wieser

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.