It is currently March 29th, 2024, 1:45 pm

Trying to move Radar GIF files to TEMP folder

Get help with creating, editing & fixing problems with skins
pbutler6
Posts: 100
Joined: April 27th, 2020, 8:10 pm

Trying to move Radar GIF files to TEMP folder

Post by pbutler6 »

The temporary GIF files for my Radar skin are causing problems with my backup software. I am trying to move the temporary GIF files to my TEMP folder where they will not be backed up. I have tried:

Code: Select all

[MeasureImageBosSm]
Measure=WebParser
URL=http://sirocco.accuweather.com/nx_mosaic_640x480_public/sir/inmasirmr_bos.gif
Download=1
ForceReload=1
FinishAction=[!CommandMeasure MeasureExtractBosSm "Run"]

[MeasureExtractBosSm]
Measure=Plugin
Plugin=RunCommand
Program=#@#gif2frames.exe 
Parameter=C:\Users\Peter\AppData\Local\Temp\RainMeter-Cache\inmasirmr_bos.gif
IfCondition=MeasureLocation = 1
IfTrueAction=[!SetOption MeterAnimLoopBosSm ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!SetOption MeterAnimLoopLarge ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!EnableMeasure MeasureAnimLoop]
This works most of the time. However, for some reason the downloaded GIF file is sometimes inmasirmr_bos_1.gif instead of the expected inmasirmr_bos.gif. I assume there is some kind of timing conflict with the download, because the file name can change back and forth every couple of minutes or it can stay the same for hours. When this happens, the extract measure fails and the measure keeps showing the out of date amimation.

I hoped the following would solve the problem:

Code: Select all

[MeasureImageBosSm]
Measure=WebParser
URL=http://sirocco.accuweather.com/nx_mosaic_640x480_public/sir/inmasirmr_bos.gif
Download=1
ForceReload=1
FinishAction=[!CommandMeasure MeasureExtractBosSm "Run"]

[MeasureExtractBosSm]
Measure=Plugin
Plugin=RunCommand
Program=#@#gif2frames.exe 
Parameter=[*MeasureImageBosSm*]
IfCondition=MeasureLocation = 1
IfTrueAction=[!SetOption MeterAnimLoopBosSm ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!SetOption MeterAnimLoopLarge ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!EnableMeasure MeasureAnimLoop]
The log shows the string value of MeasureImageBosSm is C:\Users\Peter\AppData\Local\Temp\RainMeter-Cache\inmasirmr_bos.gif, (or C:\Users\Peter\AppData\Local\Temp\RainMeter-Cache\inmasirmr_bos_1.gif when it changes), but the extract measure does not work.

What am I doing wrong?
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Trying to move Radar GIF files to TEMP folder

Post by mak_kawa »

Hi pbutler6

I am not sure why but to insert !Delay bang before !CommandMeasure bang may solve. And... Parameter=[*MeasureImageBosSm*] must be Parameter=[MeasureImageBosSm]. Further, DynamicVariables=1 is of course necessary.

Following code works well for me. Parameter of the !Delay bang can be tweaked.

Code: Select all

[MeasureImageBosSm]
Measure=WebParser
URL=http://sirocco.accuweather.com/nx_mosaic_640x480_public/sir/inmasirmr_bos.gif
Download=1
ForceReload=1
FinishAction=[!Delay 2000][!CommandMeasure MeasureExtractBosSm "Run"]

[MeasureExtractBosSm]
Measure=Plugin
Plugin=RunCommand
Program=#@#gif2frames.exe
Parameter=[MeasureImageBosSm]
DynamicVariables=1
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to move Radar GIF files to TEMP folder

Post by Yincognito »

pbutler6 wrote: August 18th, 2020, 7:06 pm The temporary GIF files for my Radar skin are causing problems with my backup software. I am trying to move the temporary GIF files to my TEMP folder where they will not be backed up. I have tried:

Code: Select all

[MeasureImageBosSm]
Measure=WebParser
URL=http://sirocco.accuweather.com/nx_mosaic_640x480_public/sir/inmasirmr_bos.gif
Download=1
ForceReload=1
FinishAction=[!CommandMeasure MeasureExtractBosSm "Run"]

[MeasureExtractBosSm]
Measure=Plugin
Plugin=RunCommand
Program=#@#gif2frames.exe 
Parameter=C:\Users\Peter\AppData\Local\Temp\RainMeter-Cache\inmasirmr_bos.gif
IfCondition=MeasureLocation = 1
IfTrueAction=[!SetOption MeterAnimLoopBosSm ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!SetOption MeterAnimLoopLarge ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!EnableMeasure MeasureAnimLoop]
This works most of the time. However, for some reason the downloaded GIF file is sometimes inmasirmr_bos_1.gif instead of the expected inmasirmr_bos.gif. I assume there is some kind of timing conflict with the download, because the file name can change back and forth every couple of minutes or it can stay the same for hours. When this happens, the extract measure fails and the measure keeps showing the out of date amimation.

I hoped the following would solve the problem:

Code: Select all

[MeasureImageBosSm]
Measure=WebParser
URL=http://sirocco.accuweather.com/nx_mosaic_640x480_public/sir/inmasirmr_bos.gif
Download=1
ForceReload=1
FinishAction=[!CommandMeasure MeasureExtractBosSm "Run"]

[MeasureExtractBosSm]
Measure=Plugin
Plugin=RunCommand
Program=#@#gif2frames.exe 
Parameter=[*MeasureImageBosSm*]
IfCondition=MeasureLocation = 1
IfTrueAction=[!SetOption MeterAnimLoopBosSm ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!SetOption MeterAnimLoopLarge ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!EnableMeasure MeasureAnimLoop]
The log shows the string value of MeasureImageBosSm is C:\Users\Peter\AppData\Local\Temp\RainMeter-Cache\inmasirmr_bos.gif, (or C:\Users\Peter\AppData\Local\Temp\RainMeter-Cache\inmasirmr_bos_1.gif when it changes), but the extract measure does not work.

What am I doing wrong?
It is possible that you're not doing anything wrong. If mak_kawa's solution doesn't help (or even if it does) you might want to take a look here, where a somewhat similar approach has been debated and eventually solved for good. Since the thread is extensive and some folks don't have the patience to go through these kind of threads, the short version of it is that the gif2frames/RunCommand approach can sometimes produce "out of sync" scenarios where things don't happen sequentially as desired and different parts of the whole process "overlap". This can cause issues.

That being said, in some cases things work out smoothly, so I don't know if such an issue happens in your case. However, if you have the possibility of getting a PNG containing the frames of that GIF by exploring the page source where I suppose you got the URL address above from, don't hesitate, as the approach of getting a single PNG file and then displaying frames from it using Bitmap meters is much less prone to problems than getting a GIF and extracting the frames from it on the fly - as it was proven towards the end of the thread I linked to above.

Other than that, some links that might help or just be interesting, here and here. The first link appears to mention something similar to what you experienced.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
pbutler6
Posts: 100
Joined: April 27th, 2020, 8:10 pm

Re: Trying to move Radar GIF files to TEMP folder

Post by pbutler6 »

Thanks for the help.

mak_kawa's suggestion fixed the basic updating problem, but then I had 2 animations createdby the extract measure, one for inmasirmr_bos.gif (inmasirmr_bos.gif00001 to 00009) and one for inmasirmr_bos.gif_1.

After following this problem for a couple of days, it looks like the downloaded file toggles between inmasirmr_bos.gif and inmasirmr_bos.gif_1. Only one is in the TEMP folder at any one time. I'm trying this as a simple solution to a complicate issue:

Code: Select all

[MeasureImageBosSm]
Measure=WebParser
URL=http://sirocco.accuweather.com/nx_mosaic_640x480_public/sir/inmasirmr_bos.gif
Download=1
ForceReload=1
FinishAction=[!Delay 2000][!CommandMeasure MeasureExtractBosSm "Run"]

[MeasureExtractBosSm]
Measure=Plugin
Plugin=RunCommand
Program=#@#gif2frames.exe 
Parameter=%TEMP%\RainMeter-Cache\inmasirmr_bos.gif
IfCondition=MeasureLocation=1
IfTrueAction=[!SetOption MeterAnimLoopBosSm ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!SetOption MeterAnimLoopLarge ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!EnableMeasure MeasureAnimLoop]
DynamicVariables=1

[MeasureExtractBosSm1]
Measure=Plugin
Plugin=RunCommand
Program=#@#gif2frames.exe 
Parameter=%TEMP%\RainMeter-Cache\inmasirmr_bos_1.gif
IfCondition=MeasureLocation=1
IfTrueAction=[!SetOption MeterAnimLoopBosSm ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!SetOption MeterAnimLoopLarge ImageName inmasirmr_bos0000[*MeasureAnimLoop*].png][!EnableMeasure MeasureAnimLoop]
DynamicVariables=1
This seems to work (at least in the short term). However, I could suddenly start to get inmasirmr_bos_2.gif, and then things would fail. I would prefer to figure out how to use Yincognito's approach.

When I was saving the temp files to the skin folder I could rename the downloade file with DownloadFile=Newname.gif. How can I specify a name other than inmasirmr_bos.gif for the downloaded file in the TEMP folder?
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to move Radar GIF files to TEMP folder

Post by Yincognito »

pbutler6 wrote: August 19th, 2020, 11:17 pmWhen I was saving the temp files to the skin folder I could rename the downloade file with DownloadFile=Newname.gif. How can I specify a name other than inmasirmr_bos.gif for the downloaded file in the TEMP folder?
I don't think you can. The rule seems to be that if the file is downloaded in the TEMP folder, the file keeps its original name and Windows handles everything, while if the file is downloaded in one of Rainmeter's folders (current skin folder or its DownloadFile subfolder) the name can be changed. That being said, although it's not necessarily about the TEMP folder, you can try using a combination of Debug=2 and Debug2File=SomeExistingPath\SomeFileName.gif options to set the path and the filename as desired.
pbutler6 wrote: August 19th, 2020, 11:17 pmThis seems to work (at least in the short term). However, I could suddenly start to get inmasirmr_bos_2.gif, and then things would fail. I would prefer to figure out how to use Yincognito's approach.
I'm not sure what approach are you talking about. If you're talking about my GIF approach, it was somewhat similar to yours, putting an emphasis to separate the operations (i.e. downloading and extracting) as much as possible in order to avoid overlapping - this worked for me, but didn't always work for the user in the thread I linked to earlier. If you're talking about by PNG/Bitmap meter approach, this will almost certainly work (like it did in the other thread) but the key is finding a replacement for that GIF (similar to what I found here, for example).

In other words, only the 1st option is available at the moment, i.e. the GIF one (for that, try to adapt the code here, it's no big deal, the URLs are different and while there it was Rain and Lightning images, here it's about inmasirmr_bos.gif and inmasirmr_bos_1.gif or whatever they are called). For the 2nd option to be available, you'd need to find an image holding all the frames either horizontally or vertically (so you can show the desired part aka frame using a Bitmap meter).

P.S. Even if the files keep their original names and you use the Download=1 option, I believe you can still check if you need to extract inmasirmr_bos.gif versus inmasirmr_bos_1.gif using an IfMatch on the path+filename returned by Download=1. Or, even better, pass the path and filename directly to the RunCommand measure by using something like Parameter=[MeasureImageBosSm] or even Parameter=#@#gif2frames.exe [MeasureImageBosSm] and no Program option (this of course assumes that you don't use the DownloadFile option). Then, adapt the ImagePath and ImageName options accordingly as well in the Image meter used for animation.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to move Radar GIF files to TEMP folder

Post by Yincognito »

pbutler6 wrote: August 19th, 2020, 11:17 pmI would prefer to figure out how to use Yincognito's approach.
Here it is - feel free to adjust the color, W and H of the background or image, the extent of the Delay, and increase the UpdateWebParser interval to more than the current 60 seconds (600 seconds, aka 10 minutes would be just fine) after you test the code properly:

Code: Select all

[Variables]
BackgroundColor=0,0,0,50
BackgroundColor2=0,0,0,160
UpdateInterval=1000
UpdateWebParser=60
Delay=0
GifFramesCount=6

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

---Measures WebParser---

[MeasureImage]
Measure=WebParser
URL=http://sirocco.accuweather.com/nx_mosaic_640x480_public/sir/inmasirmr_bos.gif
Download=1
DownloadFile=current.gif
ForceReload=1
UpdateRate=1
UpdateDivider=(#UpdateWebParser#*1000/#UpdateInterval#)
FinishAction=[!Log "Download Finished"][!Delay #Delay#][!PauseMeasure "MeasureAnimLoop"][!CommandMeasure MeasureExtract "Run"]
OnConnectErrorAction=[!Log "Connection Error"][!Delay #Delay#][!PauseMeasure "MeasureAnimLoop"][!CommandMeasure MeasureExtract "Run"]
OnDownloadErrorAction=[!Log "Download Error"][!Delay #Delay#][!PauseMeasure "MeasureAnimLoop"][!CommandMeasure MeasureExtract "Run"]
DynamicVariables=1

---Measures RunCommand---

[MeasureExtract]
Measure=Plugin
Plugin=RunCommand
Parameter=gif2frames.exe current.gif
StartInFolder=#CURRENTPATH#DownloadFile
State=Hide
OutputType=ANSI
Timeout=5000
FinishAction=[!Log "Extraction Finished"][!Delay #Delay#][!UnpauseMeasure MeasureAnimLoop]
DynamicVariables=1

---Measures Rainmeter---

[MeasureAnimLoop]
Paused=1
Measure=Calc
Formula=((MeasureAnimLoop%#GifFramesCount#)+1)
RegExpSubstitute=1
Substitute="^(.*)$":"0000\1","^.*(.{5})$":"\1"
DynamicVariables=1

---Meters---

[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,236,236,5 | Fill Color #Backgroundcolor2# | StrokeWidth 1.5 | Stroke Color #Backgroundcolor#

[MeterAnimLoop]
Meter=Image
ImagePath=#CURRENTPATH#DownloadFile
ImageName=current[MeasureAnimLoop].png
PreserveAspectRatio=1
ImageTint=255,255,255,155
X=2r
Y=2r
W=232
H=232
DynamicVariables=1
Like mentioned before, this is based on the already built code from here. I just modified the needed parts and voila. Let me know if and how it works for you, after you properly test it - for me it works just fine after more than 10 Download+Extraction "cycles":
AccuWeather Sirocco Radar.jpg
P.S. In theory, there shouldn't be problems with the changing name of the downloaded GIF, since the name of the file is manually set in the DownloadFile option of [MeasureImage] anyway.

P.S.S. Be aware that when testing, I placed gif2frames.exe in the DownloadFile subfolder of the current skin folder, not in @Resources, as this is the place where the downloaded GIF and the extracted frames reside as well. Obviously, this can also be modified appropriately, if needed.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
pbutler6
Posts: 100
Joined: April 27th, 2020, 8:10 pm

Re: Trying to move Radar GIF files to TEMP folder

Post by pbutler6 »

Again, thank you for your help.

I've made some modifications using Yincognito's code and now have the animation files all in my RainmeterCache folder in my TEMP directory. The downloaded file does toggle names between inmasirmr_bos.gif and inmasirmr_bos_1.gif. If there is a problem downloading a file the name can become inmasirmr_bos_2.gif. The code now handles any of these name changes by changing the string returned by the image download measure [ImageBoston] to the current download file name:

Code: Select all

[MeasureAnimLoop]
Measure=Calc
Formula=(MeasureAnimLoop % 9) + 1
IfEqualValue=5
IfEqualAction=[!SetOption MeasureAnimLoop UpdateDivider 2]
IfAboveValue=5
IfAboveAction=[!SetOption MeasureAnimLoop UpdateDivider 1]
Disabled=1

[ImageBoston]
Measure=WebParser
URL=http://sirocco.accuweather.com/nx_mosaic_234x175_public/sir/inmasirmr_bos.gif
Download=1
ForceReload=1
RegExpSubstitute=1
Substitute="^.*Cache\\(.*)\..*$":"\1"
FinishAction=[!Delay 2000][!EnableMeasure "MeasureAnimLoop"][!CommandMeasure ExtractBoston "Run"]

[ExtractBoston]
Measure=Plugin
Plugin=RunCommand
Program=#@#gif2frames.exe 
Parameter=%TEMP%\RainMeter-Cache\[ImageBoston].gif
State=Hide
OutputType=ANSI
Timeout=5000
IfCondition= #Location#=1
IfTrueAction=[!SetOption MeterAnimLoopBosSm ImageName [*ImageBoston*]0000[*MeasureAnimLoop*].png][!UnpauseMeasure MeasureAnimLoop]
DynamicVariables=1

[MeterAnimLoopBosSm]
Meter=Image
X=1000
Y=0
W=234
PreserveAspectRatio=1
ImagePath=%TEMP%\RainMeter-Cache
DynamicVariables=1
I think I understand most of Yinconito's code. One part I don't understand is:

Code: Select all

State=Hide
OutputType=ANSI
Timeout=5000
What does this code do?
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to move Radar GIF files to TEMP folder

Post by Yincognito »

pbutler6 wrote: August 21st, 2020, 12:32 amI've made some modifications using Yincognito's code and now have the animation files all in my RainmeterCache folder in my TEMP directory. The downloaded file does toggle names between inmasirmr_bos.gif and inmasirmr_bos_1.gif. If there is a problem downloading a file the name can become inmasirmr_bos_2.gif. The code now handles any of these name changes by changing the string returned by the image download measure [ImageBoston] to the current download file name.
As you wish. As far as I could tell, the approach I posted didn't require bothering with the name of the file, but then, it's your skin, your choice and all that. :D
pbutler6 wrote: August 21st, 2020, 12:32 amI think I understand most of Yinconito's code. One part I don't understand is:

Code: Select all

State=Hide
OutputType=ANSI
Timeout=5000
What does this code do?
Hides the cmd.exe window when running the command, sets the character encoding of the text output from the execution of the command to ANSI (this is needed for a good part of the programs one deals with, so you won't see funky characters for no reason), and kills the running program after 5000 milliseconds aka 5 seconds in order to avoid spanning multiple instances of that program by mistake. More on these options here.

Some of these options aren't absolutely needed in your specific case (the first 2, for example), but then they don't hurt either. I just have a habit of including them when writing a RunCommand measure, just in case they are needed.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
pbutler6
Posts: 100
Joined: April 27th, 2020, 8:10 pm

Re: Trying to move Radar GIF files to TEMP folder

Post by pbutler6 »

Your code uses DownloadFile=current.gif which saves the files in the DownloadFile folder of the skin. Saving these files in the skin is causing my backup software to run constantly because these temporary files are constantly being updated. To stop this updating I'm storing the files in my %Temp%/Rainmeter-Cache folder. I can't use DownloadFile= with the %Temp%/Rainmeter-Cache folder, so I can't change the name of the downloaded file.

I would like to clear the %Temp%/RainMeter-Cache/ folder occasionally to get rid of any bad data downloads. To do this, I would like to run the following little .bat file whenever the Radar skin loads.

Code: Select all

cd %Temp%\Rainmeter-Cache
Del inma*.*
The .bat file is stored in my @Resources folder as Delete.Bat. I have tried this code but it doesn't work:

Code: Select all

[DeleteTempFiles]
Measure=Plugin
Plugin=RunCommand
Program=#@#Delete.bat
FinishAction=[!SetOption DeleteTempFiles Disabled 1][!SetVariable Clear 1]
The .bat file works, but the RunCommand Plugin doesn't seem to run the .bat file.

What am I doing wrong?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to move Radar GIF files to TEMP folder

Post by jsmorley »

You need some action that actually fires the RunCommand plugin. Just having the [DeleteTempFiles] measure set up doesn't in and of itself execute the command. There are almost no commands you would ever want to run on each and every update of the skin.

You need an action like:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure DeleteTempFiles "Run"]
There is no need at all to disable the [DeleteTempFiles] measure. It's never going to do ANYTHING unless you explicitly !CommandMeasure it.