It is currently August 9th, 2020, 8:23 am

RunCommand

Share and get help with Plugins and Addons
User avatar
moshi
Posts: 1850
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - WIP (0.0.0.3)

Post by moshi »

i am having some trouble with OutputFile & OutputType

i try to use wget with Google Translate (i know i just could use WebParser).

the result i get is:

Code: Select all

[[["Übersetzung","translation","",""]],[["noun",["Übersetzung","Übertragung","Entrückung","Wiedergabe"],[["Übersetzung",["translation","transmission","version","gearing"],,0.666143596],["Übertragung",["transmission","transfer","transference","communication","broadcast","translation"],,0.000911881973],["Entrückung",["rapture","translation","ecstasy"],,3.42696658e-05],["Wiedergabe",["playback","reproduction","rendition","rendering","representation","repetition"],,2.78527239e-07]],"translation",1]],"en
now there's some weird characters there. surprisingly when i put this in a text file, WebParser can read it just fine (default codepage setting probably):

Code: Select all

[[["Übersetzung","translation","",""]],[["noun",["Übersetzung","Übertragung","Entrückung","Wiedergabe"],[["Übersetzung",["translation","transmission","version","gearing"],,0.666143596],["Übertragung",["transmission","transfer","transference","communication","broadcast","translation"],,0.000911881973],["Entrückung",["rapture","translation","ecstasy"],,3.42696658e-05],["Wiedergabe",["playback","reproduction","rendition","rendering","representation","repetition"],,2.78527239e-07]],"translation",1]],"en
so my thought was why not using OutputFile, and read that file with Webparser. when i use OutputType=Unicode i will get Chinese in in both the output and the output file, as expected.
but when i use OutputType=Ansi, all i get in the output file is:

Code: Select all

[[["Ã
and WebParser reads:

Code: Select all

[[["�

what i try to use is:

Code: Select all

[Command_C1]
Measure=Plugin
Plugin=RunCommand
Program=""#@#Addons\wget\wget.exe""
Parameter=-U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=translation&sl=auto&tl=de"
State=Hide
OnChangeAction=[!UpdateMeter *][!Redraw]
RegExpSubstitute=1
OutputType=Ansi
Outputfile="#@#translation.txt"
i use wget from the UnxUtils http://unxutils.sourceforge.net/
User avatar
moshi
Posts: 1850
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - WIP (0.0.0.3)

Post by moshi »

a CodePage setting could be nice for OutputType=Ansi settings.

i also noted with your example skin when i set OutputType=Ansi to [Command_1], the output becomes:

Code: Select all

   1111  
with Auto or Unicode it is:

Code: Select all

 Datenträger in Laufwerk C: ist Festplatte
 Volumeseriennummer: 48C9-F201

 Verzeichnis von C:\Users\Alex\Documents\Rainmeter\Skins\RunCommand

15.10.2013  21:35    <DIR>          .
15.10.2013  21:35    <DIR>          ..
17.10.2013  17:03             1.925 RunCommand.ini
17.10.2013  17:03               878 test.txt
               2 Datei(en),          2.803 Bytes
               2 Verzeichnis(se), 113.566.109.696 Bytes frei
User avatar
Brian
Developer
Posts: 2044
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand - WIP (0.0.0.3)

Post by Brian »

moshi wrote:so my thought was why not using OutputFile, and read that file with Webparser. when i use OutputType=Unicode i will get Chinese in in both the output and the output file, as expected.
but when i use OutputType=Ansi, all i get in the output file is:

Code: Select all

[[["Ã
and WebParser reads:

Code: Select all

[[["�
This "seems" like a problem with writing to the file with a default CodePage rather then using the user's current CodePage (which is supposed to happen, if I am understanding the documentation for the function correctly). Adding a CodePage option is not something I am totally comfortable with at the moment given my lack of knowledge in that area.

This problem seems to happen only when trying to encode to OutputFile to ANSI. I think the best solution may be to just encode all OutputFile's to UTF-16LE (like version 0.0.0.2). OutputType will still indicate what "type" of encoding is expected, but the OutputFile will always be UTF-16LE.



Moshi: Could you try this version? Just place the correct .dll in your "%APPDATA%\Rainmeter\Plugins" folder (assuming you using a standard installation, of course). I included both 32 and 64 bit versions.
RunCommand.dll (v.0.0.0.3a).rar
This version changes 2 things. 1) OutputFile will always be UTF-16LE encoded. I hope this fixes the problem described above. 2) I have removed internal timeout that would "wait" for a FinishAction to finish before updating the string value of the plugin (the problem we have been discussing here), and have gone a different route.



BTW - The reason OutputType=Ansi did not work for the "dir" command, is because the default program is "cmd.exe /U /C" which encodes output in UTF-16LE. Remember, the OutputType option is declare what type of output is to be expected, not necessarily what you want it to be. If "Auto" doesn't work, then try "Ansi" or "Unicode" until it displays correctly.

-Brian
You do not have the required permissions to view the files attached to this post.
User avatar
moshi
Posts: 1850
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - WIP (0.0.0.3)

Post by moshi »

i tried the new version.

i did not notice a difference on the second issue. maybe my computer is too slow, or my stress test too heavy. i am running several calendar skins similar too the one i posted above. a !RefreshAll will almost always result in at least one measure without output.

on the first issue: i think this solution is bad. because it turns output that only looks like gibberish but that could actually be useful with the right codepage settings into real, useless gibberish.
i think it will work nicely with local data, but for the wget example (and just imagine what would be possible for Rainmeter with curl) it is not ideal.
User avatar
Brian
Developer
Posts: 2044
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand - WIP (0.0.0.3)

Post by Brian »

moshi wrote:i did not notice a difference on the second issue. maybe my computer is too slow, or my stress test too heavy. i am running several calendar skins similar too the one i posted above. a !RefreshAll will almost always result in at least one measure without output.
Hmmm. I am all out of ideas on fixing this issue. I guess it is possible that the program ran so fast that my plugin did not catch the output in time. That shouldn't happen since the plugin runs in its own thread, but possible.
moshi wrote:on the first issue: i think this solution is bad. because it turns output that only looks like gibberish but that could actually be useful with the right codepage settings into real, useless gibberish.
i think it will work nicely with local data, but for the wget example (and just imagine what would be possible for Rainmeter with curl) it is not ideal.
Did you happen to try your wget example with that special version I gave you? I only ask because I think the problem only happened when writing to a file.


I will look into adding a CodePage option, but I am not promising anything.

-Brian
User avatar
moshi
Posts: 1850
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - WIP (0.0.0.3)

Post by moshi »

let's say you have an output like Entrückung

saved in an ANSI file with the matching codepage setting that means "Entrückung", which is a German word.

saved in a Unicode file that means just "Entrückung", which is nonsensical.
User avatar
moshi
Posts: 1850
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - WIP (0.0.0.3)

Post by moshi »

i have attached two example files that are in the needed format. i am not completely sure what encoding is used here. there seem to be at least three different types of UTF-8 encoding.

Language1.txt is using Hindi/Devanagari characters, Language2.txt is using Chinese characters


in notepad.exe it says it is encoded as "UTF-8" and the file displays as:

Code: Select all

[[["अनुवाद","Translation","Anuvāda",""]],[["noun",["अनुवाद","अनुवाद करना","उलथा करना","भाषांतर","बदली","अंतरण"],[["अनुवाद",["translation","rendering","version","rending","rendition"],,0.791065097],["अनुवाद करना",["translation"],,0.000911881973],["उलथा करना",["translation"],,0.000194150867],["भाषांतर",["translation","version"],,0.000123409802],["बदली",["change","transfer","changing","stopgap","transposition","translation"],,2.66892421e-05],["अंतरण",["transferal","translation"],,2.62754638e-05]],"translation",1]],"en",,[["अनुवाद",[4],1,0,1000,0,1,0]],[["Translation",4,[["अनुवाद",1000,1,0],["अनुवाद में",0,1,0],["रूपांतर",0,1,0],["अनुवाद के",0,1,0],["ट्रांसलेशन",0,1,0]],[[0,11]],"Translation"]],,,[],41]

in SciTE it says the encoding is "Code Page Property", and not "UTF-8" or "UTF-8 with BOM". it displays in SciTE as:

Code: Select all

[[["अनुवाद","Translation","Anuvāda",""]],[["noun",["अनुवाद","अनुवाद करना","उलथा करना","भाषांतर","बदली","अंतरण"],[["अनुवाद",["translation","rendering","version","rending","rendition"],,0.791065097],["अनुवाद करना",["translation"],,0.000911881973],["उलथा करना",["translation"],,0.000194150867],["भाषांतर",["translation","version"],,0.000123409802],["बदली",["change","transfer","changing","stopgap","transposition","translation"],,2.66892421e-05],["अंतरण",["transferal","translation"],,2.62754638e-05]],"translation",1]],"en",,[["अनुवाद",[4],1,0,1000,0,1,0]],[["Translation",4,[["अनुवाद",1000,1,0],["अनुवाद में",0,1,0],["रूपांतर",0,1,0],["अनुवाद के",0,1,0],["ट्रांसलेशन",0,1,0]],[[0,11]],"Translation"]],,,[],57]
and this is also the output of the RunCommand plugin.


now, having what notepad.exe displays being saved as "UTF-16 Little Endian" would be great.
but what your plugin does is saving what SciTE displays (=RunCommand output) as "UTF-16 Little Endian" and that ends up being gibberish.

maybe what would be needed for this to work would be an ANSI output file with CodePage=65001. as paradox as it sounds. :confused: :???: :?


edit: i should add that these are the type of files that both wget with the > redirection, and the WebParser plugin with DownloadFile save.
wget's output at the command line is also gibberish with different characters than the RunCommand output.
You do not have the required permissions to view the files attached to this post.
Last edited by moshi on October 18th, 2013, 7:57 am, edited 2 times in total.
User avatar
moshi
Posts: 1850
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - WIP (0.0.0.3)

Post by moshi »

this is getting weirder:

when i set OutputType=Unicode

the output is:

Code: Select all

孛≛ꓠꢤꗠ떤ꓠꚤⰢ吢慲獮慬楴湯Ⱒ䄢畮쑶撁≡∬崢ⱝ孛渢畯≮嬬薤ꓠ膥ꓠ뺤ꓠ⊦∬ꓠꢤꗠ떤ꓠꚤ閤ꓠꢤꓠ⊾∬ꓠ늤ꓠ뺤閤ꓠꢤꓠ⊾∬ꓠ뺤ꓠ뺤ꓠ꒤ꓠ⊰∬ꓠꚤꓠ肥Ⱒ薤ꓠ꒤ꓠꎤ崢嬬≛ꓠꢤꗠ떤ꓠꚤⰢ≛牴湡汳瑡潩≮∬敲摮牥湩≧∬敶獲潩≮∬敲摮湩≧∬敲摮瑩潩≮ⱝ〬㜮ㄹ㘰〵㜹ⱝ≛ꓠꢤꗠ떤ꓠꚤ閤ꓠꢤꓠ⊾嬬琢慲獮慬楴湯崢Ⱜ⸰〰㤰ㄱ㠸㤱㌷ⱝ≛ꓠ늤ꓠ뺤閤ꓠꢤꓠ⊾嬬琢慲獮慬楴湯崢Ⱜ⸰〰㄰㐹㔱㠰㜶ⱝ≛ꓠ뺤ꓠ뺤ꓠ꒤ꓠ⊰嬬琢慲獮慬楴湯Ⱒ瘢牥楳湯崢Ⱜ⸰〰㄰㌲〴㠹㈰ⱝ≛ꓠꚤꓠ肥Ⱒ≛档湡敧Ⱒ琢慲獮敦≲∬档湡楧杮Ⱒ猢潴杰灡Ⱒ琢慲獮潰楳楴湯Ⱒ琢慲獮慬楴湯崢Ⱜ⸲㘶㤸㐲ㄲⵥ㔰ⱝ≛ꓠ芤ꓠ낤ꓠ⊣嬬琢慲獮敦慲≬∬牴湡汳瑡潩≮ⱝ㈬㘮㜲㐵㌶攸〭崵ⱝ琢慲獮慬楴湯Ⱒ崱ⱝ攢≮Ⱜ孛薤ꓠ膥ꓠ뺤ꓠ⊦嬬崴ㄬ〬ㄬ〰ⰰⰰⰱ崰ⱝ孛吢慲獮慬楴湯Ⱒⰴ孛薤ꓠ膥ꓠ뺤ꓠ⊦ㄬ〰ⰰⰱ崰嬬薤ꓠ膥ꓠ뺤ꓠ₦ꓠ螥ꓠ⊂〬ㄬ〬ⱝ≛ꓠ芥ꓠ뺤ꓠ꒤ꓠ⊰〬ㄬ〬ⱝ≛ꓠꢤꗠ떤ꓠꚤ閤ꗠ⊇〬ㄬ〬ⱝ≛ꓠ趥ꓠ뺤ꓠ뢤ꓠ螥ꓠꢤⰢⰰⰱ崰ⱝ孛ⰰㄱ嵝∬牔湡汳瑡潩≮嵝Ⱜ嬬ⱝ崲
same with the saved output file in notepad.exe or Scite.
same if i parse the file with WebParser and CodePage=1200 (UTF-16 Little Endian)

but if i parse the file with WebParser and the default CodePage setting, i get:

Code: Select all

��[[["अनुवाद","Translation","Anuvāda",""]],[["noun",["अनुवाद","अनुवाद करना","उलथा करना","भाषांतर","बदली","अंतरण"],[["अनुवाद",["translation","rendering","version","rending","rendition"],,0.791065097],["अनुवाद करना",["translation"],,0.000911881973],["उलथा करना",["translation"],,0.000194150867],["भाषांतर",["translation","version"],,0.000123409802],["बदली",["change","transfer","changing","stopgap","transposition","translation"],,2.66892421e-05],["अंतरण",["transferal","translation"],,2.62754638e-05]],"translati ...
this appears to be correct, except for the leading control characters.
Last edited by moshi on October 18th, 2013, 7:39 am, edited 2 times in total.
User avatar
moshi
Posts: 1850
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - WIP (0.0.0.3)

Post by moshi »

so it seems the RunCommand plugin currently has no way to display the correct output for incoming UTF-8 encoded data, no matter whether OutputType is set to ANSI or Unicode.

with OutputFile set, you can at least get a text file that the WebParser plugin can deal with, but not a text editor or the Quote plugin.

maybe a new OutputType for UTF-8 would be a step in the right direction?
User avatar
moshi
Posts: 1850
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - WIP (0.0.0.3)

Post by moshi »

moshi wrote:wget's output at the command line is also gibberish with different characters than the RunCommand output.
this can be fixed easily with running a batch file with chcp 65001, the output at the command line is nice then.
running the batch file with RunCommand has no effect on special characters.