rclconfig.py, rclexecm.py: implement part of mimetype identification for rclexecm test mode

This commit is contained in:
Jean-Francois Dockes
2019-10-06 07:44:50 +02:00
parent 8339559536
commit af42fe8f5e
2 changed files with 34 additions and 5 deletions
+11 -5
View File
@@ -386,6 +386,7 @@ def main(proto, extract):
if len(args) != 1:
usage()
path = args[0]
def mimetype_with_file(f):
cmd = 'file -i "' + f + '"'
@@ -402,11 +403,16 @@ def main(proto, extract):
def debprint(out, s):
if not actAsSingle:
proto.breakwrite(out, makebytes(s+'\n'))
params = {'filename:': makebytes(args[0])}
# Some filters (e.g. rclaudio) need/get a MIME type from the indexer
mimetype = mimetype_with_file(args[0])
params['mimetype:'] = mimetype
params = {'filename:': makebytes(path)}
# Some filters (e.g. rclaudio) need/get a MIME type from the indexer.
# We make a half-assed attempt to emulate:
mimetype = my_config.mimeType(path)
if not mimetype and not _mswindows:
mimetype = mimetype_with_file(path)
if mimetype:
params['mimetype:'] = mimetype
if not extract.openfile(params):
print("Open error", file=sys.stderr)