185 | | ## this is no longer needed -- Larch is tested for at runtime |
186 | | sub ACTION_test_for_larchserver { |
187 | | # search for Python exe and Larch server script, write larch_server.ini |
188 | | my $inifile = File::Spec->catfile(cwd, 'lib', 'Demeter', 'share', 'ini', 'larch_server.ini'); |
189 | | print STDOUT "Looking for Python and Larch ---> "; |
190 | | my $larchexec = ''; |
191 | | if (($^O eq 'MSWin32') or ($^O eq 'cygwin')) { |
192 | | my @dirlist = split /;/, $ENV{'PATH'}; |
193 | | push @dirlist, (File::Spec->catfile($ENV{LOCALAPPDATA}, 'Continuum', 'Anaconda3'), |
194 | | File::Spec->catfile($ENV{LOCALAPPDATA}, 'Continuum', 'Anaconda2'), |
195 | | File::Spec->catfile($ENV{LOCALAPPDATA}, 'Continuum', 'Anaconda'), |
196 | | File::Spec->catfile($ENV{APPDATA}, 'Continuum', 'Anaconda3'), |
197 | | File::Spec->catfile($ENV{APPDATA}, 'Continuum', 'Anaconda2'), |
198 | | File::Spec->catfile($ENV{APPDATA}, 'Continuum', 'Anaconda'), |
199 | | 'C:\Python27', 'C:\Python35'); |
200 | | foreach my $d (@dirlist) { |
201 | | my $pyexe_ = File::Spec->catfile($d, 'python.exe'); |
202 | | my $larch_ = File::Spec->catfile($d, 'Scripts', 'larch_server'); |
203 | | if ((-e $pyexe_) && (-e $larch_)) { |
204 | | $larchexec = "$pyexe_ $larch_"; |
205 | | last; |
206 | | } |
207 | | } |
208 | | } else { |
209 | | my @dirlist = split /:/, $ENV{'PATH'}; |
210 | | push @dirlist, (File::Spec->catfile($ENV{HOME}, 'anaconda3', 'bin'), |
211 | | File::Spec->catfile($ENV{HOME}, 'anaconda2', 'bin'), |
212 | | File::Spec->catfile($ENV{HOME}, 'anaconda', 'bin')); |
213 | | |
214 | | foreach my $d (@dirlist) { |
215 | | my $pyexe_ = File::Spec->catfile($d, 'python'); |
216 | | my $larch_ = File::Spec->catfile($d, 'larch_server'); |
217 | | if ((-e $pyexe_) && (-e $larch_)) { |
218 | | $larchexec = "$pyexe_ $larch_"; |
219 | | last; |
220 | | } |
221 | | } |
222 | | } |
223 | | if ($larchexec eq '') { |
224 | | print "not found\n"; |
225 | | } else { |
226 | | print "found $larchexec \n"; |
227 | | } |
228 | | my $larch_server_ini_text = <<"END_OF_FILE"; |
229 | | --- |
230 | | server: 'localhost' # URL of larch_server or "localhost" is running locally |
231 | | port: 4966 # the port number the larch server is listening to |
232 | | timeout: 3 # the timeout in seconds before Demeter gives up trying to talk to the larch server |
233 | | quiet: 1 # 1 means to suppress larch_server screen messages, 0 means allow larch_server to print messages |
234 | | windows: $larchexec |
235 | | END_OF_FILE |
236 | | |
237 | | open(my $FOUT, '>', $inifile); |
238 | | print $FOUT $larch_server_ini_text; |
239 | | close $FOUT; |
240 | | print "Wrote $inifile\n"; |
241 | | }; |
242 | | |