Skip to content

Commit

Permalink
Merge pull request #926 from altendky/handle_no_logfile_case
Browse files Browse the repository at this point in the history
Handle the case when no log file is found
altendky authored Sep 18, 2021
2 parents b4714aa + 8d47f47 commit 5747f1f
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]
### Fixed
- Regression in v0.5.2 where plotting processes that lack log files caused a traceback.
([#926](https://github.com/ericaltendorf/plotman/pull/926))
### Added

## [0.5.2] - 2021-09-12
16 changes: 11 additions & 5 deletions src/plotman/job.py
Original file line number Diff line number Diff line change
@@ -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 = ""

0 comments on commit 5747f1f

Please sign in to comment.