348 Commits

Author SHA1 Message Date
Calum Lind
7787aa975f Delay assert in test_torrent for Travis 2017-12-16 17:29:30 +00:00
Calum Lind
2644169376 [#3126|Core] Restore synchonous add torrent methods for backward compatibilty
The synchonous add torrent method was replaced with async but this
break backward compatibility with 3rd party plugins and clients.

Added a new add_torrent_file_async method for adding single torrent.

Torrent manager has a new add_async method and split up code to prevent
duplication.

Update any use of add_torrent_file to add_torrent_file_async. Future
refactoring could use add_torrent_files instead.
2017-11-18 23:04:38 +00:00
Calum Lind
53f818e176 [#3070] Fix httpdownloader error with missing content-disposition filename
The parsing of the content-disposition in httpdownloader was not able to
handle missing parameters e.g. "Content-Disposition: attachment" and would
result in an IndexError. Added a test for this use-case.

Fixed the issue using the cgi.parse_header to extract the parameters.
2017-10-29 12:32:32 +00:00
Calum Lind
33e9545cd4 [#3079] Fix config parsing for json objects
* If a curly brace was used in a string then find_json_ojects would
   fail to find objects correctly. To fix this ignore double-quoted entries.
2017-06-28 10:32:45 +01:00
Calum Lind
dc27d873b3 Fix metafile.makeinfo trying to decode pieces
* The use of unicode_literals causes join to decode pieces if 'b' prefix not used.
 * Added test.
 * Fixed session_id keyerror when running with tests.
2017-06-15 18:25:13 +01:00
Calum Lind
45e0d10932 Update archiving of state file to use tarfile 2017-06-09 15:08:11 +01:00
Calum Lind
29191e6a58 [Tests] Remove duplicated override code 2017-06-07 12:36:09 +01:00
Calum Lind
d474576104 [Tests] Suppress JSONRequestFailedTestCase printing to stdout 2017-06-07 12:36:09 +01:00
Calum Lind
31555ee5ed [UI] Further refactoring of the connection managers
* Add host Edit button to WebUI.
 * Updated and fixed associated tests.
 * Refactored related gtkui code to better understand code flow.
 * Removed dead code in gtkui.
2017-06-07 12:36:09 +01:00
Calum Lind
ac48ad982e [UI] Refactor duplicated code out of connection managers 2017-06-07 12:36:09 +01:00
Calum Lind
54a081bdfd [Tests] Remove orphaned ubuntu favicon 2017-06-07 12:25:23 +01:00
Calum Lind
481f779349 [Python3] Fixes to make code backward compatible
* Continuation of updating code to Python 3 with Python 2 fallback.
 * Using io.open allows files to be encoded and decoded automatically on write and read. This
 maintains the python boundaries of unicode in code and bytes for output/files so less
 explicit encoding or decoding.
 * io.StringIO is the replacement for StringIO and will only accept unicode strings.
 * io.BytesIO is used where bytes output is required by the enclosing method.
 * Update bencode for full compatibility.
2017-06-05 22:25:29 +01:00
Calum Lind
6f8a6e5045 [Tests] Remove failing ubuntu icon test
* Changes to website make this test unusable now.
2017-06-05 00:01:39 +01:00
Calum Lind
73ea123f1a [#2966] [Tests] Rename deprecated method aliases 2017-03-19 22:15:07 +00:00
Calum Lind
af7e83bc76 Replace/remove usage of dict.keys() 2017-03-16 23:20:56 +00:00
Calum Lind
eb38e0ffff [Py2to3] Large set of changes for Python 3 compat
- Preparation work for using six or future module for Py2/3 compat. The
   code will be written in Python 3 with Python 2 fallbacks.
 - Added some Py3 imports with Py2 fallbacks to make it easier to remove
   Py2 code in future.
 - Replace xrange with range (sort out import as top of files in future).
 - Workaround Py2to3 basestring issue with inline if in instances. This means
   every usage of basestring is more considered.
 - Replace iteritems and itervalues for items and values. There might be a
   performance penalty on Py2 so might need to revisit this change.
2017-03-16 23:20:56 +00:00
Calum Lind
90631cca88 Fix console test 2017-03-14 15:48:20 +00:00
Calum Lind
11e8957dea [WebUI] Only accept application/json content-type requests
- Protects against CSRF (Cross-site request forgery)
2017-03-01 14:47:42 +00:00
Calum Lind
b2db96e4df [Py2to3] Refactor out usage of unicode and basestring
- Python 3 renames `unicode` type to `str` and introduces `bytes` type.
 - Python 2.7 has `bytes` but is only an alias for `str` so restricted
   to comparisons but helps keep compatibility.
 - To test for unicode string on Py2 and Py3 uses the "''.__class__" type.
 - Remove usage of utf8encode and just encode, problems with bytes being passed
   in code will be picked up faster.
 - Where possible refactor out isinstance for try..except duck-typing.
2017-02-23 00:35:43 +00:00
Calum Lind
beb4f8c8f9 [Common] Rename decode_string to decode_bytes
- Switch to using Python 3 naming convention where str now refers to unicode
   and bytes are encoded strings.
 - Cleanup docs and code
 - Also rename convert_to_utf8 to utf8_encode_structure to clarify functionality.
2017-02-23 00:30:10 +00:00
Calum Lind
9ad2f50fa4 [Common] Decode byte strings for TorrentInfo 2017-02-23 00:21:33 +00:00
Calum Lind
ba41110c27 [WebUI] Markup byte strings for twisted request 2017-02-22 12:45:12 +00:00
Calum Lind
e3b8aaf276 [Tests] Markup byte strings to fix tests 2017-02-22 12:45:11 +00:00
Calum Lind
304ad1e72d [Lint] Add missing copyright header to files 2017-02-22 12:36:33 +00:00
Calum Lind
ff6cec251a [Core] Markup byte-strings to fix httpdownloader and core tests
* Twisted methods require byte-string arguments.
 * The headers str conversion in httpdownloader _download_file was
   incorrent and left the dict key still as unicode so replaced with
   a dict comprehension (py2.7 requirement).
2017-02-22 12:36:33 +00:00
Calum Lind
84802da29b [Py2to3] Force unicode_literals and fix related issues
* Added `from __future__ import unicode_literals` to every file so
   now all strings in code are forced to be unicode strings unless
   marked as byte string `b'str'` or encoded to byte string `'str'.encode('utf-8')`.

   This is a large change but we have been working towards the goal of unicode
   strings passed in the code so decoding external input and encoding
   output as byte strings (where applicable).

   Note that in Python 2 the `str` type still refers to byte strings.

 * Replaced the use of `str` for `basestring` in isinstance comparison as
   this was the original intention but breaks code when encoutering unicode strings.

 * Marked byte strings in gtkui as the conversion to utf8 is not always handled, mostly
   related to gobject signal names.
2017-02-22 12:36:32 +00:00
Calum Lind
d1dd35d4b1 [Tests] Suppress file descriptor limit warning 2017-01-26 12:49:27 +00:00
Calum Lind
e7ce389e84 [Tests] Fix test_ui_entry failure with libtorrent 1.1
- With libtorrent 1.1 dht is enabled from startup and the returned status
   contains DHT node values (i.e. non-zero). Should be sufficient to only test for start
   and end of the status string to be correct.
2017-01-26 12:48:50 +00:00
Calum Lind
0f2083db62 [UI] [Core] Convert to session_stats_alert for session status
* Use session disk stats for cache status
2017-01-26 12:48:50 +00:00
Calum Lind
fc902af10c [Core] Remove all lt 1.1 deprecated code references 2017-01-18 14:19:37 +00:00
Calum Lind
c5e623ae45 [Core] Refactor of priorities code and test 2016-11-30 22:53:18 +00:00
Calum Lind
37d9e1f8fe [UI] Move and rename util/lang to translations_util
- The name needed to be more descriptive of it's function.
 - Moved into ui directory because of upcoming  changes being made to setup.py
   meant it would be easier to include all the 'common' ui files if there
   are no sub-dirs such as 'util'.
2016-11-28 17:41:56 +00:00
Calum Lind
7ebd69218f [Common] Fix is_ipv6 when using ipaddress module
* The ipaddress module require unicode string for 'packed' addresses.
 * Also include minor corrections to the tests.
2016-11-23 11:04:12 +00:00
bendikro
0edebda1c7 [WebUI] Log correct http address if listening on IPv6 2016-11-22 22:07:03 +00:00
Calum Lind
36cbfa8c61 [Lint] Fix files to pass Flake8 v3.2.0 2016-11-17 12:19:41 +00:00
Calum Lind
2657cc3921 [Lint] Quote cleanup 2016-11-17 10:19:59 +00:00
Calum Lind
d0d070aaf0 [Lint] Fix flake8 2016-11-04 23:54:23 +00:00
Calum Lind
e37c817151 [Lint] Refactor flake8 noqa's and add msg numbers
From pep8-naming:
 * N802: function name should be lowercase
 * N803: argument name should be lowercase
2016-11-04 18:03:21 +00:00
Calum Lind
3a2ff0c188 [Lint] Convert all python double quotes to single quotes
* A rather disruptive change but for a few reasons such as easier to read,
   easier type, keep consistent and javascript code uses single quotes.
 * There are a few exceptions for the automated process:
    * Any double quotes in comments
    * Triple double quotes for docstrings
    * Strings containing single quotes are left e.g. "they're"

 * To deal with merge conflicts from feature branches it is best to follow
   these steps for each commit:
     * Create a patch: `git format-patch -1 <sha1>`
     * Edit the patch and replace double quotes with single except those in
       comments or strings containing an unescaped apostrophe.
     * Check the patch `git apply --check <patchfile>` and fix any remaining
       issues if it outputs an error.
     * Apply the patch `git am < <patchfile>`
2016-11-03 21:45:45 +00:00
Calum Lind
03c7a2b108 [Common] Refactor unit functions 2016-11-03 10:45:01 +00:00
bendikro
f96b9c8a23 [Lint] Enable pylint warning super-init-not-called 2016-11-03 10:45:00 +00:00
bendikro
e26a3dc0e7 [Tests] Move test torrents into data subdir 2016-11-01 12:28:08 +00:00
bendikro
e827420569 [Tests] Increase file descriptor limit
Increase the file descriptor limit to avoid 'Too many files open'
error when running tests.
2016-11-01 12:28:08 +00:00
bendikro
20bae1bf90 [Console] Rewrite of the console code
This commit is a rewrite of larger parts of the console code. The
motivation behind the rewrite is to cleanup the code and reduce code
duplication to make it easier to understand and modify, and allow any
form of code reuse. Most changes are to the interactive console, but
also to how the different modes (BaseMode subclasses) are used and set
up.

* Address [#2097] - Improve match_torrent search match:
  Instead of matching e.g. torrent name with name.startswith(pattern)
  now check for asterix at beginning and end of pattern and search
  with startswith, endswith or __contains__ according to the pattern.

Various smaller fixes:
* Add errback handler to connection failed
* Fix cmd line console mixing str and unicode input
* Fix handling delete backwards with ALT+Backspace
* Fix handling resizing of message popups
* Fix docs generation warnings
* Lets not stop the reactor on exception in basemode..
* Markup for translation arg help strings

* Main functionality improvements:
 - Add support for indentation in formatting code in popup messages (like help)
 - Add filter sidebar
 - Add ComboBox and UI language selection
 - Add columnsview to allow rearranging the torrentlist columns
   and changing column widths.
 - Removed Columns pane in preferences as columnsview.py is sufficient
 - Remove torrent info panel (short cut 'i') as the torrent detail view
   is sufficient

* Cleanups and code restructuring
  - Made BaseModes subclass of Component
  - Rewrite of most of basic window/panel to allow easier code reuse
  - Implemented better handling of multple popups by stacking popups. This
    makes it easier to return to previous popup when opening multiple popups.

* Refactured console code:
  - modes/ for the different modes
    - Renamed Legacy mode to CmdLine
    - Renamed alltorrent.py to torrentlist.py and split the code into
      - torrentlist/columnsview.py
      - torrentlist/torrentsview.py
      - torrentlist/search_mode.py (minor mode)
      - torrentlist/queue_mode.py (minor mode)
  - cmdline/ for cmd line commands
  - utils/ for utility files
  - widgets/ for reusable GUI widgets
    - fields.py: Base widgets like TextInput, SelectInput, ComboInput
    - popup.py: Popup windows
    - inputpane.py: The BaseInputPane used to manage multiple base widgets in a panel
	- window.py: The BaseWindow used by all panels needing a curses screen
    - sidebar.py: The Sidebar panel
    - statusbars.py: The statusbars
  - Moved option parsing code from main.py to parser.py
2016-10-30 12:45:04 +00:00
Calum Lind
3f72905b3f Revert "[Py2to3] Clean-up the use of keys() on dictionary objects."
This reverts commit 8b50f3cdbdec4f2fa622aca9d0e4b45e5e4bf3aa.
2016-10-26 19:14:10 +01:00
Calum Lind
81334389a9 [Tests] Fix tests to run on Twisted < 13
* Also includes pylint fixes for W0233(non-parent-init-called)
 * Remove failing openbittorent icon test
2016-10-26 09:58:43 +01:00
Andrew Resch
d579efa041 [Lint] Fix various pylint warnings and fixup code
* Use print function
 * Fix except as statements
 * Remove old twisted 8 code
 * Remove empty docstring
 * Refactor try statement to only contain the relevant import and
   disable pylint import msgs.
 * Use flake8 noqa and pylint comment and drop pyflakes workarounds.
2016-10-26 09:58:43 +01:00
Andrew Resch
da51e3a3d5 [Py2to3] A group of small compatiblity code changes
* Replace the uses of long with int.
 * Replace im_func with __func__ as it has been provided for Python 3 forward-compatibility.
 * Fix next/__next__ for Python 3 compatibility.
 * Remove the long number literal
 * Ensure freespace() returns int
2016-10-26 09:58:43 +01:00
Andrew Resch
8b50f3cdbd [Py2to3] Clean-up the use of keys() on dictionary objects.
To make the code more Python 3 compatible, I've made a few changes to how we handle keys() or iterkeys() calls on dictionaries. All functionality should remain the same.

 * Remove the use of .keys() or .iterkeys() when iterating through a dictionary.
 * Remove the use of .keys() when checking if key exists in dictionary.
 * Replace dict.keys() with list(dict) to obtain a list of dictionary keys. In Python 3 dict.keys() returns a dict_keys object, not a list.
2016-10-26 09:53:32 +01:00
Calum Lind
258ad95b7a [Common] Enable use of precision and shortform units in unit funcs
* Also fixes #2562; add TiB unit.
2016-10-25 23:21:18 +01:00