Code Monkey home page Code Monkey logo

puxhelper's Introduction

PuxHelper

Performs various tasks and uses PushBullet to communicate with the user.

Requires: Transmission (BitTorrent client) Transmissionrpc (Python module) requests (Python module) PushBullet account (Put authentication key in a text file somewhere then change PuxGlobal so my thing can find it) NoPubWebAdapters that given a search dictionary {'URL': show_url} will return a list of tuples (episode number,torrent url)

puxhelper's People

Contributors

nick-ng avatar

Watchers

 avatar  avatar  avatar

puxhelper's Issues

Torrent thread 3

Looks like it times out?

2016-02-07 13:08:26: Torrent thread broke
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 331, in _make_request
    httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 333, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 362, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 559, in urlopen
    _pool=self, _stacktrace=stacktrace)
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 245, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/pi/PuxHelper/six.py", line 686, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 336, in _make_request
    self, url, "Read timed out. (read timeout=%s)" % read_timeout)
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='***', port=80): Read timed out. (read timeout=19)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/PuxHelper/PuxThreads.py", line 261, in run
    self.addShows()
  File "/home/pi/PuxHelper/PuxThreads.py", line 227, in addShows
    show.newTorrentURLs()
  File "/home/pi/PuxHelper/PuxShowf.py", line 151, in newTorrentURLs
    foundTorrents = PuxTorrents.torrentSearch(searchDict)
  File "/home/pi/PuxHelper/PuxTorrents.py", line 21, in torrentSearch
    return NoPubWebAdapters.torrentSearch(searchDict)
  File "/home/pi/PuxHelper/NoPubWebAdapters.py", line 120, in torrentSearch
    torrentList = ***Search(searchDict)
  File "/home/pi/PuxHelper/NoPubWebAdapters.py", line 25, in ***Search
    website = BFun.webRead(torrentSearchURL)
  File "/home/pi/PuxHelper/BFun.py", line 141, in webRead
    tempR = requests.get(someURL,timeout=timeout)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in get
    return request('get', url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 49, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 457, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 569, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 422, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='***', port=80): Read timed out. (read timeout=19)

Reduce Hard-coded Directory Paths

Put some of the paths in PuxGlobal and else where in a separate file.

Check for the file and if it doesn't exist, create it.

Guide users on what to put in the file?

Torrent thread bug 1

Torrent thread crashes with this traceback:

2016-57-07 01:57:50: Torrent thread broke
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/response.py", line 186, in read
    data = self._fp.read(amt)
  File "/usr/lib/python3.4/http/client.py", line 500, in read
    return super(HTTPResponse, self).read(amt)
  File "/usr/lib/python3.4/http/client.py", line 539, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/models.py", line 653, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/usr/lib/python3/dist-packages/urllib3/response.py", line 256, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/lib/python3/dist-packages/urllib3/response.py", line 201, in read
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='***', port=80): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/PuxHelper/PuxThreads.py", line 228, in run
    self.addShows()
  File "/home/pi/PuxHelper/PuxThreads.py", line 210, in addShows
    show.newTorrentURLs()
  File "/home/pi/PuxHelper/PuxShowf.py", line 151, in newTorrentURLs
    foundTorrents = PuxTorrents.torrentSearch(searchDict)
  File "/home/pi/PuxHelper/PuxTorrents.py", line 21, in torrentSearch
    return NoPubWebAdapters.torrentSearch(searchDict)
  File "/home/pi/PuxHelper/NoPubWebAdapters.py", line 120, in torrentSearch
    torrentList = ***Search(searchDict)
  File "/home/pi/PuxHelper/NoPubWebAdapters.py", line 25, in ***Search
    website = BFun.webRead(torrentSearchURL)
  File "/home/pi/PuxHelper/BFun.py", line 141, in webRead
    tempR = requests.get(someURL,timeout=timeout)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in get
    return request('get', url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 49, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 457, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 606, in send
    r.content
  File "/usr/lib/python3/dist-packages/requests/models.py", line 724, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 660, in generate
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='***', port=80): Read timed out.

If a torrent has 'complete' < 1 isn't on Transmission, crashes thread

If a torrent is removed from Transmission manually, the torrent thread crashes.

This is unlikely to occur during normal, "unmanned" operation.

Maybe check transmission for hash using try: except: then:

  1. Re-download torrent
  2. Set complete to >= 1 (2+ for non-standard completion?)

Torrent thread 2

Raised these stack traces

2016-02-07 12:44:40: Error when calling show.checkTorrents() in PuxThreads.TorrentT.run()
Traceback (most recent call last):
  File "/home/pi/PuxHelper/PuxThreads.py", line 266, in run
    show.checkTorrents()
  File "/home/pi/PuxHelper/PuxShowf.py", line 314, in checkTorrents
    fileDicts = self.transmissionSession.get_torrent(torrentDict['hashString']).files()
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 566, in get_torrent
    result = self._request('torrent-get', {'fields': arguments}, torrent_id, require_ids=True, timeout=timeout)
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 247, in _request
    http_data = self._http_query(query, timeout)
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 205, in _http_query
    result = self.http_handler.request(self.url, query, headers, timeout)
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/httphandler.py", line 65, in request
    response = self.http_opener.open(request, timeout=timeout)
  File "/usr/lib/python3.4/urllib/request.py", line 455, in open
    response = self._open(req, data)
  File "/usr/lib/python3.4/urllib/request.py", line 473, in _open
    '_open', req)
  File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.4/urllib/request.py", line 1202, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.4/urllib/request.py", line 1177, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

2016-02-07 12:45:10: Error when calling show.checkTorrents() in PuxThreads.TorrentT.run()
Traceback (most recent call last):
  File "/home/pi/PuxHelper/PuxThreads.py", line 266, in run
    show.checkTorrents()
  File "/home/pi/PuxHelper/PuxShowf.py", line 314, in checkTorrents
    fileDicts = self.transmissionSession.get_torrent(torrentDict['hashString']).files()
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 566, in get_torrent
    result = self._request('torrent-get', {'fields': arguments}, torrent_id, require_ids=True, timeout=timeout)
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 247, in _request
    http_data = self._http_query(query, timeout)
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 205, in _http_query
    result = self.http_handler.request(self.url, query, headers, timeout)
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/httphandler.py", line 65, in request
    response = self.http_opener.open(request, timeout=timeout)
  File "/usr/lib/python3.4/urllib/request.py", line 455, in open
    response = self._open(req, data)
  File "/usr/lib/python3.4/urllib/request.py", line 473, in _open
    '_open', req)
  File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.4/urllib/request.py", line 1202, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.4/urllib/request.py", line 1177, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

2016-02-07 12:45:43: Unexpected error when connecting to transmission. Search for 1435813a
Traceback (most recent call last):
  File "/home/pi/PuxHelper/PuxTorrents.py", line 30, in connectTransmission
    return transmissionrpc.Client()
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 169, in __init__
    self.get_session()
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 828, in get_session
    self._request('session-get', timeout=timeout)
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 247, in _request
    http_data = self._http_query(query, timeout)
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/client.py", line 205, in _http_query
    result = self.http_handler.request(self.url, query, headers, timeout)
  File "/usr/local/lib/python3.4/dist-packages/transmissionrpc/httphandler.py", line 65, in request
    response = self.http_opener.open(request, timeout=timeout)
  File "/usr/lib/python3.4/urllib/request.py", line 455, in open
    response = self._open(req, data)
  File "/usr/lib/python3.4/urllib/request.py", line 473, in _open
    '_open', req)
  File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.4/urllib/request.py", line 1202, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.4/urllib/request.py", line 1177, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

2016-02-07 12:45:49: Torrent thread broke
Traceback (most recent call last):
  File "/home/pi/PuxHelper/PuxThreads.py", line 261, in run
    self.addShows()
  File "/home/pi/PuxHelper/PuxThreads.py", line 229, in addShows
    show.checkTorrents()
  File "/home/pi/PuxHelper/PuxShowf.py", line 314, in checkTorrents
    fileDicts = self.transmissionSession.get_torrent(torrentDict['hashString']).files()
AttributeError: 'NoneType' object has no attribute 'get_torrent'

Turn on/off unsolicited Pushbullet messages

Unsolicited messages are ones that aren't replies to a message from the user such as when a torrent completes or when the script ends.

Maybe add a global "unsolicited" list variable so "important" messages like the script ending still get sent while less important don't.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.