Green Building Bible, Fourth Edition |
These two books are the perfect starting place to help you get to grips with one of the most vitally important aspects of our society - our homes and living environment. PLEASE NOTE: A download link for Volume 1 will be sent to you by email and Volume 2 will be sent to you by post as a book. |
Vanilla 1.0.3 is a product of Lussumo. More Information: Documentation, Community Support.
Posted By: borpinBetter if the clients simply send the data regularly or by exception to a 'static' server.There have been a couple of comments on this theme. I'd agree in general but practically it might turn out in this case easier to open a port on the sensor machine's net than the central site's, particularly for Steamy's initial demo (because the sensor is on his home network whereas the central machine is in an office with separate IT people) . All a matter of circumstances. The key is not to have the overall design too dependent on the communications details.
Posted By: SteamyTeaChanged the code above as it was total nonsense.Good, it was. You need to use subprocess.Popen or something to execute a command, you can't just write it in a string.
"%s" % fandata
is pretty meaningless; you might as well just write fandata
I'm not quite sure what you had in mind but perhaps it could be done a little more compactly with "%s\n" % fandata
But thinking about it, as I am using cat, I should be able to just write to an existing file as it concatenates. Is that right?cat concatenates its input files to produce a single output file. (About the only time I use it like that is to concatenate public keys from multiple ssh clients to form the authorized_keys file in the .ssh directory on the host, as I described in email.) To concatenate the output of cat onto an existing file you need to use something else. If it's all on one machine:
cat input1 input2 >> output
adds the contents of the two input files in turn to the output file. Doing redirection like this over ssh or within a Python subprocess.Popen call is more tricky as redirections are handled by the shell (often bash or dash). What I think you want might be done in a shell script on the central data-collection machine using:ssh pi@192.168.1.100 cat "/home/pi/CurrentCost/oneline.csv" >> /home/pi/RemoteData/oneline.csv
You could get a similar effect in a Python script fairly easily but it would be a few lines of code.cat "/home/pi/CurrentCost/oneline.csv" | ssh steamy@server.charity.org tee --append /home/pi/RemoteData/oneline.csv
might append on the server appropriately - with a few tweaks to the file names.