Is there any way to make pytest more silent? [duplicate] - pytest

I am currently learning pytest and going through the documentation it is not clear what "quiet" mode is and what the reason for using it is. Can anyone clarify this to me?
In the documentation I see it is denoted with -q like such:
$ pytest -q test_sysexit.py
But what does this do?

Adding -q option will make pytest to be more concise in its output to the console.
There are more options similar to it:
-qq will make pytest output even less information than -q.
-v to output more information than the default amount.
Source: run pytest --help in shell:
-v, --verbose increase verbosity.
-q, --quiet decrease verbosity.

Related

Mongo --ssl on bash script

I'm writing a bash script where it connects to the mongodb in different ways and I'll run this script on various projects - some of them require --ssl connection and some of them don't. So, I wanted to know a way for me to maybe declare a variable on top which will turn on or off depending on whether the project needs --ssl connection.
ssl="--ssl" #how do I determine whether to turn this variable on or off depending on whether the project needs --ssl?
Example of where its used in bash script
`master_var=`mongo ${ssl_mode} --eval "db.isMaster.ismaster"`
Another example in the bash script where I connect to mongo:
mongo --quiet ${ssl_mode} ${name_db} <<EOF
#some commands
EOF
Edit: I want all of this to be done on the bash script itself.
You can use environment variables:
if [ -n "$MYSCRIPT_ENABLE_SSL" ]; then
ssl_mode="--ssl"
fi
And from where you call the script:
MYSCRIPT_ENABLE_SSL=1 ./myscript.sh
or
export MYSCRIPT_ENABLE_SSL=1
./myscript.sh

How to get response from SCPG3 command

I'm using scpg3 command to copy file from local server to a remote server. My command is as below:
scpg3 <filename> user#remotehost:/tmp
My question is: how to get the result from this command. I want to move it to backup folder after copy successfully. Thanks
There is a verbose directly. You can use that:
scpg3 -v, --verbose
in your case,
scpg3 -v <filename> user#remotehost:/tmp
Uses verbose mode which is equal to -D 2. -D only applies on Unix. On Windows, instead of this command line tool, use the Connection Broker debugging options -D, -l.
D is the Debug level.
Hope it helps.

How to send data to command line after calling .sh file?

I want to install Anaconda through EasyBuild. EasyBuild is a software to manage software installation on clusters. Anaconda can be installed with sh Anaconda.sh.
However, after running I have to accept the License agreement and give the installation location on the command line by entering <Enter>, yes <Enter>, path/where/to/install/ <Enter>.
Because this has to be installed automatically I want to do the accepting of terms and giving the install location in one line. I tried to do it like this:
sh Anaconda.sh < <(echo) >/dev/null < <(echo yes) >/dev/null \
< <(echo /apps/software/Anaconda/1.8.0-Linux-x86_64/) > test.txt
From the test.txt I can read that the first echo works as <Enter>, but I can't figure out how to accept the License agreement, as it sees it now as not sending yes:
Do you approve the license terms? [yes|no]
[no] >>> The license agreement wasn't approved, aborting installation.
How can I send the yes correctly to the script input?
Edit: Sorry, I missed the part about having to enter more then one thing. You can take a look at writing expect scripts. thegeekstuff.com/2010/10/expect-examples. You may need to install it however.
You could try piping with the following command: yes yes | sh Anaconda.sh. Read the man pages for more information man yes.
Expect is a great way to go and probably the most error proof way. If you know all the questions I think you could do this by just writing a file with the answers in the correct order, one per line and piping it in.
That install script is huge so as long as you can verify you know all the questions you could give this a try.
In my simple tests it works.
I have a test script that looks like this:
#!/bin/sh
echo -n "Do you accept "
read ANS
echo $ANS
echo -n "Install path: "
read ANS
echo $ANS
and an answers file that looks like this:
Y
/usr
Running it like so works... perhaps it will work for your monster install file as well.
cat answers | ./test.sh
Do you accept Y
Install path: /usr
If that doesn't work then the script is likely flushing and you will have to use expect or pexpect.
Good luck!
Actually, I downloaded and looked at the anaconda install script. Looks like it takes command line arguments.
/bin/bash Anaconda-2.2.0-Linux-x86_64.sh -h
usage: Anaconda-2.2.0-Linux-x86_64.sh [options]
Installs Anaconda 2.2.0
-b run install in batch mode (without manual intervention),
it is expected the license terms are agreed upon
-f no error if install prefix already exists
-h print this help message and exit
-p PREFIX install prefix, defaults to /home/cody.stevens/anaconda
Use the -b and -p options...
so use it like so:
/bin/bash Anaconda-2.2.0-Linux-x86_64.sh -b -p /usr
Also of note.. that script explicitly says not to run with '.' or 'sh' but 'bash' so they must have some dependency on a feature of bash.
--
Cody

Is is possible to get around zsh autocorrect for one specific argument?

So, I''m testing out something and I have to run the same command repeatedly until it works. I'm doing something like this:
curl -X POST -d #filename.xml https://host.name
When I do that, zsh always replies with
zsh: correct '#filename.xml' to 'filename.xml' [nyae]? y
I want to get zsh to stop trying to autocorrect for only this command with only this argument. I eventually just made an alias in my .zshrc file and that solves the problem for me.
I'm just wondering if there is a better way to do this.
Prefix the word with \ to avoid spelling correction:
curl -X POST -d \#filename.xml https://host.name

PintOS, kernel panic with -v option bochs on ubuntu

when i do "pintos -- run alarm-multiple" in .../build/ everything seems fine.
but when i do "make check" in .../build/ all 7 tests failed with the same
"Run didn't start up properly: no "pintos booting" message"
pintos -v -k -T 60 --bochs -- -q run alarm-single < /dev/null 2> tests/threads/alarm-single.errors > tests/threads/alarm-single.output
perl -I../.. ../../tests/threads/alarm-single.ck tests/threads/alarm-single tests/threads/alarm-single.result
FAIL tests/threads/alarm-single
Run didn't start up properly: no "Pintos booting" message
then I discovered "pintos -v -k -T 60 --bochs -- -q run alarm-single" in .../build
it gives a
Bochs is exiting with the following message:
[ ] bochsrc.txt:12: display library 'nogui' not available
if I take away the "-v" it will be fine.
How to fix this
display library 'nogui' not available
Nobody seems to answer me... I got that myself at last.
just need to change the bochs's configure : ./configer --with-nogui
and then compile it again:
make
sudo make install
After that pintos's make check will work.
i had same problem and i solved it.
open "/pintos/src/tests/Make.tests"
edit line 54 (delete -v)
TESTCMD = pintos -v -k -T $(TIMEOUT)
then, in "/threads/build" you can do
make check
Remember when you using Ubuntu 14.04 or 16.04, never forget doing such things when you download original pintos project or any pintos project from Github.
(Any line with no parentheses are terminal commands)
cd ~
gedit .bashrc
(add next line to the final of the file)
{export PATH="$PATH:/home/{username}/pintos/src/utils"}
(save)
bash
cd ~/pintos/src/utils
gedit Makefile
(You need to change one line)
{change LDFLAGS = -lm to LDLIBS = -lm}
(save)
make
Then you can compile and run "make check" for pintos with no error.
(Any ~/pintos should be changed to your pintos path)
Remember final make in ~/pintos/src/utils is ridiculously important. Otherwise you will get "Run didn't start up properly: no "Pintos booting" message".
You can check full version here. http://www.luosheng-parallelbgls.com.cn/2016/03/29/pintos-install/
Cause this is a Chinese version, I would appreciate for anyone who can translate it to English.