1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2019 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from . import salome_proxy
22 from . import configuration
25 def __init__(self, resource="localhost",
26 nb_branches=None, salome_parameters=None):
27 if salome_parameters is None :
28 job_params = salome_proxy.createSalomeParameters()
29 job_params.job_type = "yacs_file"
30 job_params.resource_required.name = resource
31 job_params.job_name = "idefix_job"
32 job_params.wckey = configuration.defaultWckey(resource)
33 job_params.work_directory = configuration.defaultWorkingDir(resource)
34 if nb_branches is None:
35 nb_branches = configuration.defaultNbBranches(resource)
36 job_params.resource_required.nb_proc = nb_branches
37 self.nb_branches = nb_branches
38 self.salome_parameters = job_params
40 if nb_branches is None:
41 nb_branches = salome_parameters.resource_required.nb_proc
42 self.nb_branches = nb_branches
43 self.salome_parameters = salome_parameters
45 def configureResource(self, resource):
46 self.salome_parameters.resource_required.name = resource
47 self.salome_parameters.work_directory = configuration.defaultWorkingDir(
49 nb_branches = configuration.defaultNbBranches(resource)
50 self.salome_parameters.resource_required.nb_proc = nb_branches
51 self.nb_branches = nb_branches
52 self.salome_parameters.wckey = configuration.defaultWckey(resource)
54 def createResultDirectory(self, result_base_dir):
55 self.salome_parameters.result_directory = configuration.newResultDirectory(
58 def createTmpResultDirectory(self):
59 self.salome_parameters.result_directory = configuration.newResultDirectory(
60 tempfile.gettempdir())