From ddef4eec2643d1d902c312a4d2d6a2126b2468d4 Mon Sep 17 00:00:00 2001 From: crouzet Date: Tue, 23 Jul 2019 13:32:12 +0200 Subject: [PATCH] =?utf8?q?suppression=20fonction=20command=5Fvalue=20:=20n?= =?utf8?q?on=20utilis=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/environment.py | 13 --------- src/fileEnviron.py | 73 +--------------------------------------------- 2 files changed, 1 insertion(+), 85 deletions(-) diff --git a/src/environment.py b/src/environment.py index 898e07b..da3d031 100644 --- a/src/environment.py +++ b/src/environment.py @@ -180,19 +180,6 @@ class Environ: """ return self.get(key) - def command_value(self, key, command): - """\ - Get the value given by the system command "command" - and put it in the environment variable key - - :param key str: the environment variable - :param command str: the command to execute - """ - value = subprocess.Popen(command, - shell=True, - stdout=subprocess.PIPE, - env=self.environ).communicate()[0] - self.environ[key] = value class SalomeEnviron: diff --git a/src/fileEnviron.py b/src/fileEnviron.py index 299055c..7a84dfb 100644 --- a/src/fileEnviron.py +++ b/src/fileEnviron.py @@ -281,25 +281,12 @@ class FileEnviron(object): """ return self.environ.get_value(key) - def command_value(self, key, command): - """\ - Get the value given by the system command "command" - and put it in the environment variable key. - Has to be overwritten in the derived classes - This can be seen as a virtual method - - :param key str: the environment variable - :param command str: the command to execute - """ - raise NotImplementedError("command_value is not implement " - "for this shell!") - def finish(self): """Add a final instruction in the out file (in case of file generation) :param required bool: Do nothing if required is False """ - raise NotImplementedError("command_value is not implement " + raise NotImplementedError("finish is not implement " "for this shell!") class BashFileEnviron(FileEnviron): @@ -325,18 +312,6 @@ class BashFileEnviron(FileEnviron): self.environ.set(key, value) - def command_value(self, key, command): - """\ - Get the value given by the system command "command" - and put it in the environment variable key. - Has to be overwritten in the derived classes - This can be seen as a virtual method - - :param key str: the environment variable - :param command str: the command to execute - """ - self.output.write('export %s=$(%s)\n' % (key, command)) - class BatFileEnviron(FileEnviron): """\ @@ -374,19 +349,6 @@ class BatFileEnviron(FileEnviron): self.output.write('set %s=%s\n' % (key, value)) self.environ.set(key, value) - def command_value(self, key, command): - """\ - Get the value given by the system command "command" - and put it in the environment variable key. - Has to be overwritten in the derived classes - This can be seen as a virtual method - - :param key str: the environment variable - :param command str: the command to execute - """ - self.output.write('%s > tmp.txt\n' % (command)) - self.output.write('set /p %s =< tmp.txt\n' % (key)) - def finish(self, required=True): """\ Add a final instruction in the out file (in case of file generation) @@ -424,19 +386,6 @@ class ContextFileEnviron(FileEnviron): """ return '%({0})s'.format(key) - def command_value(self, key, command): - """\ - Get the value given by the system command "command" - and put it in the environment variable key. - Has to be overwritten in the derived classes - This can be seen as a virtual method - - :param key str: the environment variable - :param command str: the command to execute - """ - raise NotImplementedError("command_value is not implement " - "for salome context files!") - def add_echo(self, text): """Add a comment @@ -681,23 +630,6 @@ class LauncherFileEnviron: % (key, self.change_to_launcher(value))) self.environ[key]+=sep+value #here yes we know os for current execution - def command_value(self, key, command): - """\ - Get the value given by the system command "command" - and put it in the environment variable key. - - :param key str: the environment variable - :param command str: the command to execute - """ - self.output.write(self.indent+'#`%s`\n' % command) - - import shlex, subprocess - args = shlex.split(command) - res=subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, __ = res.communicate() - self.output.write(self.begin+ - self.setVarEnv+ - '(r"%s", r"%s", overwrite=True)\n' % (key, out)) def add_comment(self, comment): # Special comment in case of the distène licence @@ -781,9 +713,6 @@ class ScreenEnviron(FileEnviron): value = self.get(name) + sep + value self.write("append", name, value) - def command_value(self, key, command): - pass - def run_env_script(self, module, script): self.write("load", script, "", sign="") -- 2.39.2