Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aaf3764

Browse files
committed
Switch back to python-pbs, for now.
Was maybe a bit hasty decision to switch to python-sh since it does not support Python 3.3 and Windows yet. Will switch back when at least Python 3.3 is supported and use pbs on Windows if necessary.
1 parent 8e91a96 commit aaf3764

5 files changed

Lines changed: 26 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Livestreamer and it's plugins currently depends on these software:
2727

2828
These will be installed automatically by the setup script if they are missing:
2929
* python-requests (at least version 0.12.1)
30-
* python-sh
30+
* python-pbs
3131
* python-argparse (only needed for Python version < 2.7)
3232

3333
For RTMP based plugins:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sys import version_info
55

66
version = "1.3.2"
7-
deps = ["sh", "requests>=0.12.1"]
7+
deps = ["pbs", "requests>=0.12.1"]
88
packages = ["livestreamer",
99
"livestreamer.stream",
1010
"livestreamer.plugins",

src/livestreamer/compat.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def bytes(b, enc="ascii"):
2828
from urlparse import urlparse, urljoin, parse_qs
2929
from urllib import quote, unquote
3030

31+
import pbs as sh
32+
33+
pbs_compat = True
34+
3135
__all__ = ["is_py2", "is_py3", "is_win32", "input", "stdout",
3236
"str", "bytes", "urlparse", "urljoin", "parse_qs",
33-
"quote", "unquote"]
37+
"quote", "unquote", "sh", "pbs_compat"]

src/livestreamer/stream/__init__.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ..compat import str
1+
from ..compat import str, sh, pbs_compat
22
from ..utils import RingBuffer
33

44
import os
@@ -32,10 +32,12 @@ def __init__(self, session, params={}, timeout=30):
3232
self.params = params
3333
self.params["_bg"] = True
3434
self.params["_err"] = open(os.devnull, "w")
35-
self.params["_out_bufsize"] = 8192
3635
self.errorlog = self.session.options.get("errorlog")
37-
self.fd = None
38-
self.timeout = timeout
36+
37+
if not pbs_compat:
38+
self.fd = None
39+
self.timeout = timeout
40+
self.params["_out_bufsize"] = 8192
3941

4042
def cmdline(self):
4143
return str(self.cmd.bake(**self.params))
@@ -46,30 +48,36 @@ def write_callback(data, queue, process):
4648
self.fd.write(data)
4749
self.process_alive = process.alive
4850

49-
self.fd = RingBuffer()
50-
self.last_data_time = time.time()
51-
5251
if self.errorlog:
5352
tmpfile = tempfile.NamedTemporaryFile(prefix="livestreamer",
5453
suffix=".err", delete=False)
5554
self.params["_err"] = tmpfile
5655

57-
self.params["_out"] = write_callback
56+
if not pbs_compat:
57+
self.fd = RingBuffer()
58+
self.last_data_time = time.time()
59+
self.params["_out"] = write_callback
5860

5961
stream = self.cmd(**self.params)
6062

6163
# Wait 0.5 seconds to see if program exited prematurely
6264
time.sleep(0.5)
6365

64-
self.process_alive = stream.process.alive
66+
if pbs_compat:
67+
self.process_alive = stream.process.returncode is None
68+
else:
69+
self.process_alive = stream.process.alive
6570

6671
if not self.process_alive:
6772
if self.errorlog:
6873
raise StreamError(("Error while executing subprocess, error output logged to: {0}").format(tmpfile.name))
6974
else:
7075
raise StreamError("Error while executing subprocess")
7176

72-
return self
77+
if pbs_compat:
78+
return stream.process.stdout
79+
else:
80+
return self
7381

7482
def read(self, size=-1):
7583
if not self.fd:

src/livestreamer/stream/rtmpdump.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from . import StreamProcess, StreamError
2-
from ..compat import str, is_win32
3-
4-
import sh
2+
from ..compat import str, sh, is_win32
53

64
class RTMPStream(StreamProcess):
75
def __init__(self, session, params):

0 commit comments

Comments
 (0)