lib/transcriptic/command/run.rb in transcriptic-0.1.2 vs lib/transcriptic/command/run.rb in transcriptic-0.1.3

- old
+ new

@@ -5,27 +5,81 @@ # upload and run a protocol # class Run < Base - # transcriptic run [FILENAME|DIRECTORY] + # run [FILENAME|DIRECTORY] # # upload FILENAME or DIRECTORY and launch it # def index path = args.shift fd = create_protocol_fd_for_path(path) + if 1 == fd + error "Couldn't create run!" + end display "Uploading `#{path}` to Transcriptic..." run_id = transcriptic.create_run(fd)["run_id"] display "Run launched (#{run_id})" end + # transcriptic run:analyze [FILENAME|DIRECTORY] + # + # upload FILENAME or DIRECTORY and analyze it + # + def analyze + path = args.shift + end + + # transcriptic run:status [RUNID] + # + # show details of RUNID + # + def status + run_id = args.shift + if run_id.nil? + error("Usage: transcriptic status RUNID\nMust specify RUNID to get run status.") + end + ret = transcriptic.status(run_id) + if ret.nil? + error("#{run_id} not found for #{transcriptic.user}") + return + end + display(ret.inspect) + end + + # transcriptic run:list + # + # list active runs + # + def list + ret = transcriptic.list + if ret.empty? + error("No runs for #{transcriptic.user}") + return + end + display("Runs:") + ret.each do |run| + display " #{run.name}" + end + end + + # transcriptic run:logs RUNID + # + # get log data for RUNID + # + def logs + run_id = args.shift + transcriptic.read_logs(run_id) + end + + private def create_protocol_fd_for_path(path) begin stat = File.stat(path) rescue display "No such path: #{path}" - return + return 1 end upfile = Tempfile.new('protocol') if stat.directory? files = Pathname.glob("#{path}/**/**") file_count = files.reject(&:directory?).length \ No newline at end of file