diff --git a/.appveyor.yml b/.appveyor.yml index 3992780a5..b8131bfb7 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -17,13 +17,18 @@ environment: clone_folder: c:\projects\lbry +test_script: +- cd C:\projects\lbry\ +- pip install cython +- pip install mock pylint unqlite +- pylint lbrynet +- python -m twisted.trial tests # avoids having to set PYTHONPATH=. (see https://twistedmatrix.com/trac/ticket/9035) +#- rvm use 2.3.1 && gem install danger --version '~> 4.0' && danger + + build_script: - cd C:\projects\lbry\build\ -- python set_version.py -- python set_build.py - ps: .\build.ps1 -- python zip_daemon.py -- python release_on_tag.py artifacts: diff --git a/.pylintrc b/.pylintrc index 9af4993e0..760cc5fb1 100644 --- a/.pylintrc +++ b/.pylintrc @@ -65,7 +65,61 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating +disable= + anomalous-backslash-in-string, + arguments-differ, + attribute-defined-outside-init, + bad-continuation, + bare-except, + broad-except, + cell-var-from-loop, + consider-iterating-dictionary, + cyclic-import, + dangerous-default-value, + duplicate-code, + exec-used, + fixme, + global-statement, + inherit-non-class, + invalid-name, + locally-disabled, + logging-not-lazy, + missing-docstring, + multiple-imports, + no-init, + no-member, + no-self-use, + old-style-class, + pointless-string-statement, + protected-access, + redefined-builtin, + redefined-outer-name, + redefined-variable-type, + relative-import, + signature-differs, + singleton-comparison, + super-init-not-called, + too-few-public-methods, + too-many-arguments, + too-many-branches, + too-many-instance-attributes, + too-many-lines, + too-many-locals, + too-many-nested-blocks, + too-many-public-methods, + too-many-return-statements, + too-many-statements, + trailing-newlines, + undefined-loop-variable, + ungrouped-imports, + unidiomatic-typecheck, + unnecessary-lambda, + unused-argument, + unused-variable, + useless-else-on-loop, + wildcard-import, + wrong-import-order, + wrong-import-position [REPORTS] @@ -294,7 +348,8 @@ ignore-mixin-members=yes # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. -ignored-modules=twisted.internet.reactor,leveldb +ignored-modules=twisted.internet.reactor,leveldb,distutils +# Ignoring distutils because: https://github.com/PyCQA/pylint/issues/73 # List of classes names for which member attributes should not be checked # (useful for classes with attributes dynamically set). This supports can work diff --git a/.travis.yml b/.travis.yml index fb8b86cbe..b788bcd03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,6 @@ install: script: - pip install cython - pip install mock pylint unqlite - - ./run_pylint.sh - - ./run_tests.sh + - pylint lbrynet + - PYTHONPATH=. trial tests - rvm use 2.3.1 && gem install danger --version '~> 4.0' && danger diff --git a/build/build.ps1 b/build/build.ps1 index 07aeeaaf6..8ea59e29d 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -7,9 +7,9 @@ mingw32-make --version # build/install miniupnpc manually tar zxf miniupnpc-1.9.tar.gz cd miniupnpc-1.9 -mingw32-make.exe -f Makefile.mingw -python.exe setupmingw32.py build --compiler=mingw32 -python.exe setupmingw32.py install +mingw32-make -f Makefile.mingw +python setupmingw32.py build --compiler=mingw32 +python setupmingw32.py install cd ..\ Remove-Item -Recurse -Force miniupnpc-1.9 @@ -18,7 +18,13 @@ Get-Content ..\requirements.txt | Select-String -Pattern 'gmpy|miniupnpc' -NotMa # add in gmpy wheel Add-Content requirements.txt "./gmpy-1.17-cp27-none-win32.whl" -pip.exe install -r requirements.txt +pip install -r requirements.txt + +python set_version.py +python set_build.py pyinstaller -y daemon.onefile.spec -pyinstaller -y cli.onefile.spec \ No newline at end of file +pyinstaller -y cli.onefile.spec + +python zip_daemon.py +python release_on_tag.py \ No newline at end of file diff --git a/build/set_build.py b/build/set_build.py index bd508345e..39fe12d09 100644 --- a/build/set_build.py +++ b/build/set_build.py @@ -10,7 +10,7 @@ def main(): build = get_build() root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) with open(os.path.join(root_dir, 'lbrynet', 'build_type.py'), 'w') as f: - f.write('BUILD = "{}"'.format(build)) + f.write("BUILD = '{}'\n".format(build)) def get_build(): diff --git a/lbrynet/core/client/BlobRequester.py b/lbrynet/core/client/BlobRequester.py index 14a707fc3..5d392240b 100644 --- a/lbrynet/core/client/BlobRequester.py +++ b/lbrynet/core/client/BlobRequester.py @@ -239,9 +239,9 @@ class RequestHelper(object): def _handle_incoming_blob(response_dict, peer, request): - if not request.response_identifier in response_dict: + if request.response_identifier not in response_dict: return InvalidResponseError("response identifier not in response") - if not type(response_dict[request.response_identifier]) == dict: + if type(response_dict[request.response_identifier]) != dict: return InvalidResponseError("response not a dict. got %s" % type(response_dict[request.response_identifier])) response = response_dict[request.response_identifier] @@ -255,14 +255,14 @@ def _handle_incoming_blob(response_dict, peer, request): return InvalidResponseError("Got an unknown error from the peer: %s" % (response['error'],)) else: - if not 'blob_hash' in response: + if 'blob_hash' not in response: return InvalidResponseError("Missing the required field 'blob_hash'") if not response['blob_hash'] == request.request_dict['requested_blob']: return InvalidResponseError( "Incoming blob does not match expected. Incoming: %s. Expected: %s" % (response['blob_hash'], request.request_dict['requested_blob']) ) - if not 'length' in response: + if 'length' not in response: return InvalidResponseError("Missing the required field 'length'") if not request.blob.set_length(response['length']): return InvalidResponseError("Could not set the length of the blob") @@ -358,7 +358,7 @@ class AvailabilityRequest(RequestHelper): class PriceRequest(RequestHelper): """Ask a peer if a certain price is acceptable""" def can_make_request(self): - if len(self.available_blobs) and not self.protocol in self.protocol_prices: + if len(self.available_blobs) and self.protocol not in self.protocol_prices: return self.get_rate() is not None return False diff --git a/lbrynet/core/client/DHTPeerFinder.py b/lbrynet/core/client/DHTPeerFinder.py index 19b3ac39a..b7202368b 100644 --- a/lbrynet/core/client/DHTPeerFinder.py +++ b/lbrynet/core/client/DHTPeerFinder.py @@ -21,9 +21,6 @@ class DHTPeerFinder(object): self.next_manage_call = None def run_manage_loop(self): - - from twisted.internet import reactor - self._manage_peers() self.next_manage_call = reactor.callLater(60, self.run_manage_loop) diff --git a/lbrynet/lbrynet_daemon/auth/server.py b/lbrynet/lbrynet_daemon/auth/server.py index 267791da1..684b1224c 100644 --- a/lbrynet/lbrynet_daemon/auth/server.py +++ b/lbrynet/lbrynet_daemon/auth/server.py @@ -414,9 +414,6 @@ class AuthJSONRPCServer(AuthorizedBase): return True allowed_server, allowed_port = self.get_server_port(allowed_origin) return (allowed_server, allowed_port) == (server, port) - return ( - server == conf.settings['api_host'] and - port == conf.settings['api_port']) def get_server_port(self, origin): parsed = urlparse.urlparse(origin) diff --git a/run_pylint.sh b/run_pylint.sh deleted file mode 100755 index c54cf0a44..000000000 --- a/run_pylint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/bash - -set -eu - -# Ignoring distutils because: https://github.com/PyCQA/pylint/issues/73 -# TODO: as code quality improves, make pylint be more strict -pylint -E --disable=inherit-non-class --disable=no-member \ - --ignored-modules=distutils \ - --enable=unused-import \ - --enable=bad-whitespace \ - --enable=line-too-long \ - --enable=trailing-whitespace \ - --enable=missing-final-newline \ - --enable=mixed-indentation \ - lbrynet $@ diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index c98eae7b2..000000000 --- a/run_tests.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -o xtrace - -if [ -z "$@" ]; then - TESTS=tests -else - TESTS="$@" -fi - -find -iname "*.pyc" -delete -PYTHONPATH=. trial $TESTS