2 # -*- coding: utf-8 -*-
5 rpath = "/usr/local/bin/R"
8 workdir = File.expand_path("~/amazonrank")
11 plotfile = workdir.dup << "/plot.R"
14 isbnfile = workdir.dup << "/ISBN.txt"
16 # データCSVファイルを格納するディレクトリ
19 # HTMLファイルおよびデータCSVファイルを格納するディレクトリ
23 ploterrfile = workdir.dup << "/error_plot.log"
25 open(isbnfile, "r") { |lines|
27 while isbn = lines.gets
29 cmd = rpath.dup << " --vanilla --slave --args " << isbn.dup << " " << csvdir.dup << " " << htmldir.dup << " <" << plotfile.dup << " 2>>" << ploterrfile.dup
31 raise "ASIN:" << isbn.dup << " コマンド実行エラー" if $? != 0
35 errfile = File.expand_path(ploterrfile.dup)
36 open(errfile, "a") { |f|
37 f.print "ASIN: ", isbn, "\n"
38 f.print "日時: ", Time.now.strftime("%Y/%m/%d %H:%M:%S"), "\n"