diff --git a/CHANGELOG.md b/CHANGELOG.md index cbc4cb13..2f76741d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.5.3] - 2021-09-19 +### Fixed +- Regression in v0.5.2 where plotting processes that lack log files caused a traceback. + ([#926](https://github.com/ericaltendorf/plotman/pull/926)) +- Create the directory for the new disk spaces log file. + ([#929](https://github.com/ericaltendorf/plotman/pull/929)) +- Better handle non-interactive uses that had trouble while detecting the (non-existant) terminal size. + ([#918](https://github.com/ericaltendorf/plotman/pull/918)) + ## [0.5.2] - 2021-09-12 ### Fixed - Temp files are correctly identified for cleanup. - ([#912](https://github.com/ericaltendorf/plotman/pull/913)) + ([#912](https://github.com/ericaltendorf/plotman/pull/912)) - Correct where trailing `/` on dst directories resulted in them being considered unused. ([#920](https://github.com/ericaltendorf/plotman/pull/920)) ### Added diff --git a/VERSION b/VERSION index cb0c939a..be14282b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.2 +0.5.3 diff --git a/src/plotman/analyzer.py b/src/plotman/analyzer.py index a083de16..43303140 100644 --- a/src/plotman/analyzer.py +++ b/src/plotman/analyzer.py @@ -10,7 +10,11 @@ def analyze( - logfilenames: typing.List[str], clipterminals: bool, bytmp: bool, bybitfield: bool + logfilenames: typing.List[str], + clipterminals: bool, + bytmp: bool, + bybitfield: bool, + columns: int, ) -> None: data: typing.Dict[str, typing.Dict[str, typing.List[float]]] = {} for logfilename in logfilenames: @@ -165,7 +169,6 @@ def analyze( tab.add_row(row) - (rows, columns) = os.popen("stty size", "r").read().split() tab.set_max_width(int(columns)) s = tab.draw() print(s) diff --git a/src/plotman/configuration.py b/src/plotman/configuration.py index dff7d679..c10a39ac 100644 --- a/src/plotman/configuration.py +++ b/src/plotman/configuration.py @@ -328,6 +328,7 @@ def setup(self) -> None: os.makedirs(self.plots, exist_ok=True) os.makedirs(self.transfers, exist_ok=True) os.makedirs(os.path.dirname(self.application), exist_ok=True) + os.makedirs(os.path.dirname(self.disk_spaces), exist_ok=True) def create_plot_log_path(self, time: pendulum.DateTime) -> str: return self._create_log_path( @@ -343,13 +344,6 @@ def create_transfer_log_path(self, time: pendulum.DateTime) -> str: group="transfer", ) - def create_tdisk_space_log_path(self, time: pendulum.DateTime) -> str: - return self._create_log_path( - time=time, - directory=self.disk_spaces, - group="disk_space", - ) - def _create_log_path( self, time: pendulum.DateTime, directory: str, group: str ) -> str: diff --git a/src/plotman/job.py b/src/plotman/job.py index 198ff674..1dc1444f 100644 --- a/src/plotman/job.py +++ b/src/plotman/job.py @@ -4,6 +4,7 @@ import glob import time from datetime import datetime +import sys import typing import attr @@ -105,7 +106,7 @@ class Job: plotter: "plotman.plotters.Plotter" - logfile: str = "" + logfile: typing.Optional[str] = None job_id: int = 0 proc: psutil.Process @@ -189,10 +190,11 @@ def get_running_jobs( plotter=plotter, logroot=logroot, ) - # TODO: stop reloading every time... - with open(job.logfile, "rb") as f: - r = f.read() - job.plotter.update(chunk=r) + if job.logfile is not None: + # TODO: stop reloading every time... + with open(job.logfile, "rb") as f: + r = f.read() + job.plotter.update(chunk=r) jobs.append(job) return jobs @@ -254,6 +256,10 @@ def status_str_long(self) -> str: # ) def print_logs(self, follow: bool = False) -> None: + if self.logfile is None: + print("no log file available for this plotting process", file=sys.stderr) + return + with open(self.logfile, "r") as f: if follow: line = "" diff --git a/src/plotman/plotman.py b/src/plotman/plotman.py index fc0fa68a..e111f5a3 100755 --- a/src/plotman/plotman.py +++ b/src/plotman/plotman.py @@ -161,12 +161,16 @@ def parse_args(self) -> typing.Any: return args -def get_term_width() -> int: - try: - (rows_string, columns_string) = os.popen("stty size", "r").read().split() - columns = int(columns_string) - except: - columns = 120 # 80 is typically too narrow. TODO: make a command line arg. +def get_term_width(cfg: configuration.PlotmanConfig) -> int: + default_columns = 120 # 80 is typically too narrow. + if cfg.user_interface.use_stty_size: + try: + (rows_string, columns_string) = os.popen("stty size", "r").read().split() + columns = int(columns_string) + except: + columns = default_columns + else: + columns = default_columns return columns @@ -293,7 +297,11 @@ def main() -> None: elif args.cmd == "analyze": analyzer.analyze( - args.logfile, args.clipterminals, args.bytmp, args.bybitfield + args.logfile, + args.clipterminals, + args.bytmp, + args.bybitfield, + get_term_width(cfg), ) # @@ -317,7 +325,7 @@ def main() -> None: result = reporting.json_report(jobs) else: result = "{0}\n\n{1}\n\nUpdated at: {2}".format( - reporting.status_report(jobs, get_term_width()), + reporting.status_report(jobs, get_term_width(cfg)), reporting.summary(jobs), datetime.datetime.today().strftime("%c"), ) @@ -335,7 +343,7 @@ def main() -> None: cfg.directories, cfg.archiving, cfg.scheduling, - get_term_width(), + get_term_width(cfg), ) ) diff --git a/src/plotman/resources/plotman.yaml b/src/plotman/resources/plotman.yaml index c9d38a10..f3cb1c54 100644 --- a/src/plotman/resources/plotman.yaml +++ b/src/plotman/resources/plotman.yaml @@ -3,14 +3,17 @@ # https://github.com/ericaltendorf/plotman/wiki/Configuration#versions version: [2] -logging: - # One directory in which to store all plot job logs (the STDOUT/ - # STDERR of all plot jobs). In order to monitor progress, plotman - # reads these logs on a regular basis, so using a fast drive is - # recommended. - plots: /home/chia/chia/logs - # transfers: - # application: +#logging: +# # One directory in which to store all plot job logs (the STDOUT/ +# # STDERR of all plot jobs). In order to monitor progress, plotman +# # reads these logs on a regular basis, so using a fast drive is +# # recommended. +# # For Linux, these paths default to a directory under ~/.local/share/plotman/ +# plots: +# transfers: +# # For Linux, these paths default to a file at ~/.cache/plotman/log/ +# application: +# disk_spaces: # Options for display and rendering user_interface: