Skip to content

Commit

Permalink
reduce deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellowlol committed May 1, 2020
1 parent 437eea8 commit 8ac2edb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
7 changes: 6 additions & 1 deletion plexapi/alert.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import json
import threading
import websocket

from plexapi import log


Expand Down Expand Up @@ -40,6 +40,11 @@ def __init__(self, server, callback=None):
self._ws = None

def run(self):
try:
import websocket
except ImportError:
log.warning("Can't use the AlertListener without websocket")
return
# create the websocket connection
url = self._server.url(self.key, includeToken=True).replace('http', 'ws')
log.info('Starting AlertListener: %s', url)
Expand Down
5 changes: 0 additions & 5 deletions plexapi/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
except ImportError:
from xml.etree import ElementTree

try:
from unittest.mock import patch, MagicMock
except ImportError:
from mock import patch, MagicMock


def makedirs(name, mode=0o777, exist_ok=False):
""" Mimicks os.makedirs() from Python 3. """
Expand Down
12 changes: 8 additions & 4 deletions plexapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import requests
from plexapi import compat
from plexapi.exceptions import NotFound
from tqdm import tqdm

try:
from tqdm import tqdm
except ImportError:
tqdm = None

log = logging.getLogger('plexapi')

Expand Down Expand Up @@ -294,17 +298,17 @@ def download(url, token, filename=None, savepath=None, session=None, chunksize=4

# save the file to disk
log.info('Downloading: %s', fullpath)
if showstatus: # pragma: no cover
if showstatus and tqdm: # pragma: no cover
total = int(response.headers.get('content-length', 0))
bar = tqdm(unit='B', unit_scale=True, total=total, desc=filename)

with open(fullpath, 'wb') as handle:
for chunk in response.iter_content(chunk_size=chunksize):
handle.write(chunk)
if showstatus:
if showstatus and tqdm:
bar.update(len(chunk))

if showstatus: # pragma: no cover
if showstatus and tqdm: # pragma: no cover
bar.close()
# check we want to unzip the contents
if fullpath.endswith('zip') and unpack:
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@
# pip install -r requirements.txt
#---------------------------------------------------------
requests
tqdm
websocket-client
mock; python_version < '3.3'
2 changes: 2 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ sphinx
sphinxcontrib-napoleon
tqdm
websocket-client
mock; python_version < '3.3'


# Installing sphinx-rtd-theme directly from github above is used until a point release
# above 0.4.3 is released. https://github.com/readthedocs/sphinx_rtd_theme/issues/739
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import requests
from plexapi import compat
from plexapi.client import PlexClient
from plexapi.compat import MagicMock, patch
from plexapi.myplex import MyPlexAccount
from plexapi.server import PlexServer

Expand Down

0 comments on commit 8ac2edb

Please sign in to comment.