Skip to content

Commit

Permalink
Partially resolve unicode filename issue in ftopen().
Browse files Browse the repository at this point in the history
This resolves a unicode character issue when trying to use the ftopen()
helper function to access files. The ftopen() function accepts a
standard myth:// URI, and parses it for the necessary information,
however URIs traditionally only accept a limited, safe subset of the
ASCII character set. This adds a temporary work around where by the
various object .open() methods will internally pass the necessary data
in a tuple, bypassing the need to encode and decode about the limited
character set. Myth URIs with unsafe or escaped characters will still
not be handled properly by ftopen().
  • Loading branch information
wagnerrp committed Dec 19, 2012
1 parent 0d1d143 commit 8fe3824
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
12 changes: 5 additions & 7 deletions mythtv/bindings/python/MythTV/dataheap.py
Expand Up @@ -104,7 +104,7 @@ def downloadFrom(self, url):
be.downloadTo(url, self.imagetype, self)

def open(self, mode='r'):
return ftopen('myth://{0.imagetype}@{0.hostname}/{0}'.format(self), mode)
return ftopen((self.hostname, self.imagetype, str(self)), mode)

class Record( CMPRecord, DBDataWrite, RECTYPE ):
"""
Expand Down Expand Up @@ -332,11 +332,9 @@ def delete(self, force=False, rerecord=False):

def open(self, type='r'):
"""Recorded.open(type='r') -> file or FileTransfer object"""
return ftopen("myth://%s@%s/%s" % ( self.storagegroup,
self.hostname,
self.basename),
type, db=self._db,
chanid=self.chanid, starttime=self.starttime)
return ftopen((self.hostname, self.storagegroup, self.basename),
type, db=self._db, chanid=self.chanid,
starttime=self.starttime)

def getProgram(self):
"""Recorded.getProgram() -> Program object"""
Expand Down Expand Up @@ -930,7 +928,7 @@ def delete(self):
trailer = Artwork('trailer')

def open(self, mode='r', nooverwrite=False):
return ftopen('myth://Videos@{0.host}/{0.filename}'.format(self),
return ftopen((self.host, 'Videos', self.filename),
mode, False, nooverwrite, self._db)

def getHash(self):
Expand Down
23 changes: 12 additions & 11 deletions mythtv/bindings/python/MythTV/mythproto.py
Expand Up @@ -229,13 +229,16 @@ def ftopen(file, mode, forceremote=False, nooverwrite=False, db=None, \

# process URI (myth://<group>@<host>[:<port>]/<path/to/file>)
match = reuri.match(file)
if match is None:
if match:
host = match.group('host')
filename = match.group('file')
sgroup = match.group('group')
if sgroup is None:
sgroup = 'Default'
elif len(file) == 3:
host, sgroup, filename = file
else:
raise MythError('Invalid FileTransfer input string: '+file)
host = match.group('host')
filename = match.group('file')
sgroup = match.group('group')
if sgroup is None:
sgroup = 'Default'

# get full system name
host = host.strip('[]')
Expand Down Expand Up @@ -953,11 +956,9 @@ def delete(self, force=False, rerecord=False):
return res

def _openProto(self):
if not self.filename.startswith('myth://'):
self.filename = 'myth://%s@%s/%s' % (self.storagegroup, \
self.hostname, \
self.filename)
return ftopen(self.filename, 'r', db=self._db, chanid=self.chanid, \
filename = self.filename if self.filename.startswith('myth://') else \
(self.hostname, self.storagegroup, self.filename)
return ftopen(filename, 'r', db=self._db, chanid=self.chanid, \
starttime=self.recstartts)

def _openXML(self):
Expand Down

0 comments on commit 8fe3824

Please sign in to comment.