Skip to content

Commit

Permalink
CP-45985: Update xe-scsi-dev-map to python3
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Cheng <stephen.cheng@cloud.com>
  • Loading branch information
stephenchengCloud committed Dec 11, 2023
1 parent 46d755e commit 9504dee
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions scripts/xe-scsi-dev-map
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
#
# Copyright (c) Citrix Systems 2008. All rights reserved.
#
Expand All @@ -14,7 +14,8 @@ def doexec(args, inputtext=None):
proc = subprocess.Popen(args, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True)
close_fds=True,
universal_newlines=True)
(stdout, stderr) = proc.communicate(inputtext)
retcode = proc.returncode
return (retcode, stdout, stderr)
Expand Down Expand Up @@ -58,7 +59,7 @@ def main():
retinfo = pread(command)
index = retinfo.find(findser)
if index != -1:
if idlist.has_key(retinfo[index+len(findser):len(retinfo)].strip()):
if retinfo[index+len(findser):len(retinfo)].strip() in idlist:
idlist[retinfo[index+len(findser):len(retinfo)].strip()].append(filepath)
else:
idlist[retinfo[index+len(findser):len(retinfo)].strip()]=[filepath]
Expand All @@ -80,7 +81,7 @@ def main():
retinfo = pread(command)
index = retinfo.find(findser)
if index != -1:
if idlist.has_key(retinfo[index+len(findser):len(retinfo)].strip()):
if retinfo[index+len(findser):len(retinfo)].strip() in idlist:
idlist[retinfo[index+len(findser):len(retinfo)].strip()].append(filepath)
else:
idlist[retinfo[index+len(findser):len(retinfo)].strip()]=[filepath]
Expand All @@ -100,7 +101,7 @@ def main():
retinfo = pread(command)
index = retinfo.find(findser)
if index != -1:
if idlist.has_key(retinfo[index+len(findser):len(retinfo)].strip()):
if retinfo[index+len(findser):len(retinfo)].strip() in idlist:
idlist[retinfo[index+len(findser):len(retinfo)].strip()].append(filepath)
else:
idlist[retinfo[index+len(findser):len(retinfo)].strip()]=[filepath]
Expand All @@ -110,11 +111,11 @@ def main():
pass

for id in idlist:
print
print "serial number '%s' maps the following devices " % id
print()
print("serial number '%s' maps the following devices " % id)
for mapping in idlist[id]:
print " %s" % mapping
print
print(" %s" % mapping)
print()

if __name__ == "__main__":
main()

0 comments on commit 9504dee

Please sign in to comment.