Skip to content

Commit

Permalink
Backout changes to print text on the same line.
Browse files Browse the repository at this point in the history
Fix some spelling mistakes
  • Loading branch information
shortbloke committed Sep 1, 2019
1 parent 6e1ed0a commit f109870
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
16 changes: 8 additions & 8 deletions stressberry/cli.py
Expand Up @@ -71,17 +71,17 @@ def _get_parser_run():
"--cores",
type=int,
default=None,
help="number of cpu cores to stress (default: all)",
help="number of CPU cores to stress (default: all)",
)
parser.add_argument(
"-f", "--frequency", help="measure cpu core frequency", action="store_true"
"-f", "--frequency", help="measure CPU core frequency", action="store_true"
)
parser.add_argument(
"-ff",
"--frequency-file",
type=str,
default="/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
help="cpu core frequency file. Must be used in conjunction with --disable-vcgencmd if vcgencmd exists (default: /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)",
help="CPU core frequency file. Must be used in conjunction with --disable-vcgencmd if vcgencmd exists (default: /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)",
)
parser.add_argument(
"--disable-vcgencmd",
Expand Down Expand Up @@ -118,11 +118,11 @@ def run(argv=None):
freqs.append(measure_core_frequency(args.frequency_file, use_vcgencmd))
print(
"Current temperature: {}°C. Frequency: {}MHz".format(
temps[-1], freqs[-1], end="\r"
temps[-1], freqs[-1]
)
)
else:
print("Current temperature: {}°C".format(temps[-1]), end="\r")
print("Current temperature: {}°C".format(temps[-1]))
# Choose the sample interval such that we have a respectable number of
# data points
t.join(2.0)
Expand Down Expand Up @@ -155,7 +155,7 @@ def plot(argv=None):
data = [yaml.load(f, Loader=yaml.SafeLoader) for f in args.infiles]

# sort the data such that the data series with the lowest terminal
# temperature is plotted last (and appears int he legend last)
# temperature is plotted last (and appears in the legend last)
terminal_temps = [d["temperature"][-1] for d in data]
order = [i[0] for i in sorted(enumerate(terminal_temps), key=lambda x: x[1])]
# actually plot it
Expand Down Expand Up @@ -183,7 +183,7 @@ def plot(argv=None):
color="C1",
)
except KeyError():
print("Source data does not contain cpu frequency data.")
print("Source data does not contain CPU frequency data.")

if args.outfile is not None:
plt.savefig(args.outfile, transparent=True, bbox_inches="tight", dpi=args.dpi)
Expand Down Expand Up @@ -229,7 +229,7 @@ def _get_parser_plot():
parser.add_argument(
"-f",
"--frequency",
help="plot cpu core frequency (single input files only)",
help="plot CPU core frequency (single input files only)",
action="store_true",
)
return parser
8 changes: 3 additions & 5 deletions stressberry/main.py
Expand Up @@ -20,21 +20,19 @@ def cooldown(interval=60, filename="/sys/class/thermal/thermal_zone0/temp"):
print(
"Current temperature: {}°C - Previous temperature: {}°C".format(
tmp, prev_tmp
),
end="\r",
)
)
if abs(tmp - prev_tmp) < 0.2:
break
prev_tmp = tmp
print("") # Ensure next message starts on a new line.
return tmp


def measure_temp(filename="/sys/class/thermal/thermal_zone0/temp", use_vcgencmd=False):
"""Returns the core temperature in Celsius.
"""
if use_vcgencmd:
# Usign vcgencmd is specific to the raspberry pi
# Using vcgencmd is specific to the raspberry pi
out = subprocess.check_output(["vcgencmd", "measure_temp"]).decode("utf-8")
temp = float(out.replace("temp=", "").replace("'C", ""))
else:
Expand All @@ -61,7 +59,7 @@ def measure_core_frequency(


def vcgencmd_avaialble():
"""Returns true if vcgencmd is runable, false otherwise
"""Returns true if vcgencmd is runnable, false otherwise
"""
try:
subprocess.call(["vcgencmd"])
Expand Down

0 comments on commit f109870

Please sign in to comment.