Copying additional (non-skin) files during report generation

49 views
Skip to first unread message

Peter Fletcher

unread,
Jul 31, 2025, 3:19:53 PMJul 31
to weewx-development
Is there a 'built-in' way of copying the latest version of an external file (which is actually in a different report output folder but could be anywhere else on the system that is running weewx) into a specific report output folder at every reporting cycle. I know that you can specify that skin files be (re-)copied over at each cycle but this is not what I want to do. The file in question is actually the Cumulus current weather data text file, which I currently have being FTPed to one destination and would like to add to the site files being FTPed to a different destination. I am currently using an additional FTP stanza to send the Cumulus file to the second site, but this seems clumsy.
Message has been deleted

Tom Keffer

unread,
Jul 31, 2025, 3:48:15 PMJul 31
to Peter Fletcher, weewx-development
I'm not sure if this answers your question, but I don't see why the files listed under copy_once can't include an absolute path.

For your second question, it's impossible to say without a log. Set debug=2 (sic), restart weewxd, post the log through the first FTP session.

-tk

On Thu, Jul 31, 2025 at 12:37 PM 'Peter Fletcher' via weewx-development <weewx-de...@googlegroups.com> wrote:
Also, the attempted FTP of the file to the additional site doesn't seem to be working, even though weewx is not reporting an error on the FTP.


On Thursday, July 31, 2025 at 3:19:53 PM UTC-4 Peter Fletcher wrote:
Is there a 'built-in' way of copying the latest version of an external file (which is actually in a different report output folder but could be anywhere else on the system that is running weewx) into a specific report output folder at every reporting cycle. I know that you can specify that skin files be (re-)copied over at each cycle but this is not what I want to do. The file in question is actually the Cumulus current weather data text file, which I currently have being FTPed to one destination and would like to add to the site files being FTPed to a different destination. I am currently using an additional FTP stanza to send the Cumulus file to the second site, but this seems clumsy.

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-development/9fb1171e-f5fa-44a2-99ee-7a58c208d5afn%40googlegroups.com.

Peter Fletcher

unread,
Jul 31, 2025, 5:49:01 PMJul 31
to weewx-development
Thanks!
On the first question, I will look again at the CopyGenerator syntax. I had assumed that it could only copy from in its own skin folder.
I had subsequently deleted the second question because I discovered that I was being stupid! In the fairly dim and distant past, I changed the folder on my website that was the target for the FTP copy, but I hadn't deleted the contents of the old folder. I was looking for the new file in the old folder, and (obviously) not finding it! It was being correctly copied to the new folder.

Peter Fletcher

unread,
Jul 31, 2025, 7:21:27 PMJul 31
to weewx-development
Using CopyGenerator does not work. It will accept an absolute path, but it then tries to copy the file over itself - the absolute path is used as source and destination. Here is the error listing from journalctl:
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine: Caught unrecoverable exception in generator 'weewx.reportengine.CopyGenerator'
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****  '/var/www/html/weewx3/realtime.txt' and '/var/www/html/weewx3/realtime.txt' are the same file
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****  Traceback (most recent call last):
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****    File "/home/pi/weewx-venv/lib/python3.11/site-packages/weewx/reportengine.py", line 248, in run
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****      obj.start()
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****    File "/home/pi/weewx-venv/lib/python3.11/site-packages/weewx/reportengine.py", line 465, in start
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****      self.run()
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****    File "/home/pi/weewx-venv/lib/python3.11/site-packages/weewx/reportengine.py", line 621, in run
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****      ncopy += weeutil.weeutil.deep_copy_path(path, html_dest_dir)
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****    File "/home/pi/weewx-venv/lib/python3.11/site-packages/weeutil/weeutil.py", line 1811, in deep_copy_path
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****      shutil.copy(path, d)
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****    File "/usr/lib/python3.11/shutil.py", line 419, in copy
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****      copyfile(src, dst, follow_symlinks=follow_symlinks)
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****    File "/usr/lib/python3.11/shutil.py", line 236, in copyfile
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****      raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****  shutil.SameFileError: '/var/www/html/weewx3/realtime.txt' and '/var/www/html/weewx3/realtime.txt' are the same file
Jul 31 19:05:25 bookwormpi3b weewxd[365083]: ERROR weewx.reportengine:         ****  Generator terminated

On Thursday, July 31, 2025 at 3:48:15 PM UTC-4 Tom Keffer wrote:

Peter Fletcher

unread,
Jul 31, 2025, 10:35:46 PMJul 31
to weewx-development
The answer is a little complicated. What you have to do is create a symbolic link in the skin directory which points to the file you really want to copy. You then tell CopyGenerator to copy the named link. CopyGenerator 'looks through' the symbolic link and copies the original file to the output directory.

Tom Keffer

unread,
Aug 1, 2025, 7:30:15 AMAug 1
to Peter Fletcher, weewx-development
Reply all
Reply to author
Forward
0 new messages