Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class StaticPagesController < ApplicationController
- require 'open3'
- def mylog
- mycommand = "python app/assets/python/checkUpload.py "
- #file that should be tested
- file_loc = "..."
- #extend command with parameters
- mycommand << "[some parameter] "
- mycommand << ""#{trackfile_loc}""
- #run command to check the file and stream its output
- Open3.popen3(mycommand) do |stdin, stdout, stderr, wait_thr|
- while line=stdout.gets do
- puts line
- end
- end
- end
- end
- <% provide(:title, "Log") %>
- <p>
- <h3><b>Log:</b></h3>
- <%= #here the messages should be inserted %>
- </p>
- #header missing
- message1
- message2
- message3
- #footer missing
- class StaticPagesController < ApplicationController
- include ActionController::Streaming
- require 'open3'
- def mylog
- mycommand = "python app/assets/python/checkUpload.py "
- #file location that should be tested
- trackfile_loc = "..."
- #extend command with parameters
- mycommand << "[some parameter] "
- mycommand << ""#{trackfile_loc}""
- #filling it with one message to see if display in view works
- @messages = ["Test"]
- #run command to check the trackfile and stream its output
- Open3.popen3(mycommand) do |stdin, stdout, stderr, wait_thr|
- while line=stdout.gets do
- @messages.push(line)
- #add handle of stderr to file
- end
- end
- render stream: true
- end
- end
- <% provide(:title, "Log") %>
- <p>
- <h3><b>Log:</b></h3>
- <% for line in @messages %>
- <%= puts line %>
- <% end %>
- </p>
Add Comment
Please, Sign In to add comment