redcar 0.3.7.1 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/CHANGES +16 -0
  2. data/README.md +5 -0
  3. data/ROADMAP.md +7 -9
  4. data/Rakefile +55 -22
  5. data/lib/redcar.rb +12 -6
  6. data/lib/redcar/installer.rb +119 -44
  7. data/plugins/application/features/step_definitions/speedbar_steps.rb +62 -0
  8. data/plugins/application/features/step_definitions/tree_steps.rb +3 -3
  9. data/plugins/application/features/support/env.rb +2 -1
  10. data/plugins/application/lib/application/notebook.rb +53 -7
  11. data/plugins/application/lib/application/speedbar.rb +12 -0
  12. data/plugins/application/lib/application/tab.rb +16 -5
  13. data/plugins/application/lib/application/treebook.rb +21 -1
  14. data/plugins/application_swt/lib/application_swt.rb +12 -2
  15. data/plugins/application_swt/lib/application_swt/html_tab.rb +4 -0
  16. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -3
  17. data/plugins/application_swt/lib/application_swt/speedbar.rb +15 -27
  18. data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +1 -0
  19. data/plugins/application_swt/lib/application_swt/tab.rb +1 -0
  20. data/plugins/application_swt/lib/application_swt/treebook.rb +36 -8
  21. data/plugins/application_swt/lib/application_swt/window.rb +24 -18
  22. data/plugins/auto_completer/lib/auto_completer.rb +5 -20
  23. data/plugins/core/lib/core.rb +7 -4
  24. data/plugins/core/lib/core/observable_struct.rb +2 -2
  25. data/plugins/declarations/lib/declarations.rb +3 -17
  26. data/plugins/document_search/features/search.feature +163 -0
  27. data/plugins/document_search/features/support/env.rb +4 -0
  28. data/plugins/document_search/lib/document_search.rb +121 -0
  29. data/plugins/document_search/plugin.rb +8 -0
  30. data/plugins/edit_view/features/line_delimiter.feature +7 -0
  31. data/plugins/edit_view/features/step_definitions/editing_steps.rb +49 -1
  32. data/plugins/edit_view/features/step_definitions/tab_steps.rb +10 -11
  33. data/plugins/edit_view/features/switch_tabs.feature +61 -10
  34. data/plugins/edit_view/lib/edit_view.rb +4 -0
  35. data/plugins/edit_view/lib/edit_view/document.rb +56 -0
  36. data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
  37. data/plugins/edit_view/lib/edit_view/edit_tab.rb +0 -8
  38. data/plugins/edit_view_swt/lib/edit_view_swt.rb +4 -0
  39. data/plugins/html_view/lib/html_controller.rb +19 -1
  40. data/plugins/html_view/lib/html_view.rb +28 -1
  41. data/plugins/html_view/lib/html_view/html_tab.rb +10 -1
  42. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +3 -1
  43. data/plugins/project/features/open_directory_tree.feature +3 -3
  44. data/plugins/project/lib/project.rb +4 -6
  45. data/plugins/project/lib/project/commands.rb +17 -0
  46. data/plugins/project/lib/project/dir_controller.rb +2 -1
  47. data/plugins/project/lib/project/dir_mirror.rb +8 -0
  48. data/plugins/project/lib/project/manager.rb +2 -0
  49. data/plugins/project/plugin.rb +2 -1
  50. data/plugins/project/vendor/net-sftp/Manifest +55 -0
  51. data/plugins/project/vendor/net-sftp/Rakefile +30 -0
  52. data/plugins/project/vendor/net-sftp/lib/net/sftp.rb +70 -0
  53. data/plugins/project/vendor/net-sftp/lib/net/sftp/constants.rb +187 -0
  54. data/plugins/project/vendor/net-sftp/lib/net/sftp/errors.rb +39 -0
  55. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/dir.rb +93 -0
  56. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/download.rb +364 -0
  57. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file.rb +176 -0
  58. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file_factory.rb +60 -0
  59. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/upload.rb +387 -0
  60. data/plugins/project/vendor/net-sftp/lib/net/sftp/packet.rb +21 -0
  61. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol.rb +32 -0
  62. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/attributes.rb +315 -0
  63. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/base.rb +268 -0
  64. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/name.rb +43 -0
  65. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/02/base.rb +31 -0
  66. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/03/base.rb +35 -0
  67. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/attributes.rb +152 -0
  68. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/base.rb +94 -0
  69. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/name.rb +67 -0
  70. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/05/base.rb +66 -0
  71. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/attributes.rb +107 -0
  72. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/base.rb +63 -0
  73. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/base.rb +50 -0
  74. data/plugins/project/vendor/net-sftp/lib/net/sftp/request.rb +91 -0
  75. data/plugins/project/vendor/net-sftp/lib/net/sftp/response.rb +76 -0
  76. data/plugins/project/vendor/net-sftp/lib/net/sftp/session.rb +951 -0
  77. data/plugins/project/vendor/net-sftp/lib/net/sftp/version.rb +18 -0
  78. data/plugins/project/vendor/net-sftp/setup.rb +1331 -0
  79. data/plugins/project/vendor/net-sftp/test/common.rb +171 -0
  80. data/plugins/project/vendor/net-sftp/test/protocol/01/test_attributes.rb +97 -0
  81. data/plugins/project/vendor/net-sftp/test/protocol/01/test_base.rb +210 -0
  82. data/plugins/project/vendor/net-sftp/test/protocol/01/test_name.rb +27 -0
  83. data/plugins/project/vendor/net-sftp/test/protocol/02/test_base.rb +26 -0
  84. data/plugins/project/vendor/net-sftp/test/protocol/03/test_base.rb +27 -0
  85. data/plugins/project/vendor/net-sftp/test/protocol/04/test_attributes.rb +148 -0
  86. data/plugins/project/vendor/net-sftp/test/protocol/04/test_base.rb +74 -0
  87. data/plugins/project/vendor/net-sftp/test/protocol/04/test_name.rb +53 -0
  88. data/plugins/project/vendor/net-sftp/test/protocol/05/test_base.rb +62 -0
  89. data/plugins/project/vendor/net-sftp/test/protocol/06/test_attributes.rb +124 -0
  90. data/plugins/project/vendor/net-sftp/test/protocol/06/test_base.rb +51 -0
  91. data/plugins/project/vendor/net-sftp/test/protocol/test_base.rb +42 -0
  92. data/plugins/project/vendor/net-sftp/test/test_all.rb +7 -0
  93. data/plugins/project/vendor/net-sftp/test/test_dir.rb +47 -0
  94. data/plugins/project/vendor/net-sftp/test/test_download.rb +252 -0
  95. data/plugins/project/vendor/net-sftp/test/test_file.rb +159 -0
  96. data/plugins/project/vendor/net-sftp/test/test_file_factory.rb +48 -0
  97. data/plugins/project/vendor/net-sftp/test/test_packet.rb +9 -0
  98. data/plugins/project/vendor/net-sftp/test/test_protocol.rb +17 -0
  99. data/plugins/project/vendor/net-sftp/test/test_request.rb +71 -0
  100. data/plugins/project/vendor/net-sftp/test/test_response.rb +53 -0
  101. data/plugins/project/vendor/net-sftp/test/test_session.rb +741 -0
  102. data/plugins/project/vendor/net-sftp/test/test_upload.rb +219 -0
  103. data/plugins/project/vendor/net-ssh/Manifest +110 -0
  104. data/plugins/project/vendor/net-ssh/Rakefile +85 -0
  105. data/plugins/project/vendor/net-ssh/Rudyfile +96 -0
  106. data/plugins/project/vendor/net-ssh/lib/net/ssh.rb +215 -0
  107. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/agent.rb +179 -0
  108. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/constants.rb +18 -0
  109. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/key_manager.rb +193 -0
  110. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  111. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
  112. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
  113. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/password.rb +39 -0
  114. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/publickey.rb +92 -0
  115. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/pageant.rb +183 -0
  116. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/session.rb +134 -0
  117. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffer.rb +340 -0
  118. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffered_io.rb +198 -0
  119. data/plugins/project/vendor/net-ssh/lib/net/ssh/config.rb +202 -0
  120. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/channel.rb +630 -0
  121. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/constants.rb +33 -0
  122. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/session.rb +597 -0
  123. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/term.rb +178 -0
  124. data/plugins/project/vendor/net-ssh/lib/net/ssh/errors.rb +85 -0
  125. data/plugins/project/vendor/net-ssh/lib/net/ssh/key_factory.rb +102 -0
  126. data/plugins/project/vendor/net-ssh/lib/net/ssh/known_hosts.rb +129 -0
  127. data/plugins/project/vendor/net-ssh/lib/net/ssh/loggable.rb +61 -0
  128. data/plugins/project/vendor/net-ssh/lib/net/ssh/packet.rb +102 -0
  129. data/plugins/project/vendor/net-ssh/lib/net/ssh/prompt.rb +93 -0
  130. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/command.rb +75 -0
  131. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/errors.rb +14 -0
  132. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/http.rb +94 -0
  133. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks4.rb +70 -0
  134. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks5.rb +142 -0
  135. data/plugins/project/vendor/net-ssh/lib/net/ssh/ruby_compat.rb +43 -0
  136. data/plugins/project/vendor/net-ssh/lib/net/ssh/service/forward.rb +288 -0
  137. data/plugins/project/vendor/net-ssh/lib/net/ssh/test.rb +89 -0
  138. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/channel.rb +129 -0
  139. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/extensions.rb +152 -0
  140. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/kex.rb +44 -0
  141. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/local_packet.rb +51 -0
  142. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/packet.rb +81 -0
  143. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/remote_packet.rb +38 -0
  144. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/script.rb +157 -0
  145. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/socket.rb +64 -0
  146. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/algorithms.rb +384 -0
  147. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/cipher_factory.rb +97 -0
  148. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/constants.rb +30 -0
  149. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac.rb +31 -0
  150. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/abstract.rb +79 -0
  151. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5.rb +12 -0
  152. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  153. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/none.rb +15 -0
  154. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  155. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  156. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/identity_cipher.rb +55 -0
  157. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex.rb +13 -0
  158. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
  159. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
  160. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/openssl.rb +128 -0
  161. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/packet_stream.rb +235 -0
  162. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/server_version.rb +71 -0
  163. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/session.rb +276 -0
  164. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/state.rb +206 -0
  165. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/lenient.rb +30 -0
  166. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/null.rb +12 -0
  167. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/strict.rb +53 -0
  168. data/plugins/project/vendor/net-ssh/lib/net/ssh/version.rb +62 -0
  169. data/plugins/project/vendor/net-ssh/net-ssh.gemspec +138 -0
  170. data/plugins/project/vendor/net-ssh/setup.rb +1585 -0
  171. data/plugins/project/vendor/net-ssh/support/arcfour_check.rb +20 -0
  172. data/plugins/project/vendor/net-ssh/support/ssh_tunnel_bug.rb +65 -0
  173. data/plugins/project/vendor/net-ssh/test/README.txt +42 -0
  174. data/plugins/project/vendor/net-ssh/test/authentication/methods/common.rb +28 -0
  175. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_abstract.rb +51 -0
  176. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_hostbased.rb +114 -0
  177. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_keyboard_interactive.rb +98 -0
  178. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_password.rb +50 -0
  179. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_publickey.rb +127 -0
  180. data/plugins/project/vendor/net-ssh/test/authentication/test_agent.rb +205 -0
  181. data/plugins/project/vendor/net-ssh/test/authentication/test_key_manager.rb +105 -0
  182. data/plugins/project/vendor/net-ssh/test/authentication/test_session.rb +93 -0
  183. data/plugins/project/vendor/net-ssh/test/common.rb +107 -0
  184. data/plugins/project/vendor/net-ssh/test/configs/eqsign +3 -0
  185. data/plugins/project/vendor/net-ssh/test/configs/exact_match +8 -0
  186. data/plugins/project/vendor/net-ssh/test/configs/host_plus +10 -0
  187. data/plugins/project/vendor/net-ssh/test/configs/multihost +4 -0
  188. data/plugins/project/vendor/net-ssh/test/configs/nohost +19 -0
  189. data/plugins/project/vendor/net-ssh/test/configs/numeric_host +4 -0
  190. data/plugins/project/vendor/net-ssh/test/configs/wild_cards +14 -0
  191. data/plugins/project/vendor/net-ssh/test/connection/test_channel.rb +467 -0
  192. data/plugins/project/vendor/net-ssh/test/connection/test_session.rb +488 -0
  193. data/plugins/project/vendor/net-ssh/test/manual/test_forward.rb +185 -0
  194. data/plugins/project/vendor/net-ssh/test/test_all.rb +9 -0
  195. data/plugins/project/vendor/net-ssh/test/test_buffer.rb +336 -0
  196. data/plugins/project/vendor/net-ssh/test/test_buffered_io.rb +63 -0
  197. data/plugins/project/vendor/net-ssh/test/test_config.rb +117 -0
  198. data/plugins/project/vendor/net-ssh/test/test_key_factory.rb +67 -0
  199. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5.rb +39 -0
  200. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5_96.rb +25 -0
  201. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_none.rb +34 -0
  202. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1.rb +34 -0
  203. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1_96.rb +25 -0
  204. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
  205. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
  206. data/plugins/project/vendor/net-ssh/test/transport/test_algorithms.rb +302 -0
  207. data/plugins/project/vendor/net-ssh/test/transport/test_cipher_factory.rb +213 -0
  208. data/plugins/project/vendor/net-ssh/test/transport/test_hmac.rb +34 -0
  209. data/plugins/project/vendor/net-ssh/test/transport/test_identity_cipher.rb +40 -0
  210. data/plugins/project/vendor/net-ssh/test/transport/test_packet_stream.rb +441 -0
  211. data/plugins/project/vendor/net-ssh/test/transport/test_server_version.rb +78 -0
  212. data/plugins/project/vendor/net-ssh/test/transport/test_session.rb +315 -0
  213. data/plugins/project/vendor/net-ssh/test/transport/test_state.rb +173 -0
  214. data/plugins/redcar/plugin.rb +3 -1
  215. data/plugins/redcar/redcar.rb +108 -121
  216. data/plugins/redcar_debug/lib/redcar_debug.rb +2 -0
  217. data/plugins/runnables/lib/runnables.rb +80 -23
  218. data/plugins/runnables/lib/runnables/command_output_controller.rb +102 -0
  219. data/plugins/runnables/lib/runnables/running_process_checker.rb +34 -0
  220. data/plugins/runnables/{plugin_no_load.rb → plugin.rb} +2 -1
  221. data/plugins/runnables/vendor/session-2.4.0/HISTORY +73 -0
  222. data/plugins/runnables/vendor/session-2.4.0/README +89 -0
  223. data/plugins/runnables/vendor/session-2.4.0/TODO +3 -0
  224. data/plugins/runnables/vendor/session-2.4.0/VERSION +1 -0
  225. data/plugins/runnables/vendor/session-2.4.0/gemspec.rb +22 -0
  226. data/plugins/runnables/vendor/session-2.4.0/install.rb +143 -0
  227. data/plugins/runnables/vendor/session-2.4.0/lib/session.rb +757 -0
  228. data/plugins/runnables/vendor/session-2.4.0/sample/bash.rb +60 -0
  229. data/plugins/runnables/vendor/session-2.4.0/sample/driver.rb +47 -0
  230. data/plugins/runnables/vendor/session-2.4.0/sample/session_idl.rb +25 -0
  231. data/plugins/runnables/vendor/session-2.4.0/sample/session_sh.rb +29 -0
  232. data/plugins/runnables/vendor/session-2.4.0/sample/sh0.rb +23 -0
  233. data/plugins/runnables/vendor/session-2.4.0/sample/stdin.rb +17 -0
  234. data/plugins/runnables/vendor/session-2.4.0/sample/threadtest.rb +42 -0
  235. data/plugins/runnables/vendor/session-2.4.0/session-2.4.0.gem +0 -0
  236. data/plugins/runnables/vendor/session-2.4.0/test/session.rb +227 -0
  237. data/plugins/runnables/views/command_output.html.erb +32 -0
  238. data/plugins/task_manager/lib/task_manager.rb +2 -0
  239. data/plugins/textmate/lib/textmate/plist.rb +1 -1
  240. data/plugins/textmate/lib/textmate/snippet.rb +1 -0
  241. data/plugins/tree/lib/tree/mirror.rb +8 -1
  242. data/plugins/tree_view_swt/lib/tree_view_swt.rb +29 -2
  243. metadata +191 -6
  244. data/plugins/declarations/TODO +0 -3
  245. data/plugins/redcar/spec/redcar/redcar_spec.rb +0 -70
  246. data/plugins/redcar/spec/spec_helper.rb +0 -4
@@ -0,0 +1,102 @@
1
+
2
+ module Redcar
3
+ class Runnables
4
+ class CommandOutputController
5
+ include Redcar::HtmlController
6
+
7
+ def initialize(cmd)
8
+ @cmd = cmd
9
+ end
10
+
11
+ def title
12
+ "Process"
13
+ end
14
+
15
+ def ask_before_closing
16
+ if @shell
17
+ "This tab contains an unfinished process. \n\nKill the process and close?"
18
+ end
19
+ end
20
+
21
+ def close
22
+ if @shell
23
+ Process.kill(9, @shell.pid.to_i + 1)
24
+ end
25
+ end
26
+
27
+ def run
28
+ case Redcar.platform
29
+ when :osx, :linux
30
+ run_posix
31
+ when :windows
32
+ run_windows
33
+ end
34
+ end
35
+
36
+ def run_windows
37
+ @thread = Thread.new do
38
+ output = `#{@cmd} 2>&1`
39
+ html=<<-HTML
40
+ <div class="stdout">
41
+ <pre>#{output}</pre>
42
+ </div>
43
+ HTML
44
+ execute(<<-JAVASCRIPT)
45
+ $("#output").append(#{html.inspect});
46
+ JAVASCRIPT
47
+ end
48
+ end
49
+
50
+ def run_posix
51
+ @thread = Thread.new do
52
+ sleep 1
53
+ @shell = Session::Shell.new
54
+ @shell.outproc = lambda do |out|
55
+ html=<<-HTML
56
+ <div class="stdout">
57
+ <pre>#{out}</pre>
58
+ </div>
59
+ HTML
60
+ execute(<<-JAVASCRIPT)
61
+ $("#output").append(#{html.inspect});
62
+ JAVASCRIPT
63
+ end
64
+ @shell.errproc = lambda do |err|
65
+ html=<<-HTML
66
+ <div class="stderr">
67
+ <pre>#{err}</pre>
68
+ </div>
69
+ HTML
70
+ execute(<<-JAVASCRIPT)
71
+ $("#output").append(#{html.inspect});
72
+ JAVASCRIPT
73
+ end
74
+ begin
75
+ @shell.execute(@cmd)
76
+ rescue => e
77
+ puts e.class
78
+ puts e.message
79
+ puts e.backtrace
80
+ end
81
+ html=<<-HTML
82
+ <hr />
83
+ <small><strong>Process finished</strong></small>
84
+ HTML
85
+ execute(<<-JAVASCRIPT)
86
+ $("#output").append(#{html.inspect});
87
+ JAVASCRIPT
88
+ @shell = nil
89
+ @thread = nil
90
+ end
91
+ end
92
+
93
+ def index
94
+ rhtml = ERB.new(File.read(File.join(File.dirname(__FILE__), "..", "..", "views", "command_output.html.erb")))
95
+ command = @cmd
96
+ run
97
+ rhtml.result(binding)
98
+ end
99
+ end
100
+ end
101
+ end
102
+
@@ -0,0 +1,34 @@
1
+ module Redcar
2
+ class Runnables
3
+ class RunningProcessChecker
4
+ def initialize(tabs, message, options)
5
+ @tabs, @message, @options = tabs, message, options
6
+ end
7
+
8
+ def check
9
+ tabs_with_running_processes = @tabs.select {|t| t.html_view.controller and t.html_view.controller.ask_before_closing }
10
+ if tabs_with_running_processes.any?
11
+ result = Application::Dialog.message_box(
12
+ "You have #{tabs_with_running_processes.length} running processes.\n\n" +
13
+ @message,
14
+ :buttons => :yes_no_cancel
15
+ )
16
+ case result
17
+ when :yes
18
+ tabs_with_running_processes.each do |t|
19
+ t.focus
20
+ t.close
21
+ end
22
+ @options[:continue] ? @options[:continue].call : nil
23
+ when :no
24
+ @options[:continue] ? @options[:continue].call : nil
25
+ when :cancel
26
+ @options[:cancel] ? @options[:cancel].call : nil
27
+ end
28
+ else
29
+ @options[:none] ? @options[:none].call : nil
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -5,5 +5,6 @@ Plugin.define do
5
5
  file "lib", "runnables"
6
6
  object "Redcar::Runnables"
7
7
  dependencies "tree", ">0",
8
- "application", ">0"
8
+ "application", ">0",
9
+ "HTML View", ">0"
9
10
  end
@@ -0,0 +1,73 @@
1
+ HISTORY:
2
+
3
+ 2.4.0:
4
+ - added ability to specify stdin for Session::Bash and Session::Sh
5
+
6
+ sh = Session::new
7
+
8
+ sh.execute 'cat', :stdin => io
9
+ sh.execute 'cat', :stdin => string
10
+ sh.execute 'cat', :stdin => stringio
11
+
12
+ 2.3.0:
13
+ - fixed warning of @debug being un-initialized
14
+
15
+ 2.2.0:
16
+ - added a private munged version of Open3::open3. the builtin one causes
17
+ the child process to become a child of init, this was very inconvenient
18
+ because it was sometimes hard to crawl proces trees - the parent was lost.
19
+ now the seesion is a child process that has been detached using
20
+ Process::detach. this results in less suprising behaviour; for instance
21
+ sending signal TERM to a process results in any sessions it had open dying
22
+ as well. you can use Session::use_open3=true or
23
+ ENV['SESSION_USE_OPEN3']='1' for the old behaviour if you need it.
24
+ - added Session::Bash::Login class. this class opens a session which has
25
+ all the normal settings of a bash loging shell (.bashrc is sourced). this
26
+ if often convenient as paths, aliases, etc. are set as normal.
27
+ - moved the Spawn module inside the Session module. now the Session module
28
+ is the namespace for everything so using session pollutes namespace less.
29
+
30
+ 2.1.9:
31
+ - fixed bug where setting track history after creation caused later failure in
32
+ execute (@history =[] only in ctor). thanks leon breedt
33
+ <bitserf@gmail.com>!
34
+ - updates to README
35
+ - included session-x.x.x.rpa file - thanks batsman <batsman.geo@yahoo.com>
36
+ - to_str/to_s/to_yaml for History/Command is now valid yaml (updated samples
37
+ to reflect this)
38
+ - inspect for History/Command is now ruby's default
39
+
40
+ 2.1.8:
41
+ - greatly simplified read loop using two reader threads, one for stderr and
42
+ one for stdout alongside a mutex to protect data. this streamlined the code
43
+ alot vs. the old select method including allowing removal of the linbuffer
44
+ class. the interface remains exactly as before however.
45
+
46
+ 2.1.7:
47
+ - improved thread safe non-blocking read method
48
+ - gemspec
49
+
50
+ 2.1.6:
51
+ - wrapped send_command in a Thread (send async) so output processing can
52
+ commend immeadiately. this was o.k. before, but had strange behaviour when
53
+ using popen3 from threads. thanks to tanaka akira for this suggestion.
54
+ - iff ENV['SESSION_USE_SPAWN'] is set Session uses Spawn::spawn instead of
55
+ Open3::popen3. also noted that spawn seems to be a bit faster.
56
+ - added tests for threads.
57
+ - run 'sh SESSION_USE_SPAWN=1 ruby test/session.rb' to test using spawn
58
+ - added test for idl so it's test is not run if system doesn't have it, all
59
+ that should be required for 'ruby test/session.rb' is should be sh'
60
+ - removed sample/tcsh and note about Tcsh and Csh in README - stderr
61
+ redirection/separation is flaky in those shells
62
+
63
+ 2.1.5:
64
+ - added Session.use_spawn=, AbstractSession.use_spawn=, and an :use_session=>
65
+ option to AbstractSession#initialize. if any of them are set the code uses
66
+ Spawn::spawn to create external processes instead of Open3::popen3.
67
+ Spawn::spawn uses named pipes (fifos) for IPC instead of forking and pipes.
68
+ the fork used in popen3 can cause strange behaviour with multi-threaded apps
69
+ (like a tk app). see source for details
70
+
71
+ 2.1.4:
72
+ - added Thread.exclusive{} wrapper when io is read to works in multi
73
+ threaded apps
@@ -0,0 +1,89 @@
1
+ URLS: |
2
+
3
+ http://raa.ruby-lang.org/project/session/
4
+ http://www.codeforpeople.com/lib/ruby/session/
5
+
6
+
7
+ NAME: |
8
+
9
+ Session
10
+ ::Sh
11
+ ::Bash
12
+ ::Shell
13
+ ::IDL
14
+
15
+ SYNOPSIS: |
16
+
17
+ Session::* offers a set of classes built upon Open3::popen3 for driving
18
+ external progams via pipes. It offers a significant abstraction over
19
+ Open3::popen in that the stdout/stderr of each command sent can be deliniated:
20
+
21
+ open3:
22
+
23
+ i.o,e = Open3::popen3 '/bin/sh'
24
+
25
+ i.puts 'ls'
26
+ i.puts 'echo 42'
27
+
28
+ now, how to determine the boundry between the output from 'ls' and 'echo'?
29
+ the only (simple) way is start a process for each command
30
+
31
+ i.o,e = Open3::popen3 '/bin/sh'
32
+ i.puts 'ls'
33
+ i.close
34
+ stdout, stderr = o.read, e.read
35
+
36
+ i.o,e = Open3::popen3 '/bin/sh'
37
+ i.puts 'echo 42'
38
+ i.close
39
+ stdout, stderr = o.read, e.read
40
+
41
+ session:
42
+
43
+ sh = Session::new
44
+
45
+ stdout, stderr = sh.execute 'ls'
46
+ stdout, stderr = sh.execute 'echo 42'
47
+
48
+ Both stderr and stdout can be redirected, and the exit_status of each command
49
+ is made available:
50
+
51
+ bash = Session::Bash.new
52
+ stdout, stderr = StringIO::new, StringIO::new
53
+
54
+ bash.execute 'ls', :stdout => stdout, :stderr => stderr
55
+ # bash.execute 'ls', 1 => stdout, 2 => stderr # same thing
56
+ # bash.execute 'ls', :o => stdout, :e => stderr # same thing
57
+
58
+ exit_status = bash.exit_status
59
+
60
+ A block form can be used to specify a callback to be invoked whenever output
61
+ has become availible:
62
+
63
+ bash = Session::Bash.new
64
+
65
+ bash.execute( 'long_running_command.exe' ) do |out, err|
66
+ logger << out if out
67
+ elogger << err if err
68
+ end
69
+
70
+ Sessions are Thread safe (in the sense that they do not block on io
71
+ operations) allowing commands spawned from guis to update widgets with output
72
+ while running in the background.
73
+
74
+ button.configure 'action' => lambda do
75
+ sh = Session::new
76
+ sh.execute(cmd) do |o,e|
77
+ out_widget.update o if o
78
+ err_widget.update e if e
79
+ end
80
+ end
81
+
82
+ SAMPLES: |
83
+
84
+ see samples/*
85
+
86
+
87
+ AUTHOR: |
88
+
89
+ ara.t.howard@noaa.gov
@@ -0,0 +1,3 @@
1
+ TODO:
2
+ - factor out err/out methods from send_command so subclassing is safer
3
+ - determine non-system call method of doing 'mkfifo', possibly c extension?
@@ -0,0 +1,22 @@
1
+ lib, version = File::basename(File::dirname(File::expand_path(__FILE__))).split %r/-/, 2
2
+
3
+ require 'rubygems'
4
+
5
+ spec = Gem::Specification.new do |s|
6
+ s.name = lib
7
+ s.version = version
8
+ s.platform = Gem::Platform::RUBY
9
+ s.summary = lib
10
+
11
+ s.files = Dir["lib/*"] + Dir["bin/*"]
12
+
13
+ s.require_path = "lib"
14
+ s.autorequire = lib
15
+
16
+ s.has_rdoc = File::exist? "doc"
17
+ s.test_suite_file = "test/#{ lib }.rb" if File::directory? "test"
18
+
19
+ s.author = "Ara T. Howard"
20
+ s.email = "ara.t.howard@noaa.gov"
21
+ s.homepage = "http://codeforpeople.com/lib/ruby/#{ lib }/"
22
+ end
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rbconfig'
3
+ require 'find'
4
+ require 'ftools'
5
+ require 'tempfile'
6
+ include Config
7
+
8
+ LIBDIR = "lib"
9
+ LIBDIR_MODE = 0644
10
+
11
+ BINDIR = "bin"
12
+ BINDIR_MODE = 0755
13
+
14
+
15
+ $srcdir = CONFIG["srcdir"]
16
+ $version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
17
+ $libdir = File.join(CONFIG["libdir"], "ruby", $version)
18
+ $archdir = File.join($libdir, CONFIG["arch"])
19
+ $site_libdir = $:.find {|x| x =~ /site_ruby$/}
20
+ $bindir = CONFIG["bindir"]
21
+ $ruby_install_name = CONFIG['ruby_install_name'] || CONFIG['RUBY_INSTALL_NAME']
22
+ $ruby = File.join($bindir, $ruby_install_name || 'ruby')
23
+
24
+ if !$site_libdir
25
+ $site_libdir = File.join($libdir, "site_ruby")
26
+ elsif $site_libdir !~ %r/#{Regexp.quote($version)}/
27
+ $site_libdir = File.join($site_libdir, $version)
28
+ end
29
+
30
+ def install_rb(srcdir=nil, destdir=nil, mode=nil, bin=nil)
31
+ #{{{
32
+ path = []
33
+ dir = []
34
+ Find.find(srcdir) do |f|
35
+ next unless FileTest.file?(f)
36
+ next if (f = f[srcdir.length+1..-1]) == nil
37
+ next if (/CVS$/ =~ File.dirname(f))
38
+ path.push f
39
+ dir |= [File.dirname(f)]
40
+ end
41
+ for f in dir
42
+ next if f == "."
43
+ next if f == "CVS"
44
+ File::makedirs(File.join(destdir, f))
45
+ end
46
+ for f in path
47
+ next if (/\~$/ =~ f)
48
+ next if (/^\./ =~ File.basename(f))
49
+ unless bin
50
+ File::install(File.join(srcdir, f), File.join(destdir, f), mode, true)
51
+ else
52
+ from = File.join(srcdir, f)
53
+ to = File.join(destdir, f)
54
+ shebangify(from) do |sf|
55
+ $deferr.print from, " -> ", File::catname(from, to), "\n"
56
+ $deferr.printf "chmod %04o %s\n", mode, to
57
+ File::install(sf, to, mode, false)
58
+ end
59
+ end
60
+ end
61
+ #}}}
62
+ end
63
+ def shebangify f
64
+ #{{{
65
+ open(f) do |fd|
66
+ buf = fd.read 42
67
+ if buf =~ %r/^\s*#\s*!.*ruby/o
68
+ ftmp = Tempfile::new("#{ $$ }_#{ File::basename(f) }")
69
+ begin
70
+ fd.rewind
71
+ ftmp.puts "#!#{ $ruby }"
72
+ while((buf = fd.read(8192)))
73
+ ftmp.write buf
74
+ end
75
+ ftmp.close
76
+ yield ftmp.path
77
+ ensure
78
+ ftmp.close!
79
+ end
80
+ else
81
+ yield f
82
+ end
83
+ end
84
+ #}}}
85
+ end
86
+ def ARGV.switch
87
+ #{{{
88
+ return nil if self.empty?
89
+ arg = self.shift
90
+ return nil if arg == '--'
91
+ if arg =~ /^-(.)(.*)/
92
+ return arg if $1 == '-'
93
+ raise 'unknown switch "-"' if $2.index('-')
94
+ self.unshift "-#{$2}" if $2.size > 0
95
+ "-#{$1}"
96
+ else
97
+ self.unshift arg
98
+ nil
99
+ end
100
+ #}}}
101
+ end
102
+ def ARGV.req_arg
103
+ #{{{
104
+ self.shift || raise('missing argument')
105
+ #}}}
106
+ end
107
+
108
+
109
+ #
110
+ # main program
111
+ #
112
+
113
+ libdir = $site_libdir
114
+ bindir = $bindir
115
+
116
+ begin
117
+ while switch = ARGV.switch
118
+ case switch
119
+ when '-d', '--destdir'
120
+ libdir = ARGV.req_arg
121
+ when '-l', '--libdir'
122
+ libdir = ARGV.req_arg
123
+ when '-b', '--bindir'
124
+ bindir = ARGV.req_arg
125
+ when '-r', '--ruby'
126
+ $ruby = ARGV.req_arg
127
+ else
128
+ raise "unknown switch #{switch.dump}"
129
+ end
130
+ end
131
+ rescue
132
+ STDERR.puts $!.to_s
133
+ STDERR.puts File.basename($0) +
134
+ " -d <destdir>" +
135
+ " -l <libdir>" +
136
+ " -b <bindir>"
137
+ " -r <ruby>"
138
+ exit 1
139
+ end
140
+
141
+ install_rb(LIBDIR, libdir, LIBDIR_MODE)
142
+ install_rb(BINDIR, bindir, BINDIR_MODE, bin=true)
143
+