diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-04-05 16:40:59 +0100 |
---|---|---|
committer | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-04-06 20:22:35 +0100 |
commit | 4b30d3d6545b108c0b043baae2d57a465a8c8999 (patch) | |
tree | d448c1fbfbf25e333510508fa874986ce93bc12a /src/validators/timezone | |
parent | eaa28ee365310d17833602462b88a239a6924e57 (diff) | |
download | vyos-1x-4b30d3d6545b108c0b043baae2d57a465a8c8999.tar.gz vyos-1x-4b30d3d6545b108c0b043baae2d57a465a8c8999.zip |
util: T2226: rewrite timezone validator to use cmd
Diffstat (limited to 'src/validators/timezone')
-rwxr-xr-x | src/validators/timezone | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/validators/timezone b/src/validators/timezone index d7a8f64c4..ec845e755 100755 --- a/src/validators/timezone +++ b/src/validators/timezone @@ -17,12 +17,8 @@ import argparse from sys import exit -from subprocess import Popen, PIPE, STDOUT -def _cmd(cmd): - p = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True) - tmp = p.communicate()[0].strip() - return tmp.decode() +from vyos.util import cmd parser = argparse.ArgumentParser() parser.add_argument("--validate", action="store", help="Check if timezone is valid") @@ -31,7 +27,7 @@ if __name__ == '__main__': args = parser.parse_args() if args.validate: - tz_data = _cmd('find /usr/share/zoneinfo/posix -type f -or -type l | sed -e s:/usr/share/zoneinfo/posix/::') + tz_data = cmd('find /usr/share/zoneinfo/posix -type f -or -type l | sed -e s:/usr/share/zoneinfo/posix/::') tz_data = tz_data.split('\n') # if timezone can't be found in list it's invalid if args.validate not in tz_data: |