[Tutor] Please help disentangle my program logic

Robert Alexander gogonegro at gmail.com
Sun Jan 5 12:47:44 EST 2020


Thank you very much,  but it gives a 404 not found error.


On 5 January 2020 at 18:43:03, Mayo Adams (mayoadams at gmail.com) wrote:

The pages of Phillip Guo might possibly help, though your stuff looks
pretty advanced (pythontutor.com/visualize).

On Sun, Jan 5, 2020 at 11:01 AM Robert Alexander <gogonegro at gmail.com>
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.
>
> I usually run this program as described in the requirements.txt file as
> "nohup python -u speedtest.py >> adsl.log &"
>
> As you can see in the current version the st_json function spits out two
> log lines which have a different format from the usual ones and quits
> altogether breaking the while True loop. This might be acceptable in the
> “Speedtest prerequisite not installed” case but not for the “Internet down
> case” which should be logged (the frequencies of logging are computed in
> the set_frequency function and currently do not contemplate the
> Internet-offline case).
>
> So currently the function calls in the main are a bit of spaghetti logic
> which makes it hard to define a standard modular log line that could be
> parseable in the future.
>
> Two main questions are:
>
> A) Are there tools to quickly/neatly look at a flow of your program? For
> example how would you modify the st_json function to handle both a
> successful measure but also the other two cases (Internet not reachable and
> speediest CLI not installed)?
>
> B) Suggestions to make this little program more rational?
>
> Thank you all very much in advance
> Robert
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


--
Mayo Adams

287 Erwin Rd.
Chapel Hill, NC 27514
(919)-780-3917
mayoadams at gmail.com


More information about the Tutor mailing list