[Tutor] Please help disentangle my program logic

Robert Alexander gogonegro at gmail.com
Sun Jan 5 13:23:56 EST 2020


Thank you Mats. Very interesting observation.

May you kindly expand on why you are suggesting this?

In my opinion specifying a log name at runtime gives me more flexibility
but I might be not considering some other important reason.

Ciao

PS Etiquette question please: Is it better to reply to both the sender and
the list or the list only?


On 5 January 2020 at 19:18:30, Mats Wichmann (mats at wichmann.us) wrote:

On 1/5/20 9:00 AM, Robert Alexander wrote:
> Dear friends and tutors,
> Also thanks to some of your help I have written my first little python
> program.
>
> It now lives on Github https://github.com/rjalexa/adsl-warn and its
purpose
> is to monitor my home ADSL speeds, log them and if they degrade send me a
> Gmail email with increasing frequency.
>
> While is does work ok, thinking about it’s overall flow there are things I
> do not like.
>
> The next iteration should always log a line covering all cases from the
LAN
> not functioning, to Internet not reachable (and of course in these cases I
> should log but not attempt to send an email), to the degraded (log +
email)
> and normal (log only) speeds.

quick reaction: look into the logging module to control how, where and
what to log. No need to reinvent the wheel.

>
> I usually run this program as described in the requirements.txt file as
> "nohup python -u speedtest.py >> adsl.log &"

You shouldn't need to depend on shell syntax to get this stuff to
work... the logging module will handle appending, or you can do it
yourself (print can take a a file= argument to show where to send the
output, and you open that file first in the appropriate mode)
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list