Skip to content

Commit

Permalink
handle more unicode weirdness from pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcarneiro committed Aug 10, 2021
1 parent 3c69156 commit 50148d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions example/adhoc.yacron.d/test-utc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ defaults:

jobs:
- name: test-01
command: echo "hello"
schedule: "27 19 * * *"
command: echo "heállo€"
schedule: "* * * * *"
captureStdout: true
2 changes: 1 addition & 1 deletion pyinstaller/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pluggy==0.13.1
py==1.10.0
pycodestyle==2.7.0
pyflakes==2.3.1
pyinstaller==4.1
pyinstaller==4.5.1
pyinstaller-hooks-contrib==2021.2
pyparsing==2.4.7
pytest==6.2.4
Expand Down
13 changes: 9 additions & 4 deletions yacron/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async def _read(self, stream):
return
out_line = prefix + line
try:
sys.stdout.write(out_line)
sys.stdout.buffer.write(out_line.encode())
except UnicodeEncodeError:
out_line = out_line.encode("ascii", "replace").decode("ascii")
sys.stdout.write(out_line)
Expand Down Expand Up @@ -337,10 +337,15 @@ async def start(self) -> None:
)

try:
self.proc = await create(*cmd, **kwargs)
except subprocess.SubprocessError:
self.proc = await create(*[c.encode() for c in cmd], **kwargs)
except (subprocess.SubprocessError, UnicodeEncodeError):
logger.exception(
"Error launching subprocess of job %s", self.config.name
"Error launching subprocess of job %s, cmd=%r, kwargs=%s "
"(system encoding: %s)",
self.config.name,
cmd,
kwargs,
sys.getdefaultencoding(),
)
return

Expand Down

0 comments on commit 50148d2

Please sign in to comment.