Variables $SummaryByYear and $SummaryByMonth

104 views
Skip to first unread message

Michael Waldor

unread,
Jul 25, 2026, 8:58:03 AM (8 days ago) Jul 25
to weewx-user
Both variables are used within Seasons skin titlebar.inc to populate the month resp. year dropdown. Works fine.

But now I've setup a new weatherstation with incompatible weewx.sdb DB structure (ecowitt_http_driver). Thus I'm forced to start with an empty weewx.sdb (because currently I want to avoid to migrate my old data). The folder  /var/www/html/weewx/NOAA still contains all old summaries, but I can't access them from Seasons gui, probabely because $SummaryByYear and $SummaryByMonth are initialized based on the current weewx.sdb.

Is it possible to get access to the (existing) old NOAA files from within Seasons titlebar.inc? As a final resort I might hardwire the list of years within "my" titlebar.inc, but maybe there is a better solution?

Regards, Michael

Tom Keffer

unread,
Jul 25, 2026, 10:31:56 AM (8 days ago) Jul 25
to weewx...@googlegroups.com
Your question is not entirely clear to me, but what I think you're asking is how do you gain access to the file names from within the webpage.

The answer is that you can't. Modern web browsers don't allow free access to the file system on the client, so you cannot search to see which files have been generated. 

Instead, the dropdown list that you see is created at file generation time. The Cheetah generator keeps track of all files that should be there and populates the list with that. 

If at all possible, you would be best off figuring out some way of migrating your old data to your new weewx.sdb file. Provided the data is still in the flat format used by the database, this should be possible. Have you tried using the "weectl database" utility for adding and removing columns?

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-user/37c7eed3-2bbd-4307-81af-ab61e6aca2efn%40googlegroups.com.

Michael Waldor

unread,
Jul 25, 2026, 11:20:49 AM (8 days ago) Jul 25
to weewx-user
Thanks for your quick reply. The NOAA files are stored within the HTML area served by nginx, thus should be visible for a web browser. Only the selection is not possible because the variables are set by CheetahGenerator - as to be expected.

Thus my best solution will be data migration. The author of the new ecowitt driver even provides an sql script for that purpose. I'll give it a try.

Tom Keffer

unread,
Jul 25, 2026, 11:34:27 AM (8 days ago) Jul 25
to weewx...@googlegroups.com
Client-side Javascript cannot read the web server's file system due to security sandboxing. I can think of a few ways around that, but none is very satisfying.
  1. Turn directory indexing on for the NOAA subdirectory. Then fetch the list of files, parse them, and display. This is probably the best of the alternative approaches. I didn't use this because it requires a user to modify his/her web server configuration.
  2. Include some sort of manifest file, such as noaa.json. Retrieve that, parse, and display. Problem is that the manifest file has to be generated, so you're back to where you started.
  3. Require a backend framework. You read the manifest from an endpoint. Again, this requires users to install infrastructure.
The solution I came up with was the only one that required minimal user modifications. If I have missed an idea, I'd love to hear about it!

-tk


Michael Waldor

unread,
Jul 25, 2026, 12:55:09 PM (8 days ago) Jul 25
to weewx-user
With the help of gemini I could write a small Cheetah script to do what I need - of course this is only a kind of workaround/proof of concept. But it works:
  <div id="reports">
    #import os
    #import fnmatch
    #set $files = os.listdir('/var/www/html/weewx/NOAA')
    #set $months = fnmatch.filter($files, 'NOAA-[0-9][0-9][0-9][0-9]-[0-9][0-9].txt')
    #set $years = fnmatch.filter($files, 'NOAA-[0-9][0-9][0-9][0-9].txt')
    $gettext("Monthly Reports"):
    <select name="reports" onchange="openTabularFile(value)">
      #for $month in $months
     #set $monthYear = os.path.splitext($month)[0]
 #set $monthYear = $monthYear[5:]
      <option value="$monthYear">$monthYear</option>
      #end for
      <option selected>- $gettext("select month") -</option>
    </select>
    <br/>
    $gettext("Yearly Reports"):
    <select name="reports" onchange="openTabularFile(value)">
      #for $year in $years
        #set $yr = os.path.splitext($year)[0]
#set $yr = $yr[5:]
      <option value="$yr">$yr</option>
      #end for
      <option selected>- $gettext("select year") -</option>
    </select>
    <br/>
  </div>
Anyhow I'm really impressed of the power of Cheetah!

Tom Keffer

unread,
Jul 25, 2026, 1:08:11 PM (8 days ago) Jul 25
to weewx...@googlegroups.com
Good idea. It could be packaged as a search list extension.

Of course, that will only get you what is on the computer that is hosting weewx, not what is on the web server. 

Vince Skahan

unread,
Jul 25, 2026, 1:18:43 PM (8 days ago) Jul 25
to weewx-user
Is there a reasonable way to seed (so to speak) the new db with placeholder info so the existing Seasons has whatever it needs to generate the lists of months/years for the historical data ? Seems like a one-time thing might be possible perhaps ?

Michael Waldor

unread,
Jul 26, 2026, 4:56:05 AM (7 days ago) Jul 26
to weewx-user
In the meanwhile I've tweaked my script a little bit to  make it more robust. Sadly, I have to hardcode the path /var/www/html/weewx set within weewx.conf as StdReport.HTML_ROOT. I (and gemini) couldn't find any mechanism to extract that parameter within Cheetah scripting.

Regarding getting access - weewx and nginx run on the same raspberry pi 4, thus the files are accessible without any problem to all web instances.

  <div id="reports">
    #import os
    #import fnmatch
    #set $noaa_dir = os.path.join('/var/www/html/weewx', 'NOAA')
    #if os.path.isdir($noaa_dir)
      #set $files = os.listdir($noaa_dir)
      #set $monthYears = fnmatch.filter($files, 'NOAA-[0-9][0-9][0-9][0-9]-[0-9][0-9].txt')

      #set $years = fnmatch.filter($files, 'NOAA-[0-9][0-9][0-9][0-9].txt')
    $gettext("Monthly Reports"):
    <select name="reports" onchange="openTabularFile(value)">
      #for $entry in $monthYears
 #set $monthYear = $entry[5:-4]

      <option value="$monthYear">$monthYear</option>
      #end for
      <option selected>- $gettext("select month") -</option>
    </select>
    <br/>
    $gettext("Yearly Reports"):
    <select name="reports" onchange="openTabularFile(value)">
      #for $entry in $years
#set $year = $entry[5:-4]
      <option value="$year">$year</option>

      #end for
      <option selected>- $gettext("select year") -</option>
    </select>
    <br/>
    #end if
  </div>

Regards, Michael

Michael Waldor

unread,
Jul 27, 2026, 1:23:08 PM (6 days ago) Jul 27
to weewx-user
Just now I've learned that my old weewx.sdb database is still compatible with my new weatherstation. I've setup that database many years (8) ago. Using sqlitebrowser I have seen that e.g. appTemp is missing in that old database. But using my old datbase works smooth, i.e weewx is more intelligent in handling missing fields as expected. Thus I no longer need to use my workaround to handle NOAA data.
Reply all
Reply to author
Forward
0 new messages