summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-04-05 17:52:17 +0100
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-04-06 20:22:35 +0100
commitc90aca4f9a25af4b0660dbf6fbeafae68439d4ab (patch)
treea569b31ac36843e6bb654200c03e70b2a0c08002 /src
parent9664e7d685307f5f9736929731e759ff7bad7353 (diff)
downloadvyos-1x-c90aca4f9a25af4b0660dbf6fbeafae68439d4ab.tar.gz
vyos-1x-c90aca4f9a25af4b0660dbf6fbeafae68439d4ab.zip
util: T2226: rewrite 12-to-13 to use cmd
Diffstat (limited to 'src')
-rwxr-xr-xsrc/migration-scripts/system/12-to-1313
1 files changed, 6 insertions, 7 deletions
diff --git a/src/migration-scripts/system/12-to-13 b/src/migration-scripts/system/12-to-13
index 5f7413d46..5b068f4fc 100755
--- a/src/migration-scripts/system/12-to-13
+++ b/src/migration-scripts/system/12-to-13
@@ -12,12 +12,8 @@ import re
import sys
from vyos.configtree import ConfigTree
-from subprocess import Popen, PIPE, STDOUT
+from vyos.util import cmd
-def _cmd(cmd):
- p = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True)
- tmp = p.communicate()[0].strip()
- return tmp.decode()
if (len(sys.argv) < 1):
print("Must specify file name!")
@@ -37,8 +33,11 @@ else:
tz = config.return_value(tz_base)
# retrieve all valid timezones
- 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')
+ try:
+ tz_datas = cmd('find /usr/share/zoneinfo/posix -type f -or -type l | sed -e s:/usr/share/zoneinfo/posix/::')
+ except OSError:
+ tz_datas = ''
+ tz_data = tz_datas.split('\n')
if re.match(r'[Ll][Oo][Ss].+', tz):
tz = 'America/Los_Angeles'