Commit 080bf9cd authored by Nikos Skalkotos's avatar Nikos Skalkotos

windows: Loosen up the 'shrink QUERYMAX' regexp

Do not search for specific words in it. The messages may be in a
language other than English. Focus on the Numbers.
parent 1ca02c3a
......@@ -407,20 +407,20 @@ class Windows(OSBase):
stdout, stderr, rc = self.vm.rexec(cmd)
querymax = None
expr = re.compile(
for line in stdout.splitlines():
# diskpart will return something like this:
# The maximum number of reclaimable bytes is: xxxx MB
if line.find('reclaimable') >= 0:
answer = line.split(':')[1].strip()
m ='(\d+)\s*([KMGT]?)B', answer, re.IGNORECASE)
if m:
querymax =
unit =
raise FatalError("Unexpected output for `shrink querymax' "
"command: %s" % line)
# a) The maximum number of reclaimable bytes is: xxxx MB
# b) The maximum number of reclaimable bytes is: xxxx GB (xxxx MB)
match = expr.match(line)
if match:
offset = 0 if is None else 2
querymax =
unit =
if querymax is None:
raise FatalError("Error in shrinking! Couldn't find the max "
......@@ -472,7 +472,7 @@ class Windows(OSBase):
"Shrinking failed. Please make sure the media is defragged.")
for line in stdout.splitlines():
if line.find('shrunk') >= 0:
if line.find("%d" % querymax) >= 0:
self.out.output(" %s" % line)
self.shrinked = True
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment