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

Dennis,

> No surprise there... All that statement does is create a
> Python datetime object/instance initialized to a particular
> date/time value -- and then throws it away..

After a few hours I realized that that might be the case.   Would have
expected at least a warning for that creating-but-not-using-it though.

> First recommendation -- forget the interactive shell... It is
> really just meant for testing snippets of code.

And thats what I'm doing, as a python user of less than a week (have been
programming for a number of years though). :-)

> Second -- study the Python Library Reference manual... I'd direct
> you to the section on subprocess.popen()

And that makes me feel like I'm back in my BASIC days, having to shell for
all the interesting stuff ...

I also found a solution using "subprocess.call()"
https://stackoverflow.com/questions/27363487/setting-the-time-and-date-via-pyth
on-linux
although I had to combine all the arguments to a single one (why?) it does
seem to work.
Its just that I could not believe that I would have to do it that way.

> this helps prevent someone walking by a logged in machine
> from randomly doing "sudo something-malicious"

:-) I have the Pi open to be able to connect stuff to its GPIO.   If someone
wanted to do something malicious than just going over them with a coin
(short-circuiting them) would likely destroy a few - instead of just having
to re-install.   Or even just "by accident" spilling some liquid onto it
would be enough.

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

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™.