Skip to content

Commit e2edd13

Browse files
Fix the 1st commit of #17: incompatible retcode of subprocess.getstatusoutput()
Fix the 1st commit of #17 which replaced commands.getstatusoutput() with subprocess.getstatusoutput() without taking the change of the status code into account: Unfortunately, the Python3 developers broke the compatibility: The return code changes: python2 -c 'import commands ; print( commands.getstatusoutput("false"))' (256, '') python3 -c 'import subprocess; print(subprocess.getstatusoutput("false"))' (1, '') With commands.getstatusoutput(), you had to use this to get the actual exit code: status = os.WEXITSTATUS(status) These calls have to be removed because now they just shift away the error code: As shown at benjaminp/six#207, the operation is just `status >> 8` Luckily, the status code is checked to against 0 at most places, so there is no change for these checks. There is only one location where a bit is checked. Fix this location too. Also, that commit did not take into account that subprocess.get*output do not exist in Python2, which goes against the directive by Andrew in PR #16 where he requires that we keep Python2 working: The current master branch works neither for Python2, nor Python3 - fix this breakage in the 2nd commit. Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent d3f38b6 commit e2edd13

File tree

3 files changed

+1
-3
lines changed

3 files changed

+1
-3
lines changed

XSConsoleDataUtils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def HandleMountFailure(self, inStatus, inOutput):
382382
# Entered after self.Unmount has run
383383
if self.vdi['SR']['type'] != 'udev' or self.vdi['SR']['content_type'] != 'disk':
384384
# Take special action for USB devices only, i.e. don't reformat SCSI disks, etc.
385-
if inStatus == 8192: # Return code for empty CD drive
385+
if inStatus == 32: # 32 is the mount(8) return code for mount failure, assuming empty CD drive
386386
raise Exception(Lang("Drive is empty"))
387387
raise Exception(inOutput)
388388

plugins-base/XSFeatureDRBackup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def DoAction(self, inSR):
3939
command = "%s/xe-backup-metadata -n -u %s" % (Config.Inst().HelperPath(), sr_uuid)
4040

4141
status, output = subprocess.getstatusoutput(command)
42-
status = os.WEXITSTATUS(status)
4342
initalize_vdi = ""
4443
if status == 3:
4544
initalize_vdi = "-c"

plugins-base/XSFeatureDRRestore.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def HandleMethodChoice(self, inChoice, dryRun):
9393
Layout.Inst().TransientBanner(Lang("Restoring VM Metadata. This may take a few minutes..."))
9494
command = "%s/xe-restore-metadata -y %s -u %s -x %s -d %s -m %s" % (Config.Inst().HelperPath(), dry_flag, self.sr_uuid, self.vdi_uuid, self.chosen_date, chosen_mode)
9595
status, output = subprocess.getstatusoutput(command)
96-
status = os.WEXITSTATUS(status)
9796
Layout.Inst().PopDialogue()
9897
if status == 0:
9998
Layout.Inst().PushDialogue(InfoDialogue(Lang("Metadata Restore Succeeded: ") + output))

0 commit comments

Comments
 (0)