Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ python:

before_install:
- pip install -U pip wheel setuptools

install:
- pip install -e .[dev]

before_script:
- ci/travis/before_script.sh
- sh ci/travis/before_script.sh

script:
- python -m coverage run -m unittest discover -v
Expand Down
Empty file modified ci/travis/before_script.sh
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion instalooter/_uadetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_user_agent(port=None, cache=None):
# Use webbrowser to connect to the server with the default browser
webbrowser.open("http://localhost:{}/".format(port))
# Wait for the request handler to get the request from the browser
user_agent = UserAgentRequestHandler.queue.get()
user_agent = UserAgentRequestHandler.queue.get(True, 5)
# Close the server
server.shutdown()
server.server_close()
Expand Down
10 changes: 7 additions & 3 deletions instalooter/looters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import fs
import six
from requests import Session
from six.moves.queue import Queue
from six.moves.queue import Queue, Empty
from six.moves.http_cookiejar import FileCookieJar, LWPCookieJar

from . import __author__, __name__ as __appname__, __version__
Expand Down Expand Up @@ -69,10 +69,14 @@ def _user_agent(cls):
"""
cache = cls._cachefs()
if not cache.isfile(cls._USERAGENT_FILE):
ua = get_user_agent(cache=cache.getsyspath(cls._USERAGENT_FILE))
try:
ua = get_user_agent(cache=cache.getsyspath(cls._USERAGENT_FILE))
except Empty:
ua = None
if ua is None:
warnings.warn("Could not detect user agent, using default")
ua = "Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0"
warnings.warn("Could not detect user agent, using default: " + ua)
warnings.warn("User agent will be stored in file " + cache.getsyspath(cls._USERAGENT_FILE))
with cache.open("user-agent.txt", "w") as f:
f.write(ua)
with cache.open(cls._USERAGENT_FILE) as f:
Expand Down