Is there a limit to the size of a plist for tm_dialog? If so, is there a workaround? I think I'm hitting a limit, if I take this shell escaped output and manually trim it, I can run it as a shell script that seems alright:
/usr/lib/ruby/1.8/rexml/encoding.rb:22: command not found: / Applications/TextMate.app/Contents/PlugIns/Dialog.tmplugin/Contents/ Resources/tm_dialog -mp <?xml\ version="1.0"\ encoding="UTF-8 "?>' '<!DOCTYPE\ plist\ PUBLIC\ "-//Apple\ Computer//DTD\ PLIST\ 1.0//EN "\ "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' '<plist\ version="1.0">' '<dict>' ' <key>photosets</key>' ' <array>'
[...hugefrickin'SNIP...]
' <key>title</key>' ' <string>Vista\ Point</string>' ' </dict>' ' </array>' '</dict>' '</plist>' ' select_photoset /tmp/temp_textmate.1kkRWq:88:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 4: syntax error: unexpected end of filecall' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/ progress.rb:36:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of filecall' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/ progress.rb:49:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of filefork' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/ progress.rb:47:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of filedialog' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/ progress.rb:40:in
On 26. Apr 2007, at 02:59, Brett Terpstra wrote:
Is there a limit to the size of a plist for tm_dialog?
There is a limit to how many bytes you can pass as arguments to a shell command, so yes (if you use -p/--parameters)
If so, is there a workaround? [...]
Yes, pass the plist as stdin instead of via -p, then you also do not need to shell escape it.
So from Ruby, with ‘params’ being a ruby hash:
open("|"$DIALOG" -t#{token}", "w") { |io| io << params.to_plist }
Yes, pass the plist as stdin instead of via -p, then you also do not need to shell escape it.
So from Ruby, with ‘params’ being a ruby hash:
open("|\"$DIALOG\" -t#{token}", "w") { |io| io <<
params.to_plist }
OK. Making sense so far, but how is the window token defined, and is it necessary when using a custom nib? I tried using:
plist = { 'photosets' => setarray }.to_plist res = open("|"$DIALOG" -m select_photoset", "w") { |io| io << plist }
and got back what looked like a perfect xml response but with this at the end:
Received exception:undefined method
The problem seems to be in how I'm calling tm_dialog, so I'm hoping it's an obvious solution…
Thanks, Brett
On Apr 25, 2007, at 10:20 PM, Brett Terpstra wrote:
Yes, pass the plist as stdin instead of via -p, then you also do not need to shell escape it.
So from Ruby, with ‘params’ being a ruby hash:
open("|"$DIALOG" -t#{token}", "w") { |io| io << params.to_plist }
OK. Making sense so far, but how is the window token defined, and is it necessary when using a custom nib?
The tokens is returned when you create an async dialog. This being a modal dialog, you don't need one.
got back what looked like a perfect xml response but with this at the end:
Received exception:undefined method
What text appears in the Console log when this happens?
Chris
I had been setting a variable to the open() command, but I think that it returns nil, doesn't it? How do I get the return value from the dialog into a variable using this method? Or is that not the problem...?
Thanks, Brett
On Apr 26, 2007, at 7:46 AM, Chris Thomas wrote:
On Apr 25, 2007, at 10:20 PM, Brett Terpstra wrote:
Yes, pass the plist as stdin instead of via -p, then you also do not need to shell escape it.
So from Ruby, with ‘params’ being a ruby hash:
open("|"$DIALOG" -t#{token}", "w") { |io| io << params.to_plist }
OK. Making sense so far, but how is the window token defined, and is it necessary when using a custom nib?
The tokens is returned when you create an async dialog. This being a modal dialog, you don't need one.
got back what looked like a perfect xml response but with this at the end:
Received exception:undefined method
What text appears in the Console log when this happens?
Chris ______________________________________________________________________ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 26. Apr 2007, at 15:12, Brett Terpstra wrote:
I had been setting a variable to the open() command, but I think that it returns nil, doesn't it? How do I get the return value from the dialog into a variable using this method? Or is that not the problem...?
When you want to both send and receive stdin/out to/from a command, you need to use popen3.
For example like this (untested):
require "open3"
Open3.popen3('"$DIALOG" -m select_photoset') do |stdin, stdout, stderr| stdin << plist; stdin.close res = PropertyList::load(stdout) end
On Apr 26, 2007, at 2:05 PM, Allan Odgaard wrote:
On 26. Apr 2007, at 15:12, Brett Terpstra wrote:
I had been setting a variable to the open() command, but I think that it returns nil, doesn't it? How do I get the return value from the dialog into a variable using this method? Or is that not the problem...?
When you want to both send and receive stdin/out to/from a command, you need to use popen3.
Is that true? I thought that's only if we needed stderr too.
For example like this (untested):
require "open3" Open3.popen3('"$DIALOG" -m select_photoset') do |stdin, stdout,
stderr| stdin << plist; stdin.close res = PropertyList::load(stdout) end
What's wrong with:
IO.popen('"$DIALOG" -m select_photoset') do |dialog| dialog << plist dialog.close_write res = PropertyList::load(dialog) end
?
James Edward Gray II
On 26. Apr 2007, at 21:13, James Edward Gray II wrote:
When you want to both send and receive stdin/out to/from a command, you need to use popen3.
Is that true? I thought that's only if we needed stderr too.
For example like this (untested): [...]
What's wrong with:
IO.popen('"$DIALOG" -m select_photoset') do |dialog| dialog << plist dialog.close_write res = PropertyList::load(dialog) end
?
Oh yeah, that should work -- just the stdlib popen doesn’t do bidirectional pipes, but the Ruby one of course does not suffer from that :)
Got it! Just have to define res=[] before going into it so that res is available outside of the block. Works perfectly, thanks!
Brett
On Apr 26, 2007, at 2:05 PM, Allan Odgaard wrote:
require "open3" Open3.popen3('"$DIALOG" -m select_photoset') do |stdin, stdout,
stderr| stdin << plist; stdin.close res = PropertyList::load(stdout) end
On 26. Apr 2007, at 21:31, Brett Terpstra wrote:
Got it! Just have to define res=[] before going into it so that res is available outside of the block. Works perfectly, thanks!
For popen3 you can also do:
res = Open3.popen3('"$DIALOG" -m select_photoset') do |stdin, stdout, stderr| stdin << plist; stdin.close PropertyList::load(stdout) end
Thanks for the help. Is there any reason to use popen over popen3? Is it just that I don't need popen3 because I'm not using stderr for anything?
On Apr 26, 2007, at 2:43 PM, Allan Odgaard wrote:
On 26. Apr 2007, at 21:31, Brett Terpstra wrote:
Got it! Just have to define res=[] before going into it so that res is available outside of the block. Works perfectly, thanks!
For popen3 you can also do:
res = Open3.popen3('"$DIALOG" -m select_photoset') do |stdin,
stdout, stderr| stdin << plist; stdin.close PropertyList::load(stdout) end
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Hi All,
I am taking my first crack at creating a menu using the TextMate dialog infrastructure. I am trying to integrate a rubyOSA command in the menu to get a list of open FileMaker databases. All seems to be working well except that rubygems are not found when I run the command from the bundle. However, if I run the command from within textmate as just a ruby script it runs fine.
This is the error I get:
/tmp/temp_textmate.HbtlDJ:6:in `require': No such file to load -- rubygems (LoadError) from /tmp/temp_textmate.HbtlDJ:6
Any suggestions would be most appreciated. Thank you so much,
Don Levan
On 26. Apr 2007, at 23:38, Don Levan wrote:
[...] This is the error I get:
/tmp/temp_textmate.HbtlDJ:6:in `require': No such file to load -- rubygems (LoadError) from /tmp/temp_textmate.HbtlDJ:6
Any suggestions would be most appreciated. Thank you so much,
Presumably you both installed a new ruby and rubygems only for this new ruby.
If you set your PATH so that TM finds the new ruby, it should work, see http://macromates.com/textmate/manual/shell_commands#search_path
Be sure to also read the paragraph marked “Important”.
Hi Allan,
Thanks for your help with this. I think I have finally got it set correctly.
Don
On Apr 27, 2007, at 9:56 AM, Allan Odgaard wrote:
On 26. Apr 2007, at 23:38, Don Levan wrote:
[...] This is the error I get:
/tmp/temp_textmate.HbtlDJ:6:in `require': No such file to load -- rubygems (LoadError) from /tmp/temp_textmate.HbtlDJ:6
Any suggestions would be most appreciated. Thank you so much,
Presumably you both installed a new ruby and rubygems only for this new ruby.
If you set your PATH so that TM finds the new ruby, it should work, see http://macromates.com/textmate/manual/shell_commands#search_path
Be sure to also read the paragraph marked “Important”.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 26. Apr 2007, at 22:05, Brett Terpstra wrote:
Thanks for the help. Is there any reason to use popen over popen3? Is it just that I don't need popen3 because I'm not using stderr for anything?
Yeah, no real reason -- I guess popen is more “built in” than popen3 (seeing how you do not need a require).
I think popen just merges stdout and stderr.
So use whatever you think is easiest :) I guess on the previous ground you could say popen3 is better, because if there is some warning or error printed to stderr, it won’t be intermixed with the resulting plist (which would lead to a parse error, even when the plist might have been complete, despite the text sent to stderr).
I want to learn more about this program.
Op 26-apr-07, om 21:05 heeft Allan Odgaard het volgende geschreven:
On 26. Apr 2007, at 15:12, Brett Terpstra wrote:
I had been setting a variable to the open() command, but I think that it returns nil, doesn't it? How do I get the return value from the dialog into a variable using this method? Or is that not the problem...?
When you want to both send and receive stdin/out to/from a command, you need to use popen3.
For example like this (untested):
require "open3" Open3.popen3('"$DIALOG" -m select_photoset') do |stdin, stdout,
stderr| stdin << plist; stdin.close res = PropertyList::load(stdout) end
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate