Guest User

Untitled

a guest
Feb 22nd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. class StaticPagesController < ApplicationController
  2. require 'open3'
  3. def mylog
  4. mycommand = "python app/assets/python/checkUpload.py "
  5.  
  6. #file that should be tested
  7. file_loc = "..."
  8.  
  9. #extend command with parameters
  10. mycommand << "[some parameter] "
  11. mycommand << ""#{trackfile_loc}""
  12.  
  13. #run command to check the file and stream its output
  14. Open3.popen3(mycommand) do |stdin, stdout, stderr, wait_thr|
  15. while line=stdout.gets do
  16. puts line
  17. end
  18. end
  19. end
  20. end
  21.  
  22. <% provide(:title, "Log") %>
  23. <p>
  24. <h3><b>Log:</b></h3>
  25. <%= #here the messages should be inserted %>
  26. </p>
  27.  
  28. #header missing
  29. message1
  30. message2
  31. message3
  32. #footer missing
  33.  
  34. class StaticPagesController < ApplicationController
  35. include ActionController::Streaming
  36. require 'open3'
  37. def mylog
  38. mycommand = "python app/assets/python/checkUpload.py "
  39.  
  40. #file location that should be tested
  41. trackfile_loc = "..."
  42.  
  43. #extend command with parameters
  44. mycommand << "[some parameter] "
  45. mycommand << ""#{trackfile_loc}""
  46.  
  47. #filling it with one message to see if display in view works
  48. @messages = ["Test"]
  49.  
  50. #run command to check the trackfile and stream its output
  51. Open3.popen3(mycommand) do |stdin, stdout, stderr, wait_thr|
  52. while line=stdout.gets do
  53. @messages.push(line)
  54. #add handle of stderr to file
  55. end
  56. end
  57. render stream: true
  58. end
  59. end
  60.  
  61. <% provide(:title, "Log") %>
  62. <p>
  63. <h3><b>Log:</b></h3>
  64. <% for line in @messages %>
  65. <%= puts line %>
  66. <% end %>
  67. </p>
Add Comment
Please, Sign In to add comment