I execute a linux shell command using python.
I get the below error for the line mentioned-
JavaScript
x
E501 line too long (99 > 79 characters)
Code:
JavaScript
ssh_client.exec_command(
"sudo grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}'")
Im not sure how to format the line as its a Linux command.
Advertisement
Answer
Consecutive string literals (separated only by whitespace) are merged into one in Python. So:
JavaScript
ssh_client.exec_command(
"sudo grep 'cpu ' /proc/stat | "
"awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}'")