It is currently May 20th, 2019, 11:42 pm

New WebParser Error detection.

Changes made during the Rainmeter 3.2 beta cycle.
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

New WebParser Error detection.

jsmorley » March 2nd, 2015, 4:26 pm

We have added some new and quite robust error condition detection and actions to WebParser. This will allow you do detect when you either can't connect to a site, or parse the information with RegExp, or both. You can then take whatever action you like in response.

http://docs.rainmeter.net/manual-beta/plugins/webparser#ActionOptions

In addition, we have created a new "Reset" command for WebParser, used with the !CommandMeasure bang, that will allow you to reset the "remembered" values for WebParser parent and related child measures to their initial empty "" values. You might use this in conjunction with the new error actions above.

http://docs.rainmeter.net/manual-beta/plugins/webparser#MeasureCommands
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New WebParser Error detection.

jsmorley » March 2nd, 2015, 4:42 pm

Here is a little example skin to demonstrate one way you might use the new features:
WebServerStatus_1.0.rmskin
WebServerStatus.jpg
Disconnect my network...
2.jpg

Code: Select all

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

[Metadata]
Name=WebServerStatus
Author=JSMorley
Information=Demonstrates how you can do a test of connectivity to a web server. 
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=Mar 2, 2015

[Variables]
HowOften=30

[MeasureLAN]
Measure=Plugin
Plugin=SysInfo
SysInfoType=LAN_CONNECTIVITY
UpdateDivider=#HowOften#
IfCondition=MeasureLAN = 1
IfTrueAction=[!SetOption MeterLANIcon ImageName "GreenLight.png"]
IfFalseAction=[!SetOption MeterLANIcon ImageName "RedLight.png"]
IfConditionMode=1

[MeasureWAN]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
UpdateDivider=#HowOften#
IfCondition=MeasureWAN = 1
IfTrueAction=[!SetOption MeterWANIcon ImageName "GreenLight.png"]
IfFalseAction=[!SetOption MeterWANIcon ImageName "RedLight.png"]
IfConditionMode=1

[MeasureParseSite]
Measure=Plugin
Plugin=WebParser
Url=http://www.msftncsi.com/ncsi.txt
RegExp=^(Microsoft NCSI)$
StringIndex=1
UpdateRate=#HowOften#
FinishAction=[!SetOption MeterSiteIcon ImageName "GreenLight.png"][!SetOption MeterParseIcon ImageName "GreenLight.png"][!SetOption MeterParseText Text ""]
OnConnectErrorAction=[!SetOption MeterSiteIcon ImageName "RedLight.png"][!SetOption MeterParseIcon ImageName "OffLight.png"][!SetOption MeterParseText Text "Unable to Parse"]
OnRegExpErrorAction=[!SetOption MeterSiteIcon ImageName "GreenLight.png"][!SetOption MeterParseIcon ImageName "RedLight.png"][!SetOption MeterParseText Text "Unable to Parse"]

[MeterLANIcon]
Meter=Image
X=0
Y=0
ImagePath=#@#Images\
ImageName=OffLight.png

[MeterLANText]
Meter=String
X=10R
Y=0r
FontSize=11
FontColor=240,226,173,255
SolidColor=0,0,0,1
AntiAlias=1
Text=LAN Connection

[MeterWANIcon]
Meter=Image
X=0
Y=10R
ImagePath=#@#Images\
ImageName=OffLight.png

[MeterWANText]
Meter=String
X=10R
Y=0r
FontSize=11
FontColor=240,226,173,255
SolidColor=0,0,0,1
AntiAlias=1
Text=WAN Connection

[MeterSiteIcon]
Meter=Image
X=0
Y=10R
ImagePath=#@#Images\
ImageName=OffLight.png

[MeterSiteText]
Meter=String
X=10R
Y=0r
FontSize=11
FontColor=240,226,173,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Site Connection

[MeterParseIcon]
Meter=Image
X=0
Y=10R
ImagePath=#@#Images\
ImageName=OffLight.png

[MeterParseText]
Meter=String
MeasureName=MeasureParseSite
X=10R
Y=0r
FontSize=11
FontColor=240,226,173,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Parse Status
You do not have the required permissions to view the files attached to this post.
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: New WebParser Error detection.

moshi » March 4th, 2015, 10:23 am

that's pretty cool.

there is one error left:

the problem is that there's a website that sometimes has wrong/not-existing image urls in it's header's metadata.

when i try to download these, i then get an error like this:
WebParser: Download failed (res=0x800C0006, COM=0x00000000): http://www.heise.de/tp/artikel/44/44279/44279_1.jpg (SphynxNewsTiles\German\Telepolis\regular.ini - [MeasureImage8])
FinishAction would not be executed then.
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New WebParser Error detection.

jsmorley » March 4th, 2015, 11:59 am

Yes moshi, there is no error trapping on the specific "Download=1" functionality. That is really a "child" function in a sense. The connect error trapping is based on connecting to the host in the URL, and the regular expression trapping is base on on the RegExp causing errors, both of which are "parent" functions. While Download=1 can be on a parent measure, the image download doesn't take place in the context of where we can currently return one of those two new error actions.

A similar conundrum can also be seen if you have a URL like:

http://SomeSite.com/SomeFile.html

and SomeFile.html doesn't exist on the server. While that might look like a "connect" error, it isn't. WebParser is able to connect to the HTTP server at SomeSite.com, and so there is no connect error. However, since what will be returned is some "404" HTML, what you will get is a regular expression error on the RegExp side of things, so you can still trap it.

Download=1 in and of itself can't produce a parent connect error, and has no regular expression component, and so will slip through this crack.

Any Downoad=1 on a parent or child measure is not even executed at all if there is a "connect" error on the parent, so that is a non-issue. If the Download=1 is on a pure child measure, it also won't be executed at all if the parent has either kind of error, so that is a non-issue. The problem is going to arise with something like:

URL=http://SomeSite.com/SomeImage.png
Download=1

and the image doesn't exist on the server. FinishAction won't fire, but neither will either error action.

or

URL=http://SomeSite.com
RegExp=(?siU)img src="(.*)"
StringIndex=1
Download=1

and the regular expression is fine, but the image defined in (.*) doesn't exist on the server. FinishAction won't fire, but neither will either error action.

However, this case:

[MeasureParent]
URL=http://SomeSite.com
RegExp=(?siU)img src="(.*)"

[MeasureChild]
URL=[MeasureParent]
StringIndex=1
Download=1

and the parent is entirely successful, but the image doesn't exist on the server. FinishAction on the parent WILL fire, but the Download=1 failure can't be trapped in either the parent (where it just can't be) or in the child, where it probably should be.

So the logical flaws are 1) When Download=1 is on any measure that has "parent" attributes, any failure in Download=1 will stop FinishAction from firing, but won't in and of itself fire any corresponding error action. 2) When Download=1 is on a pure "child" measure, any failure of the download is not trapped as long as the parent "succeeds".

We will continue to look at this. WebParser is functionally complex as the "parent / child" capabilities are both powerful and fragile, and we are very cautious about in any way altering things that can have a cascading effect on backwards compatibility.

P.S. There is one additional anomaly that might come into play. If you are able to successfully download and use an image, and subsequently that image is accidentally deleted or renamed on the server, you won't get the "failure" you might expect. That image will be cached, locally, in your Internet Explorer cache, will get copied to your TEMP\Rainmeter-cache folder, and will continue to apparently succeed - and display the image in your meter, until the IE cache expires or is cleared out. This is not a bad thing, just a thing...