Commit c2b88099 authored by Celine Noirot's avatar Celine Noirot
Browse files

Add jflow update : get cpu and memory form application.properties

and set multi-user usage with ###USER###.
parent a13b6209
......@@ -51,13 +51,24 @@ class Component(object):
self.version = self.version.decode()
self.batch_options = self.config_reader.get_component_batch_options(self.__class__.__name__)
# in case of SGE, parse the cpu and memory parameter
self.__cpu=None
self.__memory=None
type, options, limit_submission = self.config_reader.get_batch()
if type.lower() == "sge":
if type.lower() == "sge" :
try:
self.__cpu = int(re.match( r'.*-pe\s+(\w+)\s+(\d+)\s?.*', self.batch_options).group(2))
self.__memory = int(re.match( r'.*-l\s+mem=(\d+\S+)\s?.*', self.batch_options))
except: pass
except: pass
try:
self.__memory = re.match( r'.*-l\s+mem=(\d+\S+)\s?.*', self.batch_options).group(1)
except: pass
elif type.lower() == "local" :
try:
self.__cpu = int(re.match( r'.*cpu=(\d+)\s?.*', self.batch_options).group(1))
except: pass
try:
self.__memory = re.match( r'.*\s?mem=(\d+\w)\s?.*', self.batch_options).group(1)
except: pass
def get_cpu(self):
return self.__cpu
......
......@@ -37,12 +37,12 @@ class JFlowConfigReader(object):
self.reader.read(os.path.join(os.path.dirname(inspect.getfile(self.__class__)), self.CONFIG_FILE_PATH))
def get_tmp_directory(self):
if not os.path.isdir(self.reader.get("storage", "tmp_directory")):
os.makedirs(self.reader.get("storage", "tmp_directory"), 0o751)
return self.reader.get("storage", "tmp_directory")
if not os.path.isdir(self.reader.get("storage", "tmp_directory").replace("###USER###",os.getenv("USER"))):
os.makedirs(self.reader.get("storage", "tmp_directory").replace("###USER###",os.getenv("USER")), 0o751)
return self.reader.get("storage", "tmp_directory").replace("###USER###",os.getenv("USER"))
def get_work_directory(self):
return self.reader.get("storage", "work_directory")
return self.reader.get("storage", "work_directory").replace("###USER###",os.getenv("USER"))
def get_exec(self, software):
try:
......@@ -59,7 +59,7 @@ class JFlowConfigReader(object):
@return: the path to the log file
"""
try:
return self.reader.get('storage', 'log_file')
return self.reader.get('storage', 'log_file').replace("###USER###",os.getenv("USER"))
except :
raise NoOptionError("Failed when parsing the config file, no section logging found!")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment