-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to hide stdout
for non-task
#879
Comments
|
Indeed, but not |
Looks to me that both |
Actually v1 did not suppress |
The line you pointed to is for task. this line is for regular execution, which says,
So |
I agree. But unfortunately some programs prints debug information or warning messages to
Not sure if it is a good idea, but it looks useful to me. After all the only reason to use non-task mode is performance of job submission; that often means there involve lots of jobs, and such messages will easily get overwhelming. |
Sounds like a good idea ... |
but wondering what should happen for
And for
Should we let users take the risk? |
I guess it is fair enough that users take the risk. And we make it |
I am not sure about the |
I see. I guess my question is whether or not to remove those files, if exist, before running the code that will write to them, thus preventing repeated runs adding too much to it. I assumed this is natural to do. But the corner case would be :
So removing existing |
I used |
These options right now only accept a file, but users might want to use |
Great! It works perfectly.
Right, I think it would be useful to have. Then it'd be |
The problem is that |
Right. But from my reading of the code we are parsing the options anyways. So can we change the behavior such that we keep the default behavior if |
We can certainly implement\ the behavior (missing as standard, But I agree that |
We actually have another choice, |
Okey, I changed it from diff --git a/src/sos/actions.py b/src/sos/actions.py
index 4b28e5a6..38d99d51 100644
--- a/src/sos/actions.py
+++ b/src/sos/actions.py
@@ -323,14 +323,14 @@ class SoS_ExecuteScript:
stderr=subprocess.PIPE, bufsize=0)
out, err = child.communicate()
if 'stdout' in kwargs:
- if kwargs['stdout'] is not None:
+ if kwargs['stdout']:
with open(kwargs['stdout'], 'ab') as so:
so.write(out)
else:
sys.stdout.write(out.decode())
if 'stderr' in kwargs:
- if kwargs['stderr'] is not None:
+ if kwargs['stderr']:
with open(kwargs['stderr'], 'ab') as se:
se.write(err)
else:
@@ -343,7 +343,7 @@ class SoS_ExecuteScript:
elif '__std_out__' in env.sos_dict and '__std_err__' in env.sos_dict:
if 'stdout' in kwargs or 'stderr' in kwargs:
if 'stdout' in kwargs:
- if kwargs['stdout'] is None:
+ if kwargs['stdout'] is False:
so = subprocess.DEVNULL
else:
so = open(kwargs['stdout'], 'ab')
@@ -353,7 +353,7 @@ class SoS_ExecuteScript:
so = subprocess.DEVNULL
if 'stderr' in kwargs:
- if kwargs['stderr'] is None:
+ if kwargs['stderr'] is False:
se = subprocess.DEVNULL
else:
se = open(kwargs['stderr'], 'ab')
@@ -379,7 +379,7 @@ class SoS_ExecuteScript:
ret = p.wait()
else:
if 'stdout' in kwargs:
- if kwargs['stdout'] is None:
+ if kwargs['stdout'] is False:
so = subprocess.DEVNULL
else:
so = open(kwargs['stdout'], 'ab')
@@ -389,7 +389,7 @@ class SoS_ExecuteScript:
so = subprocess.DEVNULL
if 'stderr' in kwargs:
- if kwargs['stderr'] is None:
+ if kwargs['stderr'] is False:
se = subprocess.DEVNULL
else:
se = open(kwargs['stderr'], 'ab')
@@ -412,11 +412,12 @@ class SoS_ExecuteScript:
debug_args = '{filename:q}'
else:
debug_args = self.args
- cmd = interpolate(f'{self.interpreter} {debug_args}',
+ cmd = interpolate(f'{self.interpreter.strip()} ``{debug_args}``',
{'filename': sos_targets(debug_script_file), 'script': self.script})
- raise RuntimeError('Failed to execute commmand ``{}`` (ret={}, workdir={}{})'.format(
+ raise RuntimeError('Failed to execute commmand "{}" (ret={}, workdir={}{}{})'.format(
cmd, ret, os.getcwd(),
- f', task={os.path.basename(env.sos_dict["__std_err__"]).split(".")[0]}' if '__std_out__' in env.sos_dict else ''))
+ f', task={os.path.basename(env.sos_dict["__std_err__"]).split(".")[0]}' if '__std_out__' in env.sos_dict else '',
+ f', err=``{kwargs["stderr"]}``' if 'stderr' in kwargs and os.path.isfile(kwargs['stderr']) else ''))
except RuntimeError:
raise
except Exception as e: |
Ok with me. |
I seem to recall we have talked about this before -- for non-tasks, is there a way to hide, or better, redirect stdout / stderr elsewhere just like for
task
? The output of some programs are so overwhelming that it drastically slows down the entire process because of huge amount of text printed to the terminal ...The text was updated successfully, but these errors were encountered: