Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-49928/static-vdis: Fix pyright (3/3 of: prepare move to python3/) #5731

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions scripts/static-vdis
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,25 @@ def sr_attach(ty, device_config):
return call_volume_plugin(ty, "SR.attach", args)

def list_vdis():
all = []
files = []
try:
all = os.listdir(main_dir)
except:
files = os.listdir(main_dir)
except OSError: # All possible errors are subclasses of OSError
pass
return list(map(load, all))
return list(map(load, files))

def fresh_name():
all = []
"""Return a unique name for a new static VDI configuration directory"""
try:
all = os.listdir(main_dir)
for i in range(0, len(all) + 1): # guarantees to find a unique number
files = os.listdir(main_dir)
for i in range(0, len(files) + 1): # guarantees to find a unique number
i = str(i)
if not(i in all):
if i not in files:
return i
except:
except OSError: # All possible errors are subclasses of OSError
# Directory doesn't exist
os.mkdir(main_dir)
return "0"
return "0" # Always return a string, fixes pyright error by not returning None


def to_string_list(d):
Expand Down
Loading