Skip to content

Commit

Permalink
Python Bindings: Open video/recoring in binary mode
Browse files Browse the repository at this point in the history
Since the exported function `ftopen` is meant for videos or
recordings, open those type of files in binary mode.

Tested with python2.7 and python3.6

Refs #13475

Thanks to Jay Harbeston, who reported this issue
See
http://lists.mythtv.org/pipermail/mythtv-users/2020-August/404781.html

(cherry picked from commit c2ff157)
  • Loading branch information
rcrdnalor committed Aug 27, 2020
1 parent aac5e7f commit 5c395c5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mythtv/bindings/python/MythTV/mythproto.py
Expand Up @@ -288,7 +288,7 @@ def ftopen(file, mode, forceremote=False, nooverwrite=False, db=None, \
for sg in sgs:
if sg.dirname in path:
if sg.local:
return open(sg.dirname+filename, mode)
return open(sg.dirname+filename, mode+'b')
else:
return protoopen(host, filename, sgroup)

Expand All @@ -307,9 +307,9 @@ def ftopen(file, mode, forceremote=False, nooverwrite=False, db=None, \
path = sg.dirname+filename.rsplit('/',1)[0]
if not os.access(path, os.F_OK):
os.makedirs(path)
log(log.FILE, log.INFO, 'Opening local file (w)',
log(log.FILE, log.INFO, 'Opening local file (wb)',
sg.dirname+filename)
return open(sg.dirname+filename, mode)
return open(sg.dirname+filename, mode+'b')

# fallback to remote write
else:
Expand All @@ -322,9 +322,9 @@ def ftopen(file, mode, forceremote=False, nooverwrite=False, db=None, \
sg = findfile(filename, sgroup, db)
if sg is not None:
# file found, open local
log(log.FILE, log.INFO, 'Opening local file (r)',
log(log.FILE, log.INFO, 'Opening local file (rb)',
sg.dirname+filename)
return open(sg.dirname+filename, mode)
return open(sg.dirname+filename, mode+'b')
else:
# file not found, open remote
return protoopen(host, filename, sgroup)
Expand Down

0 comments on commit 5c395c5

Please sign in to comment.