nysol 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,218 @@
1
+ #!/usr/bin/env ruby
2
+ #/* ////////// LICENSE INFO ////////////////////
3
+ #
4
+ # * Copyright (C) 2013 by NYSOL CORPORATION
5
+ # *
6
+ # * Unless you have received this program directly from NYSOL pursuant
7
+ # * to the terms of a commercial license agreement with NYSOL, then
8
+ # * this program is licensed to you under the terms of the GNU Affero General
9
+ # * Public License (AGPL) as published by the Free Software Foundation,
10
+ # * either version 3 of the License, or (at your option) any later version.
11
+ # *
12
+ # * This program is distributed in the hope that it will be useful, but
13
+ # * WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF
14
+ # * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
15
+ # *
16
+ # * Please refer to the AGPL (http://www.gnu.org/licenses/agpl-3.0.txt)
17
+ # * for more details.
18
+ #
19
+ # ////////// LICENSE INFO ////////////////////*/
20
+ #= MCMD ruby拡張ライブラリ
21
+ # ユーティリティツール
22
+ # Array.
23
+ # maddPrefix
24
+ # maddSuffix
25
+ # mslidepair
26
+ # MCMD::
27
+ # errorLog(msg="")
28
+ # warningLog(msg="")
29
+ # endLog(msg="")
30
+ # msgLog(msg="",time=true,header=true)
31
+ # mkDir(path,rm=false)
32
+ # chkCmdExe(cmd,type,arg1=nil)
33
+ # chkRexe(libs)
34
+ # mcat(fName,oFile)
35
+
36
+ class Array
37
+
38
+ def maddPrefix(strs)
39
+ strs = [strs] if strs.class != Array
40
+ rtn =[]
41
+ params=self.dup
42
+ params.each{|v|
43
+ strs.each{|str| rtn << "#{str}#{v}" }
44
+ }
45
+ return rtn
46
+ end
47
+
48
+ def maddSuffix(strs)
49
+ strs = [strs] if strs.class != Array
50
+ rtn =[]
51
+ params=self.dup
52
+ params.each{|v|
53
+ strs.each{|str| rtn << "#{v}#{str}" }
54
+ }
55
+ return rtn
56
+ end
57
+
58
+ def mslidepair
59
+ rtn =[]
60
+ params=self.dup
61
+ (1...params.size).each{|i|
62
+ rtn << [params[i-1],params[i]]
63
+ }
64
+ return rtn
65
+ end
66
+ end
67
+
68
+
69
+ module MCMD
70
+
71
+ def MCMD::errorLog(msg="")
72
+ vbl=ENV["KG_ScpVerboseLevel"]
73
+ if(not vbl or vbl.to_i>=1) then
74
+ STDERR.puts "#ERROR# #{msg}; #{Time.now.strftime('%Y/%m/%d %H:%M:%S')}"
75
+ end
76
+ end
77
+
78
+ def MCMD::warningLog(msg="")
79
+ vbl=ENV["KG_ScpVerboseLevel"]
80
+ if(not vbl or vbl.to_i>=2) then
81
+ STDERR.puts "#WARNING# #{msg}; #{Time.now.strftime('%Y/%m/%d %H:%M:%S')}"
82
+ end
83
+ end
84
+
85
+ def MCMD::endLog(msg="")
86
+ vbl=ENV["KG_ScpVerboseLevel"]
87
+ if(not vbl or vbl.to_i>=3) then
88
+ STDERR.puts "#END# #{msg}; #{Time.now.strftime('%Y/%m/%d %H:%M:%S')}"
89
+ end
90
+ end
91
+
92
+ def MCMD::msgLog(msg="",time=true,header=true)
93
+ vbl=ENV["KG_ScpVerboseLevel"]
94
+ if(not vbl or vbl.to_i>=4) then
95
+ str=""
96
+ str << "#MSG# " if header
97
+ str << msg
98
+ str << "; #{Time.now.strftime('%Y/%m/%d %H:%M:%S')}" if time
99
+ STDERR.puts str
100
+ end
101
+ end
102
+
103
+ # ディレクトリの作成
104
+ def MCMD::mkDir(path,rm=false)
105
+ if File.exist?(path)
106
+ if rm
107
+ FileUtils.rm_rf(path) if rm
108
+ FileUtils.mkdir_p(path)
109
+ end
110
+ else
111
+ FileUtils.mkdir_p(path)
112
+ end
113
+ end
114
+
115
+ # コマンド実行チェック
116
+ # 実行可能ならtrue else false
117
+ def MCMD::chkCmdExe(cmd,type,arg1=nil)
118
+ ret=true
119
+ if(type=="executable")
120
+ system "#{cmd} 2>/dev/null"
121
+ if($?.exitstatus==127)
122
+ MCMD::errorLog("command not found (type=#{type}): '#{cmd}'.")
123
+ ret=false
124
+ end
125
+ elsif(type=="wc")
126
+ log=`#{cmd} #{type} 2>&1`
127
+ if log.chomp.size()<arg1
128
+ MCMD::errorLog("command not found (type=#{type}): '#{cmd}'.")
129
+ ret=false
130
+ end
131
+ else
132
+ log=`#{cmd} #{type} 2>&1`
133
+ if log.chomp!=arg1
134
+ MCMD::errorLog("command version mismatch: '#{cmd}': needs '#{arg1}', but '#{log}.")
135
+ ret=false
136
+ end
137
+ end
138
+
139
+ return ret
140
+ end
141
+
142
+ # rの実行チェックとr ライブラリのインストールチェック
143
+ def MCMD::chkRexe(libs)
144
+ log=`R --version 2>&1`
145
+ if log.chomp.size()<100
146
+ MCMD::errorLog("R is not installed.")
147
+ return false
148
+ end
149
+
150
+ libStr=""
151
+ libs.split(",").each{|lib|
152
+ libStr << "p=packageVersion(\"#{lib}\")\n"
153
+ }
154
+
155
+ wf=MCMD::Mtemp.new
156
+ xxscp=wf.file
157
+ File.open(xxscp,"w"){|fpw|
158
+ fpw.puts <<EOF
159
+ tryCatch({
160
+ #{libStr}
161
+ },
162
+ error=function(e){
163
+ message(e)
164
+ quit(save="no", status=1)
165
+ })
166
+ quit(save="no", status=0)
167
+ EOF
168
+ }
169
+
170
+ # it will be aborted here if the library is not found
171
+ ret=system "R -q --vanilla --slave --no-save --no-restore < #{xxscp}"
172
+ unless ret
173
+ puts "\n"
174
+ MCMD::errorLog("R package shown above is not installed.")
175
+ end
176
+
177
+ # return true if nothing happened
178
+ return ret
179
+ end
180
+
181
+ # mcat i=のファイル名文字列がbashの位置行文字数制限(たぶん1024くらい?)に引っかかるのを回避するmcat
182
+ # date,noが指定されれば、date,no以前のデータをmcatし、oFileに出力する。
183
+ # マッチしたファイル名配列を返す。
184
+ def MCMD::mcat(fName,oFile)
185
+ files=[]
186
+ if fName.class.name=="Array"
187
+ fName.each{|name|
188
+ files.concat(Dir["#{name}"])
189
+ }
190
+ else
191
+ files=Dir["#{fName}"]
192
+ end
193
+
194
+ wf=MCMD::Mtemp.new
195
+ xxbase=wf.file
196
+ xxbaseX=wf.file
197
+
198
+ split=20
199
+ collect_path =[]
200
+ (0...files.size).each{|i|
201
+ if i==0
202
+ system("cp #{files[0]} #{xxbase}")
203
+ next
204
+ end
205
+ collect_path << "#{files[i]}"
206
+ if i%split == 0 or i==files.size-1 then
207
+ system("mcat i=#{xxbase},#{collect_path.join(",")} -skip_fnf o=#{xxbaseX}")
208
+ system("cp #{xxbaseX} #{xxbase}")
209
+ collect_path = []
210
+ end
211
+ }
212
+ system("cp #{xxbase} #{oFile}") if files.size>0
213
+
214
+ return files
215
+ end
216
+
217
+
218
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nysol
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.1
5
+ platform: ruby
6
+ authors:
7
+ - nysol
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake-compiler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: 'refer : http://www.nysol.jp/'
28
+ email:
29
+ - info@nysol.jp
30
+ executables:
31
+ - meach.rb
32
+ - meachc.rb
33
+ - mtempclean.rb
34
+ - mdistcopy.rb
35
+ - msend.rb
36
+ extensions:
37
+ - ext/mcsvin/extconf.rb
38
+ - ext/mcsvout/extconf.rb
39
+ - ext/mmethods/extconf.rb
40
+ - ext/mtable/extconf.rb
41
+ extra_rdoc_files: []
42
+ files:
43
+ - lib/nysol/margs.rb
44
+ - lib/nysol/mcmd.rb
45
+ - lib/nysol/mnettools.rb
46
+ - lib/nysol/mparallel.rb
47
+ - lib/nysol/mparallelmanager.rb
48
+ - lib/nysol/mrubyparse.rb
49
+ - lib/nysol/msysteminfo.rb
50
+ - lib/nysol/mtemp.rb
51
+ - lib/nysol/mutils.rb
52
+ - ext/mcsvin/extconf.rb
53
+ - ext/mcsvout/extconf.rb
54
+ - ext/mmethods/extconf.rb
55
+ - ext/mtable/extconf.rb
56
+ - ext/mcsvin/mcsvin.cpp
57
+ - ext/mcsvout/mcsvout.cpp
58
+ - ext/mmethods/mmethods.cpp
59
+ - ext/mtable/mtable.cpp
60
+ - bin/blueKiller.rb
61
+ - bin/mdistcopy.rb
62
+ - bin/meach.rb
63
+ - bin/meachc.rb
64
+ - bin/msend.rb
65
+ - bin/mtempclean.rb
66
+ homepage: http://www.nysol.jp/
67
+ licenses: []
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.0.14
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Tools for nysol ruby tools
89
+ test_files: []