Skip to content
Snippets Groups Projects

Remove old modules (sph, Metafor, fdtd)

Merged Boman Romain requested to merge rm_old_modules into master
123 files
+ 1
23695
Compare changes
  • Side-by-side
  • Inline
Files
123
+ 0
78
#!/usr/bin/env python3
# -*- coding: utf-8; -*-
# Copyright 2020 University of Liège
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import os
import shutil
import fwk
isUnix = lambda: os.name == 'posix'
def Metafor_call(d):
import shlex, subprocess
import platform
command_line = d['Metafor_exe'] + ' -nogui'
print(command_line)
args = shlex.split(command_line)
fileout = open('Metafor.log','w')
workdir = os.getcwd()
if isUnix(): # sans close_fds, ca freeze
if platform.system() == 'Darwin':
my_env = os.environ.copy()
my_env["DYLD_LIBRARY_PATH"] = my_env.get("VTK_DIR", '')
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=my_env, shell=False,close_fds=True)
else:
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True)
else: # si nice+Windows => "shell=True" (pour "start")
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=True)
pin = p.stdin
pin.write("import sys\n")
pin.write("sys.path.append(%s)\n" % repr(d['Metafor_model']))
pin.write("load(%s)\n" % repr(d['Metafor_model_name']))
#pin.write("setDir(%s)\n" % repr(workdir))
pin.write("para = %s\n" % repr(d))
pin.write("instance(para)\n" )
pin.write("meta()\n")
pin.close()
retcode = p.wait()
fileout.close()
'''
print os.path.isfile('pars.py')
print os.path.isfile('Metafor.log')
print 'workspace/' + d['Metafor_model_name'] + '/time.ascii'
print os.path.isfile('workspace/' + d['Metafor_model_name'] + '/time.ascii')
'''
src = workdir + '/workspace/' + d['Metafor_model_name']
src_files = os.listdir(src)
for file_name in src_files:
full_file_name = os.path.join(src, file_name)
if os.path.isfile(full_file_name):
shutil.copy(full_file_name, workdir)
shutil.rmtree(workdir + '/workspace')
Loading