It is currently April 21st, 2019, 5:08 am

Preventing download error in log

Help with creating, editing & fixing problems with skins
User avatar
qwerky
Posts: 180
Joined: April 10th, 2014, 12:31 am
Location: Canada

Preventing download error in log

qwerky » February 10th, 2019, 10:38 pm

This measure:

Code: Select all

[msrGraphic1Icon]
Measure=WebParser
URL=#SiteURL#[msrGraphicGroup]
StringIndex=#GraphicIndexIcon#
Download=1
IfMatch=(?i)\.gif
IfMatchAction=[!ShowMeter mtrDay1Icon]
IfNotMatchAction=[!HideMeter mtrDay1Icon]
works correctly, in that if there is a .gif file, the meter is shown, otherwise the meter is hidden. The only issue is that, when there is no .gif file downloaded, the log shows an error. Is there a way to suppress that error?

The reason the .gif file may be missing, is because when the weather site is read a night, there is no daytime data, including icon; so the value of the measure is null. I see there is a OnDownloadErrorAction option, but I don't know how it would be used for this purpose.
User avatar
jsmorley
Developer
Posts: 19182
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Preventing download error in log

jsmorley » February 11th, 2019, 1:39 am

This is not nearly enough of the code for me to test this and give you a solution. I can't EVER help unless I have enough code to fully test what someone is trying to do, without having to try to create it from scratch myself, which leads to miscommunication.

I simply never give an answer without testing it first.

It would be useful to know what error(s) you are getting in the log as well.
User avatar
balala
Rainmeter Sage
Posts: 8081
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Preventing download error in log

balala » February 11th, 2019, 2:17 pm

qwerky wrote:
February 10th, 2019, 10:38 pm
works correctly, in that if there is a .gif file, the meter is shown, otherwise the meter is hidden. The only issue is that, when there is no .gif file downloaded, the log shows an error. Is there a way to suppress that error?
I completely agree with jsmorley, a few more details would be great to can test, however I'd add two more things:
  • What does returns the [msrGraphicGroup] measure, when there is no icon? If it doesn't return anything, being empty in such cases, then the problem is solved, by add an IfMatch option to disable the current measure ([msrGraphic1Icon]).
  • Also as jsmorley previously explained as reply to one of your own questions, probably would be great to add a & symbol to the measure name used into the URL option URL=#SiteURL#[&msrGraphicGroup], along with a DynamicVariables=1 option (but this definitely doesn't fix the error message issue).
But yes, we're waiting for some details.
User avatar
jsmorley
Developer
Posts: 19182
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Preventing download error in log

jsmorley » February 11th, 2019, 2:24 pm

balala wrote:
February 11th, 2019, 2:17 pm
I completely agree with jsmorley, a few more details would be great to can test, however I'd add two more things:
  • What does returns the [msrGraphicGroup] measure, when there is no icon? If it doesn't return anything, being empty in such cases, then the problem is solved, by add an IfMatch option to disable the current measure ([msrGraphic1Icon]).
  • Also as jsmorley previously explained as reply to one of your own questions, probably would be great to add a & symbol to the measure name used into the URL option URL=#SiteURL#[&msrGraphicGroup], along with a DynamicVariables=1 option (but this definitely doesn't fix the error message issue).
But yes, we're waiting for some details.
It's going to depend a lot on what is generating the error. To determine that, we need the error(s) from the log, and enough code to see the steps you are taking to get to the icon.

If it is failing due to a regular expression error when some higher level parse is being done, due to the entry for the icon not being there, that is one thing. If it is failing due to not being able to find the icon .gif file on the server with Download=1, that is another.

You really can't "disable" WebParser child measures, they are entirely under the control of the parent measure, so that isn't going to end up being the answer.
User avatar
balala
Rainmeter Sage
Posts: 8081
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Preventing download error in log

balala » February 11th, 2019, 2:41 pm

jsmorley wrote:
February 11th, 2019, 2:24 pm
It's going to depend a lot on what is generating the error. To determine that, we need the error(s) from the log, and enough code to see the steps you are taking to get to the icon.
As I said, I completely agree and definitely need a few details. I think a complete code of the related WebParser measures would be enough, then we'll see ourselves what error messages do we get.
jsmorley wrote:
February 11th, 2019, 2:24 pm
You really can't "disable" WebParser child measures, they are entirely under the control of the parent measure, so that isn't going to end up being the answer.
But I don't completely agree with this. As [msrGraphic1Icon] should have to download a file, it can't be completely considered being a child measure. In such cases, when a WebParser measure which downloads an image, gets its URL from another WebParser measure, I usually disable the second measure, then enabling and updating it through a FinishAction option added to the first parent WebParser measure. I do this, exactly to avoid the error messages.
But yes, code would be needed.
User avatar
jsmorley
Developer
Posts: 19182
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Preventing download error in log

jsmorley » February 11th, 2019, 2:46 pm

The error log will tell us a lot. It can be one of "parsing error", "not enough substrings" or "download failure", and they each have different causes and possible solutions.
User avatar
balala
Rainmeter Sage
Posts: 8081
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Preventing download error in log

balala » February 11th, 2019, 2:54 pm

jsmorley wrote:
February 11th, 2019, 2:46 pm
The error log will tell us a lot. It can be one of "parsing error", "not enough substrings" or "download failure", and they each have different causes and possible solutions.
Yep, agree. But the code also would be useful. More useful in my opinion at least.
User avatar
jsmorley
Developer
Posts: 19182
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Preventing download error in log

jsmorley » February 11th, 2019, 5:25 pm

balala wrote:
February 11th, 2019, 2:41 pm
But I don't completely agree with this. As [msrGraphic1Icon] should have to download a file, it can't be completely considered being a child measure. In such cases, when a WebParser measure which downloads an image, gets its URL from another WebParser measure, I usually disable the second measure, then enabling and updating it through a FinishAction option added to the first parent WebParser measure. I do this, exactly to avoid the error messages.
This is true, but keep in mind that once you enable the measure with Download=1 on it, if the image isn't there or can't be parsed on subsequent updates of the parent measure, when UpdateRate is reached, then it will start producing errors again.
User avatar
jsmorley
Developer
Posts: 19182
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Preventing download error in log

jsmorley » February 11th, 2019, 5:53 pm

I would be tempted to do something like:

Skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureSite]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)(?(?=<image>)<image>(.*)</image>)
UpdateRate=20
LogSubstringErrors=0

[MeasureImageParse]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
IfMatch=^.*$
IfMatchAction=[!DisableMeasure MeasureImageGet]
IfNotMatchAction=[!EnableMeasure MeasureImageGet]

[MeasureImageGet]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
Download=1

[MeterImage]
Meter=Image
MeasureName=MeasureImageGet
Good Test.html:

Code: Select all

<image>https://forum.rainmeter.net/styles/elegance/theme/images/logo.png</image>
Bad Test.html:

Code: Select all

<image></image>
or:

Code: Select all

<badTag>https://forum.rainmeter.net/styles/elegance/theme/images/logo.png</image>
So I am doing several things:

1) Using a lookahead assertion in the RegExp, to stop it from blowing up entirely if it can't parse correctly. Instead, it will "succeed", but won't create any (capture) or StringIndex.
2) Using LogSubtstringErrors=0, to keep the above from generating errors on "child" measures.
3) Creating a pure "child" measure to get the value from StringIndex=1 from the "parent". This will be "" if the parent has not returned a (capture).
4) Having an IfMatchAction on this child "enable" or "disable" another measure that will do the downloading.

This approach should either return the image (complete success) or nothing (can't parse, missing image location). There should not be any errors in the log, on load or on subsequent updates if things change on the site.

The only thing that can and will produce an error in the log is if the name of the file is in fact in the <name></name> tags, but doesn't actually exist on the server. This would seem very unlikely to me, and in any case really should generate a warning.
User avatar
qwerky
Posts: 180
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Preventing download error in log

qwerky » February 11th, 2019, 6:13 pm

Apologies for the lack of information. First the error message. I can't remember the exact wording, and it only appears during nighttime hours, not daytime hours. However, I do know that it is the "download failure" message you mentioned, not either of the other two.

Now the code (with all variables either listed or resolved):

Code: Select all

[Variables]
SiteURL=https://weather.gc.ca
PageURL=https://weather.gc.ca/city/pages/on-143_metric_e.html

; regexBase strings:  1 Header, 2 Current Conditions, 3 Forecast Issue Time, 4 Graphic Forecast, 5 Detailed Forecast, 6 Normals, 7 Averages, 8 Yesterday
regexBase=(?siU)property="mainContentOfPage"(.*)</ul>(.*)<h2>Forecast.*Forecast(.*)>(.*)Detailed Forecast(.*)Normals:(.*)<h2>Averages(.*)<h2>Yesterday(.*)</details>

; regexGraphic strings:  Day 1:   1 Weekday,  2 Date,  3 Month,  4 Icon,  5 High Temperature,  6 Day POP,   7 Day Text,  8 Low Temperature,  9 Night POP, 10 Night Text
;                        Day 2:  11 Weekday, 12 Date, 13 Month, 14 Icon, 15 High Temperature, 16 Day POP,  17 Day Text, 18 Low Temperature, 19 Night POP, 20 Night Text
;                        Day 3:  21 Weekday, 22 Date, 23 Month, 24 Icon, 25 High Temperature, 26 Day POP,  27 Day Text, 28 Low Temperature, 29 Night POP, 30 Night Text
;                        Day 4:  31 Weekday, 32 Date, 33 Month, 34 Icon, 35 High Temperature, 36 Day POP,  37 Day Text, 38 Low Temperature, 39 Night POP, 40 Night Text
;                        Day 5:  41 Weekday, 42 Date, 43 Month, 44 Icon, 45 High Temperature, 46 Day POP,  47 Day Text, 48 Low Temperature, 49 Night POP, 50 Night Text
;                        Day 6:  51 Weekday, 52 Date, 53 Month, 54 Icon, 55 High Temperature, 56 Day POP,  57 Day Text, 58 Low Temperature, 59 Night POP, 60 Night Text
;                        Day 7:  61 Weekday, 62 Date, 63 Month, 64 Icon, 65 High Temperature, 66 Day POP,  67 Day Text
regexGraphNight=.*div-row4.*title="min">(.*)<.*<p class=".*"(?(?= title).*>.*>(.*)<).*<p class.*>(.*)<
regexGraphDay=.*title="(.*)".*br>(\d+)[^\d].*title="(.*)".*<img.*src="(.*)".*title="max">(.*)<.*<p class=".*"(?(?= title).*>.*>(.*)<).*<p class.*>(.*)<
regexGraphic=(?siU).*div-row1 div-row-head(?(?=")#regexGraphDay#)#regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay##regexGraphNight##regexGraphDay#

[msrSite]
Measure=WebParser
URL=#PageURL#
RegExp=#regexBase#
UpdateRate=600
FinishAction=[!SetOption msrHeaderAlertPage URL "#siteURL#[*&msrHeaderAlertURL*]"][!CommandMeasure msrHeaderAlertPage "Update"]

[msrGraphicGroup]
Measure=WebParser
URL=[msrSite]
RegExp=#regexGraphic#
StringIndex=4

[msrGraphic1Icon]
Measure=WebParser
URL=#SiteURL#[msrGraphicGroup]
StringIndex=4
Download=1
IfMatch=(?i)\.gif
IfMatchAction=[!ShowMeter mtrDay1Icon]
IfNotMatchAction=[!HideMeter mtrDay1Icon]
If you visit the #PageURL# page, and scroll down, you will see the graphic forecast: a row of seven Day boxes, and below that, a row of seven Night boxes. The seventh Night box is always empty.

Right now, the first Day box is populated, and it is that icon which is being downloaded in the above measure. During the night, however, that first Day box is empty (just like the last Night box), and there is therefore no icon to download.

Hope this is sufficient information.