Ticket #4467: mythburn_patch_fix_ValueError.patch

File mythburn_patch_fix_ValueError.patch, 1.7 KB (added by schepens@…, 14 years ago)

Patch to fix problem: cause was spaces in mount point. Solution: use regex to parse mount lines

  • .py

    old new  
    1414# paulh
    1515# 4 May 2006 - Added into mythtv svn
    1616
     17# banyan
     18# 14 Jan 2008 - Fixed issue in CopyRemote causing the following exception:
     19#       ValueError: too many values to unpack
     20#    Cause: a mount with spaces in the path split into more than 6 parts.
     21#    This caused the assignment of the parts to fail later. 
     22#    Solution: replaced the split() and assignment with a regular expression.
     23
    1724#For this script to work you need to have...
    1825#Python2.3.5
    1926#python2.3-mysqldb
     
    3138#******************************************************************************
    3239
    3340# version of script - change after each update
    34 VERSION="0.1.20071115-1.fixes"
     41VERSION="0.1.20080114-1.fixes"
    3542
    3643
    3744##You can use this debug flag when testing out new themes
     
    5562import Image, ImageDraw, ImageFont
    5663import MySQLdb, codecs
    5764import time, datetime, tempfile
     65import re
    5866from fcntl import ioctl
    5967from CDROM import CDROMEJECT
    6068from CDROM import CDROMCLOSETRAY
     
    32943302    mounts = os.popen('mount')
    32953303    # Go through each line of mounts output
    32963304    for line in mounts.readlines():
    3297         parts = line.split()
    32983305        # mount says in this format
    3299         device, txt1, mountpoint, txt2, filesystem, options = parts
     3306        m = re.match(r"(.*)( on )(.*)( type )(.*)\s(\(.*\))", line)
     3307        assert m, "Could not parse the mount line:\n\t%s" % line
     3308        device, txt1, mountpoint, txt2, filesystem, options = m.group(1),"on",m.group(3),"type",m.group(5),m.group(6)
    33003309        # only do if really remote
    33013310        if filesystem in remotefs:
    33023311            # add remote to list