From 4756026371feb272a5062355fc3d3def1695b2fb Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Wed, 17 Aug 2022 21:30:10 +0900 Subject: [PATCH] fix run error:name 'file' is not defined About correct python interpreter, now we use python3 interpreter directly without correct anymore. Change-Id: Ic3ae325727fb98d4ab60f0e7022863eb684d6cba Signed-off-by: biao716.wang --- mic/rt_util.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mic/rt_util.py b/mic/rt_util.py index 43b15de..61b9353 100644 --- a/mic/rt_util.py +++ b/mic/rt_util.py @@ -196,7 +196,7 @@ def get_mic_libpath(): def sync_mic(bootstrap, binpth = '/usr/bin/mic', libpth='/usr/lib', plugin='/usr/lib/mic/plugins', - pylib = '/usr/lib/python2.7/site-packages', + pylib = '/usr/lib/python3/site-packages', conf = '/etc/mic/mic.conf'): _path = lambda p: os.path.join(bootstrap, p.lstrip('/')) @@ -224,7 +224,7 @@ def sync_mic(bootstrap, binpth = '/usr/bin/mic', raise errors.BootstrapError(err) # auto select backend - conf_str = file(_path(conf)).read() + conf_str = open(_path(conf)).read() conf_str = re.sub("pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str) with open(_path(conf), 'w') as wf: wf.write(conf_str) @@ -232,13 +232,6 @@ def sync_mic(bootstrap, binpth = '/usr/bin/mic', # chmod +x /usr/bin/mic os.chmod(_path(binpth), 0o777) - # correct python interpreter - mic_cont = file(_path(binpth)).read() - mic_cont = "#!/usr/bin/python3\n" + mic_cont - with open(_path(binpth), 'w') as wf: - wf.write(mic_cont) - - def safecopy(src, dst, symlinks=False, ignore_ptns=()): if os.path.isdir(src): if os.path.isdir(dst): -- 2.7.4