Added terminal mode, fixed mime handler for gifv
This commit is contained in:
@@ -117,7 +117,7 @@ class GifvMIMEParser(BaseMIMEParser):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_mimetype(url):
|
def get_mimetype(url):
|
||||||
modified_url = url[:-4] + 'webm'
|
modified_url = url[:-4] + 'webm'
|
||||||
return modified_url, 'image/webm'
|
return modified_url, 'video/webm'
|
||||||
|
|
||||||
|
|
||||||
class RedditUploadsMIMEParser(BaseMIMEParser):
|
class RedditUploadsMIMEParser(BaseMIMEParser):
|
||||||
@@ -190,4 +190,4 @@ parsers = [
|
|||||||
RedditUploadsMIMEParser,
|
RedditUploadsMIMEParser,
|
||||||
YoutubeMIMEParser,
|
YoutubeMIMEParser,
|
||||||
GifvMIMEParser,
|
GifvMIMEParser,
|
||||||
BaseMIMEParser]
|
BaseMIMEParser]
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ class Terminal(object):
|
|||||||
if not self.config['enable_media']:
|
if not self.config['enable_media']:
|
||||||
return self.open_browser(url)
|
return self.open_browser(url)
|
||||||
|
|
||||||
command = None
|
command, entry = None, None
|
||||||
for parser in mime_handlers.parsers:
|
for parser in mime_handlers.parsers:
|
||||||
if parser.pattern.match(url):
|
if parser.pattern.match(url):
|
||||||
modified_url, content_type = parser.get_mimetype(url)
|
modified_url, content_type = parser.get_mimetype(url)
|
||||||
@@ -335,23 +335,33 @@ class Terminal(object):
|
|||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
with self.loader('Opening page in a new window', delay=0):
|
args = [command]
|
||||||
args = [command]
|
_logger.info('Running command: %s', args)
|
||||||
_logger.info('Running command: %s', args)
|
|
||||||
# Non-blocking, run with a full shell to support pipes
|
if 'needsterminal' in entry:
|
||||||
p = subprocess.Popen(
|
with self.suspend():
|
||||||
args, shell=True, universal_newlines=True,
|
# Blocking, pause rtv until the process returns
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(args, shell=True)
|
||||||
# Wait a little while to make sure that the command doesn't exit
|
code = p.wait()
|
||||||
# with an error. This isn't perfect, but it should be good enough
|
if code != 0:
|
||||||
# to catch invalid commands.
|
|
||||||
time.sleep(1.0)
|
|
||||||
code = p.poll()
|
|
||||||
if code is not None and code != 0:
|
|
||||||
stdout, stderr = p.communicate()
|
|
||||||
_logger.warning(stderr)
|
|
||||||
raise exceptions.BrowserError(
|
raise exceptions.BrowserError(
|
||||||
'Program exited with status=%s' % code)
|
'Program exited with status=%s' % code)
|
||||||
|
else:
|
||||||
|
with self.loader('Opening page in a new window', delay=0):
|
||||||
|
# Non-blocking, run with a full shell to support pipes
|
||||||
|
p = subprocess.Popen(
|
||||||
|
args, shell=True, universal_newlines=True,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
# Wait a little while to make sure that the command doesn't
|
||||||
|
# exit with an error. This isn't perfect, but it should be good
|
||||||
|
# enough to catch invalid commands.
|
||||||
|
time.sleep(1.0)
|
||||||
|
code = p.poll()
|
||||||
|
if code is not None and code != 0:
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
|
_logger.warning(stderr)
|
||||||
|
raise exceptions.BrowserError(
|
||||||
|
'Program exited with status=%s' % code)
|
||||||
|
|
||||||
def open_browser(self, url):
|
def open_browser(self, url):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user