Re: [Dorset] CentOS petition

2021-01-21 Thread tda

On 21/01/2021 16:23, Hamish McIntyre-Bhatty wrote:

On 21/01/2021 12:59, Tim Waugh wrote:


Here's the latest about this:

https://www.redhat.com/en/blog/new-year-new-red-hat-enterprise-linux-programs-easier-ways-access-rhel

Tim.
*/


Oh that looks really good, thank you for sharing :) Makes me feel quite
a lot better about the whole thing.



Dunno, I think it's just in Red Hat's corporate culture to monetise their 
stable offerings while keeping the free distros more or less bleeding edge 
(they are after all a business). I remember, with the EOL of RH9 back in 2004, 
asking on the list whether to move to Fedora or Debian; ended up switching to 
Debian. So I'd wonder how long this new RHEL offering will last. There's Rocky 
Linux on the horizon, but could that go the same way as Centos in a few years?

Tim

--
 Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] CentOS petition

2021-01-21 Thread Hamish McIntyre-Bhatty
On 21/01/2021 12:59, Tim Waugh wrote:
>
> Here's the latest about this:
>
> https://www.redhat.com/en/blog/new-year-new-red-hat-enterprise-linux-programs-easier-ways-access-rhel
>
> Tim.
> */

Oh that looks really good, thank you for sharing :) Makes me feel quite
a lot better about the whole thing.

Hamish



signature.asc
Description: OpenPGP digital signature
-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 14:40:35 GMT Stephen Wolff wrote:
> My google search was for ‘Flask button names’ btw - as I knew that
> was a way to detect which button had being clicked for a form to be
> submitted. So Google got it right - the SO post explains the task you
> were trying to accomplish.

Even with those search terms.  I never found it.  The trouble is that Google 
'helpfully' tunes its responses based on the browsing history of the person 
making the query, so two people can search for the same thing and end up with 
a totally different selection of hits.

> The book being quoted is a really good intro to Flask, and has some good
> ideas. Miguel develops a number of very useful Flask libraries, so is
> well placed. So, worth pursuing if you want to go further…

Yes.  I bought it.  :-)  It is good, but in that particular Chapter, pointed 
to by Ralph, there's an awful lot about validation and authentication and very 
little about buttons

It simply never occurred to me that I might use a form with associated Submit 
buttons because I don't need a form on my page, just a bunch of buttons.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Stephen Wolff

On 21 Jan 2021, at 14:37, Terry Coles wrote:


On Thursday, 21 January 2021 14:28:42 GMT Ralph Corderoy wrote:

https://stackoverflow.com/questions/19794695/flask-python-buttons/27952991#2
7952991 is the same approach as the book.  You may find the book 
better

written than trying to piece it together from SO answers.  :-)


Well I understand the code snippets at SO, whereas I couldn't make 
head or
tail of the stuff in the book.  Apart from anything else, the 
connection to
buttons isn't particularly obvious (it only talks about a submit 
button).
Then the resulting web page only has forms on it with a single button 
and not

multiple buttons each carrying out a single action.


My google search was for ‘Flask button names’ btw - as I knew that 
was a way to detect which button had being clicked for a form to be 
submitted. So Google got it right - the SO post explains the task you 
were trying to accomplish.


The book being quoted is a really good intro to Flask, and has some good 
ideas. Miguel develops a number of very useful Flask libraries, so is 
well placed. So, worth pursuing if you want to go further…


--
 Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 14:28:42 GMT Ralph Corderoy wrote:
> https://stackoverflow.com/questions/19794695/flask-python-buttons/27952991#2
> 7952991 is the same approach as the book.  You may find the book better
> written than trying to piece it together from SO answers.  :-)

Well I understand the code snippets at SO, whereas I couldn't make head or 
tail of the stuff in the book.  Apart from anything else, the connection to 
buttons isn't particularly obvious (it only talks about a submit button).  
Then the resulting web page only has forms on it with a single button and not 
multiple buttons each carrying out a single action.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Ralph Corderoy
Hi Terry,

> Anyway, I'm going to try the method(s) at stack overflow first.

https://stackoverflow.com/questions/19794695/flask-python-buttons/27952991#27952991
is the same approach as the book.  You may find the book better written
than trying to piece it together from SO answers.  :-)

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 14:08:44 GMT Ralph Corderoy wrote:
> You want a form.
> https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iii-web-fo
> rms from that book seems to do exactly what you want.  Just think of your
> needs as a form with just a submit button, so no fields which need filling
> in, and the message-sending to Hamish is when the book ‘flash’es a message.

Yes.  I read that but couldn't see how to make it do what I wanted. :-(

The solution on stack overflow linked to by Stephen seems to be the closest to 
my pseudo code.

The solution from Hamish and LXF as posted by Peter would also work, but I 
think it would rapidly get a bit bloated with more than half a dozen buttons.

Anyway, I'm going to try the method(s) at stack overflow first.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Ralph Corderoy
Hi Terry,

Keith wrote:
> > I don't know how well you know Flask, Terry, but this is an
> > excellent intro. It's not going to be the immediate answer to your
> > question, though.
> > 
> > http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
>
> the book majors on the forms side of things with lots of stuff on
> accessing databases and authentication etc.

You want a form.
https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iii-web-forms
from that book seems to do exactly what you want.  Just think of your
needs as a form with just a submit button, so no fields which need
filling in, and the message-sending to Hamish is when the book ‘flash’es
a message.

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread PeterMerchant

On 21/01/2021 13:54, Terry Coles wrote:

On Thursday, 21 January 2021 13:52:27 GMT PeterMerchant wrote:

Sending you separately an article form LXformat that shows how to do this.
I did this for my remote control car, with the R-Pi configured as an access
point and Flask Web server, and the HTML Calling Python to set GPIO pins to
drive the motors.

Peter,

Which issue was that?  I sunscribe to LXf


Issue 229. A couple of Years ago.

P.




--
 Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 13:55:09 GMT PeterMerchant wrote:
> Go-car.sh used to start programs when I am testing. These lines go into
> rc.local for running at startup

That seems to be the way that Hamish proposed it.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread PeterMerchant

On 21/01/2021 12:39, Terry Coles wrote:

Hi,

I'm building a Web page to allow users to monitor key status information on
one of the Pis at WMT.  I also want to create a page where users can press a
button to carry out certain tasks, such as Start or Stop some music playing or
select a new Playlist. The Player is written in Python. Altogether, there are
around 10 or more control functions that I want to invoke.

I have the monitoring page working reasonably well using a suitable html
template and a Flask route which populates the status values on the rendered
page. However, the control side is making me think a bit. I've found quite a
lot of tutorials and text book examples that use forms and a 'Submit' button,
but so far nothing quite like what I want.

What I need is for the user to be presented with set of buttons that, when
pressed, cause a bit of Python code to be executed that communicates with the
Player program.  On receipt of the message, the Player program will trigger a
set of functions to carry out the requested action.  The communication side is
sorted; all I need is an example or a link to a suitable tutorial that
illustrates the Flask code that I need to make it happen and if necessary, the
associated template.


Here is a bit of a demonstration:

https://www.youtube.com/watch?v=jsj-cnHkr_k

Peter






--
 Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 13:52:27 GMT PeterMerchant wrote:
> Sending you separately an article form LXformat that shows how to do this. 
> I did this for my remote control car, with the R-Pi configured as an access
> point and Flask Web server, and the HTML Calling Python to set GPIO pins to
> drive the motors.

Peter,

Which issue was that?  I sunscribe to LXF.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread PeterMerchant

On 21/01/2021 12:39, Terry Coles wrote:

Hi,

I'm building a Web page to allow users to monitor key status information on
one of the Pis at WMT.  I also want to create a page where users can press a
button to carry out certain tasks, such as Start or Stop some music playing or
select a new Playlist. The Player is written in Python. Altogether, there are
around 10 or more control functions that I want to invoke.

I have the monitoring page working reasonably well using a suitable html
template and a Flask route which populates the status values on the rendered
page. However, the control side is making me think a bit. I've found quite a
lot of tutorials and text book examples that use forms and a 'Submit' button,
but so far nothing quite like what I want.

What I need is for the user to be presented with set of buttons that, when
pressed, cause a bit of Python code to be executed that communicates with the
Player program.  On receipt of the message, the Player program will trigger a
set of functions to carry out the requested action.  The communication side is
sorted; all I need is an example or a link to a suitable tutorial that
illustrates the Flask code that I need to make it happen and if necessary, the
associated template.

Here is a bit of pseudo code to illustrate what I'm trying to do:

@app.route('/control')
def control():
 Add a Button called "Stop the Music"
 ON click run:
socket.write("Stop the Music")

Add another button...

etc.


Can anyone help?


Sending you separately an article form LXformat that shows how to do this.  I 
did this for my remote control car, with the R-Pi configured as an access point 
and Flask Web server, and the HTML Calling Python to set GPIO pins to drive the 
motors.

Peter M.


--
 Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 13:27:01 GMT Stephen Wolff wrote:
> This does something like your pseudo code:
> 
>   - https://stackoverflow.com/questions/19794695/flask-python-buttons

It does doesn't it.  :-)  Now I have a new starting point.  Thanks for that.

You guys obviously have a better degree in googling than I do, because I 
searched for 'Flask Python Buttons' and never found that.

> If you want to make it happen without a page refresh, you could use
> ‘Ajax’ - one simple way is to use jquery to submit the form
> (https://api.jquery.com/jquery.ajax/). The Flask end would stay the same
> (or similar), so I’d get a non-ajax version working first, then look
> into Ajax if that’s what you need.

Thanks for that too, although I have stumbled across a tutorial somewhere that 
uses flask-moment (I think) to keep the page refreshed.

Anyway.  That's the next problem :-)

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 13:10:56 GMT Keith Edmunds wrote:
> I don't know how well you know Flask, Terry, but this is an excellent
> intro. It's not going to be the immediate answer to your question, though.
> 
> http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-wor
> ld

Keith,

I'm very much on the steep part of the leaning curve.

Miguel's Tutorial is one of the sites that I found.  I also bought his text 
book, which is how I was able to do the monitoring part.  Again, the book 
majors on the forms side of things with lots of stuff on accessing databases 
and authentication etc.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Stephen Wolff
I've been using subprocess.open in the Player programs, but I don't 
believ the
I need it for this.  The Flask App is written in Python, so I should 
be able
to use the sockets code that we already have (written by Hamish for 
the River
System) to pass messages between the two running programs, eg the 
Webserver

and the Player.


You might be able to do that but you’d need to re-open the socket on 
each web server request, and close it at the end of the requests, or 
you’ll run into problems. I don’t think you’ll be able to keep the 
socket available to all requests, but I might be wrong!


--
 Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 13:08:32 GMT Stephen Wolff wrote:
> You might need the subprocess.open method or .run

I've been using subprocess.open in the Player programs, but I don't believ the 
I need it for this.  The Flask App is written in Python, so I should be able 
to use the sockets code that we already have (written by Hamish for the River 
System) to pass messages between the two running programs, eg the Webserver 
and the Player.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Stephen Wolff

On 21 Jan 2021, at 13:11, Terry Coles wrote:


On Thursday, 21 January 2021 13:02:13 GMT Ralph Corderoy wrote:

How do they not meet your requirements?
That might give us a better idea of what to suggest.


Well they don't do anything like the psuedo code that I mentioned.  
:-)




This does something like your pseudo code:

 - https://stackoverflow.com/questions/19794695/flask-python-buttons

You give your form input elements a name attribute, and that is picked 
up in the Flask url handler.


If you want to make it happen without a page refresh, you could use 
‘Ajax’ - one simple way is to use jquery to submit the form 
(https://api.jquery.com/jquery.ajax/). The Flask end would stay the same 
(or similar), so I’d get a non-ajax version working first, then look 
into Ajax if that’s what you need.


Stephen
--
 Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 13:02:13 GMT Ralph Corderoy wrote:
> How do they not meet your requirements?
> That might give us a better idea of what to suggest.

Well they don't do anything like the psuedo code that I mentioned.  :-)

Seriously, everything I've found so far has been oriented towards blogging and 
login pages. etc.  One that I've found on YouTube shows how to get the content 
of a form and write the info to a database.  I thought that might lead me by 
the nose, but I can't seem to see how to convert what they do to what I need.

The official documentation for Flask only mentions buttons in around four five 
places and that's more of the same.  I'm assuming that If I had a template 
with the buttons defined in it, I might be able to get the button press to 
invoke the python code somehow, but again I can't seem to see how to do that.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Keith Edmunds
I don't know how well you know Flask, Terry, but this is an excellent
intro. It's not going to be the immediate answer to your question, though.

http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
-- 
Linux Tips: https://www.tiger-computing.co.uk/category/techtips/

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Hamish McIntyre-Bhatty
On 21/01/2021 13:03, Terry Coles wrote:
> On Thursday, 21 January 2021 12:52:44 GMT Hamish McIntyre-Bhatty wrote:
>> I haven't looked at Flask in detail, but one way to do it would be to
>> use a GET or POST value when the button is submitted in the form, so it
>> eg redirects to /control.html?action=play.
> Thanks Hamish.  I did wonder if that might be the only way, but it seemed a 
> bit clunky and felt that there ought to be something more sophisticated that 
> I've missed.
>
> One trouble that I've found with Flask is that on its own its fairly 
> straightforward, but much of what is done is done my the loading of flask 
> modules and other helper libraries.  It isn't always obvious which of those 
> module or libraries to study to find what I need.
>
> That's why I've been trying to find an example from someone who has done 
> something similar.  I've found a number of examples using javascript (I even 
> used one myself for the original WMT Webserver), but they all simply redirect 
> to another page.  I need to execute a line of Python.

The only other way I particularly know is to use client-side Javascript
to make that request without reloading the page. I know it is also
possible to respond to the result from the server, for example with a
callback, but I can't provide a good example of how to do this because I
lack the expertise. If I spend some time later I my be able to find you
an example of it.

The only way (that I know of) to do this is to send a request to the
server in some way to trigger it to execute the Python line, eg by
redirecting to a page or sending a request through some other means.

I'm quite happy to be proven wrong though, I'm sure there must be a
proper web developer on here who we can both learn from.

Hamish



signature.asc
Description: OpenPGP digital signature
-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Stephen Wolff
On Thursday, 21 January 2021 12:52:44 GMT Hamish McIntyre-Bhatty 
wrote:

I haven't looked at Flask in detail, but one way to do it would be to
use a GET or POST value when the button is submitted in the form, so 
it

eg redirects to /control.html?action=play.


Thanks Hamish.  I did wonder if that might be the only way, but it 
seemed a
bit clunky and felt that there ought to be something more 
sophisticated that

I've missed.

One trouble that I've found with Flask is that on its own its fairly
straightforward, but much of what is done is done my the loading of 
flask
modules and other helper libraries.  It isn't always obvious which of 
those

module or libraries to study to find what I need.

That's why I've been trying to find an example from someone who has 
done
something similar.  I've found a number of examples using javascript 
(I even
used one myself for the original WMT Webserver), but they all simply 
redirect

to another page.  I need to execute a line of Python.


You might need the subprocess.open method or .run

 - https://docs.python.org/3/library/subprocess.html

This lets you run out of process functions (ie shell scripts, python 
scripts etc) without leaving the wsgi world.


The other thing I was thinking was that your original code mentions 
‘socket’, so you might be wanting to make some sort of websocket 
connection from the browser. I’d try and avoid that if possible as it 
really is a bit of a nightmare depending how Flask is being hosted, and 
what you use to set up the web sockets. Stick to the GET or POST as 
Hamish says, with a redirect on successful submission (to avoid web 
browser history allowing the user to get in a muddle)

--
 Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 12:52:44 GMT Hamish McIntyre-Bhatty wrote:
> I haven't looked at Flask in detail, but one way to do it would be to
> use a GET or POST value when the button is submitted in the form, so it
> eg redirects to /control.html?action=play.

Thanks Hamish.  I did wonder if that might be the only way, but it seemed a 
bit clunky and felt that there ought to be something more sophisticated that 
I've missed.

One trouble that I've found with Flask is that on its own its fairly 
straightforward, but much of what is done is done my the loading of flask 
modules and other helper libraries.  It isn't always obvious which of those 
module or libraries to study to find what I need.

That's why I've been trying to find an example from someone who has done 
something similar.  I've found a number of examples using javascript (I even 
used one myself for the original WMT Webserver), but they all simply redirect 
to another page.  I need to execute a line of Python.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Ralph Corderoy
Hi Terry,

> I've found quite a lot of tutorials and text book examples that use
> forms and a 'Submit' button, but so far nothing quite like what
> I want.

How do they not meet your requirements?
That might give us a better idea of what to suggest.

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] CentOS petition

2021-01-21 Thread Tim Waugh
Here's the latest about this:

https://www.redhat.com/en/blog/new-year-new-red-hat-enterprise-linux-programs-easier-ways-access-rhel

Tim.
*/
-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Hamish McIntyre-Bhatty
On 21/01/2021 12:39, Terry Coles wrote:
> Hi,
>
> I'm building a Web page to allow users to monitor key status information on 
> one of the Pis at WMT.  I also want to create a page where users can press a 
> button to carry out certain tasks, such as Start or Stop some music playing 
> or 
> select a new Playlist. The Player is written in Python. Altogether, there are 
> around 10 or more control functions that I want to invoke.
>
> I have the monitoring page working reasonably well using a suitable html 
> template and a Flask route which populates the status values on the rendered 
> page. However, the control side is making me think a bit. I've found quite a 
> lot of tutorials and text book examples that use forms and a 'Submit' button, 
> but so far nothing quite like what I want.
>
> What I need is for the user to be presented with set of buttons that, when 
> pressed, cause a bit of Python code to be executed that communicates with the 
> Player program.  On receipt of the message, the Player program will trigger a 
> set of functions to carry out the requested action.  The communication side 
> is 
> sorted; all I need is an example or a link to a suitable tutorial that 
> illustrates the Flask code that I need to make it happen and if necessary, 
> the 
> associated template.
>
> Here is a bit of pseudo code to illustrate what I'm trying to do:
>
> @app.route('/control')
> def control():
> Add a Button called "Stop the Music"
> ON click run:
>socket.write("Stop the Music")
>
>Add another button...
>
>etc.
>
> Can anyone help?

I haven't looked at Flask in detail, but one way to do it would be to
use a GET or POST value when the button is submitted in the form, so it
eg redirects to /control.html?action=play.

Then, the server side-script can examine the value of the action
attribute when the page reloads, and perform the action. It could also
render a little confirmation message to say whether or not it was
successful.

If you want to avoid page reloads, you'll likely need some JavaScript to
catch the form submission and send the request to the server through
something like the XHR facility.

Might need a little more info on exactly how you want it to behave though.

Unfortunately I don't have the knowledge to help much beyond
conceptualising this at the moment, but I'm sure someone here does web
development as a profession/has some time to find something for you.

Hamish



signature.asc
Description: OpenPGP digital signature
-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


[Dorset] Using Flask to render a set of Buttons.

2021-01-21 Thread Terry Coles
Hi,

I'm building a Web page to allow users to monitor key status information on 
one of the Pis at WMT.  I also want to create a page where users can press a 
button to carry out certain tasks, such as Start or Stop some music playing or 
select a new Playlist. The Player is written in Python. Altogether, there are 
around 10 or more control functions that I want to invoke.

I have the monitoring page working reasonably well using a suitable html 
template and a Flask route which populates the status values on the rendered 
page. However, the control side is making me think a bit. I've found quite a 
lot of tutorials and text book examples that use forms and a 'Submit' button, 
but so far nothing quite like what I want.

What I need is for the user to be presented with set of buttons that, when 
pressed, cause a bit of Python code to be executed that communicates with the 
Player program.  On receipt of the message, the Player program will trigger a 
set of functions to carry out the requested action.  The communication side is 
sorted; all I need is an example or a link to a suitable tutorial that 
illustrates the Flask code that I need to make it happen and if necessary, the 
associated template.

Here is a bit of pseudo code to illustrate what I'm trying to do:

@app.route('/control')
def control():
Add a Button called "Stop the Music"
ON click run:
   socket.write("Stop the Music")
   
   Add another button...
   
   etc.

Can anyone help?

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 11:45:36 GMT PeterMerchant wrote:
> About the USB connections, I thought that the specified length for USB
> connections was 5 Metres? Are you going further than that at WMT?

No.  The two Pis are in the same Equipment Case.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread PeterMerchant



Do you not compile the C code before uploading it to an Arduino or similar?
I've never used an Arduino but have always assumed that the compiler was in
the IDE not the device.


been using a Wemos D1 which has some of these features plus Wifi, and
programmed in c.

That's an interesting device too, albeit a lot less capable than this latest
offering.

The microPython is the attractive thing.  When i was evaluating the options at
WMT in 2016, I plumped for the RPi Zero because it was half the price of the
cheapest Arduino, but more importantly it supported Python.


Yes, The Arduino IDE has a 'verify' Button that compiles the code and reports 
errors, and also the 'upload' button that compiles and then uploads the 
firmware to the device.  I am using the Wemos like a remote control unit with 6 
buttons as inputs, and I2C display, and MQTT over Wifi to my Raspberry Pi.  And 
powered by a USB powerbank, as I never wired up the 4 battery AA pack.

When I first got the Wemos I tried to load the MicroPython on to is 
unsuccessfully a few times, so It was interesting after I got given the Arduino 
Unos  to discover that I could program the Wemos using the IDE.

I concur that you did the right thing back then choosing the Raspberry Pi for 
all the work at the WMT.

About the USB connections, I thought that the specified length for USB 
connections was 5 Metres? Are you going further than that at WMT?

Peter


--
 Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Ralph Corderoy
Hi Terry,

> You are guilty of selective quoting.  :-)

Ah, sorry.

> When I referred to USB Networking, I was talking about the technique
> described in your link.

Yes, I see that now.

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 10:17:49 GMT Ralph Corderoy wrote:
> > USB Networking works extremely well.
> 
> ...
> 
> > traffic has still to be carried over USB and then be converted to
> > TCP/IP in the Adaptor.
> 
> So to clarify, it isn't USB networking.  It's wired Ethernet or Wi-Fi
> networking with one of those network interface being connected to the Pi
> locally over USB.
> 
> USB networking would be USB all the way down.  :-)
> https://en.wikipedia.org/wiki/Ethernet_over_USB

Ralph,

You are guilty of selective quoting.  :-)

When I referred to USB Networking, I was talking about the technique described 
in your link.  I have two Pis in the new Minster installation and they are 
connected together over USB without an Ethernet Adaptor at either end.  Once 
configured at one end, both Pis gain a usb0 interface, which can be treated as 
a network interface.  No WiFi, no Ethernet Adaptor.

As it happens one of the Pis has a WiFi Adaptor to link to the WMT Network 
(which does not support USB networking and would need a very long USB cable if 
it did).

In you second quote, I was simply comparing the (assumed) performance of USB 
Networking and Ethernet in that scenario.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Ralph Corderoy
Hi Terry,

> USB Networking works extremely well.
...
> traffic has still to be carried over USB and then be converted to
> TCP/IP in the Adaptor.   

So to clarify, it isn't USB networking.  It's wired Ethernet or Wi-Fi
networking with one of those network interface being connected to the Pi
locally over USB.

USB networking would be USB all the way down.  :-)
https://en.wikipedia.org/wiki/Ethernet_over_USB

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Bob Dunlop
Hi,

> I notice that it doesn't have WiFi, and I wonder if it could be programmed 
> from the Arduino IDE as 'c' is mentioned. Perhaps that will come. I have been 
> using a Wemos D1 which has some of these features plus Wifi, and programmed 
> in c.

In my professional work this was often the demarcation line.  Need a network
Ethernet or WiFi then use a SoC and linux or at least a multitasking OS.
Need lowest power and no network, use an MPU and bareback code.

Now for hobby use that equates to, networking use the Pi Zero W or better,
no networking STM32 blue pill and the like.  The Pico even looks like a blue
pill.

The newer F4 based black pills look comparable to the Pico, single core but
it's Cortex-M4 not M0 with hardware floating point and DSP instructions.
Similar price from usual suppliers.  There's a nice write up here:
https://hackaday.com/2021/01/20/blue-pill-vs-black-pill-transitioning-from-stm32f103-to-stm32f411/#more-454155

I suspect the RPi Pico will soon win out just on popular labeling.


All have IDEs available that allow you to program them in C these days,
although my personal method is Vi + gcc + make.

Oh and it's 'C' not 'c' please.

-- 
Bob Dunlop

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 09:55:45 GMT Hamish McIntyre-Bhatty wrote:
> That's true, if USB is fairly functional that perhaps USB NICs could be
> made to work. It will still need a TCP/IP stack though.

Yes agreed, which is why I only said that I would 'seriously consider' this 
device.  :-)

> What would the Pico's be doing in that design? All the hardware-related
> stuff like interfacing with probes?
> 
> I realise this is very much a hypothetical discussion, but still
> interested :). Does the USB Raspberry Pi networking work well for the
> new Minster system?

USB Networking works extremely well.  Once configured it is pretty much 
seamless.  The only change from the system viewpoint is that the Static IP 
Address on the Pi has to be assigned to usb0 instead of eth0.

I should image that throughput would be limited only by the speed of the USB 
hardware and would probably be higher than if an Ethernet Adaptor is used 
because traffic has still to be carried over USB and then be converted to 
TCP/IP 
in the Adaptor.   

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Hamish McIntyre-Bhatty
On 21/01/2021 09:50, Terry Coles wrote:
> On Thursday, 21 January 2021 09:25:02 GMT Hamish McIntyre-Bhatty wrote:
>> This is a very interesting product. That said, I agree with you Terry in
>> that I think it would have been hard to even get Ethernet to work with
>> something like this, let alone talking to a MySQL database - probably
>> unsuitable for the River System, or at least the direction it went in
>> given the hardware we had at the time.
> At the time, there was no thought of networking the devices; this was when I 
> did the lighting controller.  This would have been perfect for that because 
> in 
> the end I was unable to get PWM to work without flickering using Python 
> because 
> the GPIO Library didn't (doesn't?) support the hardware PWM on Pin 18.   I 
> got 
> it working with WiringPi and C, although the C code is hardly rocket science 
> with only around 160 lines of code around a third of which are comments.
>
> The train controllers would have been a perfect choice for this , but I 
> couldn't have used it for any of the four audio players on the site.  I agree 
> with you that we certainly would have struggled to develop the software for 
> the River System in its present form.
>
> From a hardware standpoint we would have been fine for any of the River 
> System 
> devices if USB networking could be made to work.   If I were starting today, 
> I 
> would seriously consider using a Pi Zero at each location to do the grunt 
> work, connected to the Pico's using USB Networking, like I've just done on 
> the 
> new Minster hardware.

That's true, if USB is fairly functional that perhaps USB NICs could be
made to work. It will still need a TCP/IP stack though.

What would the Pico's be doing in that design? All the hardware-related
stuff like interfacing with probes?

I realise this is very much a hypothetical discussion, but still
interested :). Does the USB Raspberry Pi networking work well for the
new Minster system?

Hamish



signature.asc
Description: OpenPGP digital signature
-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Ralph Corderoy
Hi Hamish,

> I must admit I struggle to see the difference between a
> microcontroller and a very low end SoC/SBC, apart from the analogue
> inputs (but AFAIK some SoCs/SBCs include analogue inputs too).

I'd welcome corrections, this is just the impression I'm formed from
programming a few microcontrollers in C and assembler, e.g. swtch().

A microcontroller unit, or MCU, is more than a CPU.  The Z80, 6502,
6509, etc., used in home computers of the 70s and 80s were CPUs; a chip
which read instructions and executed them and accessed the outside
world, including any memory other than its register file, over address
and data pins.

These days, a microcontroller will have on-board static RAM, and perhaps
flash memory too for holding the code to run.  If the flash isn't within
the microcontroller's package then there will be support for external
flash.  General purpose binary I/O pins will be available for reading or
writing.  Simple ‘serial’ interfaces, like SPI, I²C, and CAN bus, will
be available.  An analogue-to-digital converter or two might be
available to sample an analogue signal on an input pin.

The CPU at the centre of the microcontroller still often lacks a
floating-point unit so it can only do integer arithmetic, though
fixed-point arithmetic is often good enough.  And it probably won't have
any memory protection unit either so all RAM is accessed at the same
privilege level.  Which isn't to say the CPU doesn't have different
privilege levels when executing instructions, just that it can't be told
a range of bytes are currently inaccessible to cause a fault on an
invalid access.

ARM's Cortex-M range, like the Pico's Cortex-M0+, are microcontrollers,
according to ARM, which is why they're ‘M’ in contrast to the Cortex-A
range which are for applications.

An SoC which isn't a microcontroller would have double-precision
floating-point and memory management in the CPU.  Plus more complex
peripherals like a GPU, SATA interfaces, etc.

USB is a bit borderline, I think.  Hardware-wise on the wire, it's quite
simple, but the software stack to support it can be complex and so out
of place on an MCU which may have limited flash to store all the code
and RAM as low as hundreds of bytes.

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 09:25:02 GMT Hamish McIntyre-Bhatty wrote:
> This is a very interesting product. That said, I agree with you Terry in
> that I think it would have been hard to even get Ethernet to work with
> something like this, let alone talking to a MySQL database - probably
> unsuitable for the River System, or at least the direction it went in
> given the hardware we had at the time.

At the time, there was no thought of networking the devices; this was when I 
did the lighting controller.  This would have been perfect for that because in 
the end I was unable to get PWM to work without flickering using Python because 
the GPIO Library didn't (doesn't?) support the hardware PWM on Pin 18.   I got 
it working with WiringPi and C, although the C code is hardly rocket science 
with only around 160 lines of code around a third of which are comments.

The train controllers would have been a perfect choice for this , but I 
couldn't have used it for any of the four audio players on the site.  I agree 
with you that we certainly would have struggled to develop the software for 
the River System in its present form.

From a hardware standpoint we would have been fine for any of the River System 
devices if USB networking could be made to work.   If I were starting today, I 
would seriously consider using a Pi Zero at each location to do the grunt 
work, connected to the Pico's using USB Networking, like I've just done on the 
new Minster hardware.

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Hamish McIntyre-Bhatty
On 21/01/2021 08:11, Terry Coles wrote:
> On Thursday, 21 January 2021 07:59:12 GMT PeterMerchant wrote:
>> I notice that it doesn't have WiFi, and I wonder if it could be programmed
>> from the Arduino IDE as 'c' is mentioned. Perhaps that will come. I have
> Do you not compile the C code before uploading it to an Arduino or similar?  
> I've never used an Arduino but have always assumed that the compiler was in 
> the IDE not the device.
>
>> been using a Wemos D1 which has some of these features plus Wifi, and
>> programmed in c.
> That's an interesting device too, albeit a lot less capable than this latest 
> offering.
>
> The microPython is the attractive thing.  When i was evaluating the options 
> at 
> WMT in 2016, I plumped for the RPi Zero because it was half the price of the 
> cheapest Arduino, but more importantly it supported Python.
>
> Since the WMT is largely maintained by volunteers, I didn't want to use a 
> language that might be hard to use for novices.  Since Python was going up 
> the 
> popularity charts even then, and is quite powerful, I felt it was the right 
> choice.  I still do. 

This is a very interesting product. That said, I agree with you Terry in
that I think it would have been hard to even get Ethernet to work with
something like this, let alone talking to a MySQL database - probably
unsuitable for the River System, or at least the direction it went in
given the hardware we had at the time.

I must admit I struggle to see the difference between a microcontroller
and a very low end SoC/SBC, apart from the analogue inputs (but AFAIK
some SoCs/SBCs include analogue inputs too).

Hamish



signature.asc
Description: OpenPGP digital signature
-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Terry Coles
On Thursday, 21 January 2021 07:59:12 GMT PeterMerchant wrote:
> I notice that it doesn't have WiFi, and I wonder if it could be programmed
> from the Arduino IDE as 'c' is mentioned. Perhaps that will come. I have

Do you not compile the C code before uploading it to an Arduino or similar?  
I've never used an Arduino but have always assumed that the compiler was in 
the IDE not the device.

> been using a Wemos D1 which has some of these features plus Wifi, and
> programmed in c.

That's an interesting device too, albeit a lot less capable than this latest 
offering.

The microPython is the attractive thing.  When i was evaluating the options at 
WMT in 2016, I plumped for the RPi Zero because it was half the price of the 
cheapest Arduino, but more importantly it supported Python.

Since the WMT is largely maintained by volunteers, I didn't want to use a 
language that might be hard to use for novices.  Since Python was going up the 
popularity charts even then, and is quite powerful, I felt it was the right 
choice.  I still do. 

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Raspberry Pi Pico

2021-01-21 Thread Ralph Corderoy
Hi Peter,

> and I wonder if it could be programmed from the Arduino IDE as 'c' is
> mentioned.

Arduino Nano RP2040 Connect

Arduino joins the RP2040 family with one of its most popular
formats: the Arduino Nano.  The Arduino Nano RP2040 Connect combines
the power of RP2040 with high-quality MEMS sensors (a 9-axis IMU and
microphone), a highly efficient power section, a powerful
WiFi/Bluetooth module, and the ECC608 crypto chip, enabling anybody
to create secure IoT applications with this new microcontroller.
The Arduino Nano RP2040 Connect will be available for pre-order in
the next few weeks.

(The RP2040 is the new SoC the Raspberry Pi Foundation have designed for
the Pico.)

> I have been using a Wemos D1 which has some of these features plus
> Wifi, and programmed in c.

That's based on the ESP32, a very popular chip for an embedded processor
coupled with Wi-Fi.

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-02-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk