Commit 9558c06d authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

1. python 3 and 2 compatible

2. sorted list
parent 1af2fb90
#!/usr/bin/env python #!/usr/bin/env python3
''' '''
Copyright 2020, Elphel Inc. Copyright 2020, Elphel Inc.
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
Author: Oleg Dzhimiev <oleg@elphel.com> Author: Oleg Dzhimiev <oleg@elphel.com>
Description: Check software versions on the target Description: Compares software versions between local GIT and hardware target
''' '''
import json import json
...@@ -70,7 +70,7 @@ def get_versions_from_target_quick(addr,tdir): ...@@ -70,7 +70,7 @@ def get_versions_from_target_quick(addr,tdir):
remote_list = [] remote_list = []
for f in os.listdir(ldir): for f in sorted(os.listdir(ldir)):
with open(ldir+"/"+f, 'r') as content_file: with open(ldir+"/"+f, 'r') as content_file:
content = content_file.read() content = content_file.read()
remote_list.append([f,content.strip()]) remote_list.append([f,content.strip()])
...@@ -99,8 +99,7 @@ def get_version_from_git(path,vfile): ...@@ -99,8 +99,7 @@ def get_version_from_git(path,vfile):
#PR #PR
cmd = "git rev-list --count $(git log -1 --pretty=format:\"%H\" "+vfile+")..HEAD" cmd = "git rev-list --count $(git log -1 --pretty=format:\"%H\" "+vfile+")..HEAD"
p1 = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) p1 = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True).strip().decode('utf-8')
p1 = p1.strip()
else: else:
print(vfile+" file is missing in the project") print(vfile+" file is missing in the project")
...@@ -115,6 +114,9 @@ def deep_analysis(local,remote): ...@@ -115,6 +114,9 @@ def deep_analysis(local,remote):
update_list = "" update_list = ""
for pl,vl in local: for pl,vl in local:
# pl is <class 'bytes'>
# vl is <class 'str'>
pl = pl.decode('utf-8')
recstr = "{:<24}".format(pl)+"{:<16}".format(vl) recstr = "{:<24}".format(pl)+"{:<16}".format(vl)
prfound = False prfound = False
for pr,vr in remote: for pr,vr in remote:
...@@ -222,6 +224,9 @@ for p,v in Projects.items(): ...@@ -222,6 +224,9 @@ for p,v in Projects.items():
else: else:
raise Exception("Unknown error") raise Exception("Unknown error")
# sort [[a,va],[b,vb]] by key 0
local_list = sorted(local_list, key=lambda x: x[0])
#print(local_list) #print(local_list)
deep_analysis(local_list,target_list) deep_analysis(local_list,target_list)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment