Skip to content

Commit

Permalink
Merge pull request #5731 from xenserver-next/static-vdis-pyright-fres…
Browse files Browse the repository at this point in the history
…h_name-not-None
  • Loading branch information
psafont authored Jul 2, 2024
2 parents 5b0de9a + b606836 commit 2f83515
Showing 1 changed file with 10 additions and 10 deletions.
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

0 comments on commit 2f83515

Please sign in to comment.