mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
[PR #11340/a0d3bac8 backport][stable-12] cronvar: simplify exception raise - remove import sys (#11348)
cronvar: simplify exception raise - remove import sys (#11340)
* cronvar: simplify exception raise - remove import sys
* add changelog frag
(cherry picked from commit a0d3bac88c)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
303bac630a
commit
8d4e702d89
2 changed files with 4 additions and 3 deletions
2
changelogs/fragments/11340-cronvar-simplify-exc.yml
Normal file
2
changelogs/fragments/11340-cronvar-simplify-exc.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- cronvar - simplify handling unknown exceptions (https://github.com/ansible-collections/community.general/pull/11340).
|
||||
|
|
@ -101,7 +101,6 @@ import platform
|
|||
import pwd
|
||||
import re
|
||||
import shlex
|
||||
import sys
|
||||
import tempfile
|
||||
from shlex import quote as shlex_quote
|
||||
|
||||
|
|
@ -162,7 +161,7 @@ class CronVar:
|
|||
# cron file does not exist
|
||||
return
|
||||
except Exception as e:
|
||||
raise CronVarError("Unexpected error:", sys.exc_info()[0]) from e
|
||||
raise CronVarError(f"Unexpected error: {e}", type(e)) from e
|
||||
else:
|
||||
# using safely quoted shell for now, but this really should be two non-shell calls instead. FIXME
|
||||
(rc, out, err) = self.module.run_command(self._read_user_execute(), use_unsafe_shell=True)
|
||||
|
|
@ -219,7 +218,7 @@ class CronVar:
|
|||
# cron file does not exist
|
||||
return False
|
||||
except Exception as e:
|
||||
raise CronVarError("Unexpected error:", sys.exc_info()[0]) from e
|
||||
raise CronVarError(f"Unexpected error: {e}", type(e)) from e
|
||||
|
||||
def parse_for_var(self, line):
|
||||
lexer = shlex.shlex(line)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue