Compare commits
118
Commits
v0.2.4
...
test-release-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf4d78a24c | ||
|
|
ee88970075 | ||
|
|
f5fa40feb7 | ||
|
|
da13192cfe | ||
|
|
8ff65a65db | ||
|
|
2d882a11a5 | ||
|
|
79adc677a1 | ||
|
|
a8e2dad6d0 | ||
|
|
16954c5626 | ||
|
|
56305c4ede | ||
|
|
30713cc21d | ||
|
|
2bac0a25e0 | ||
|
|
c3aa5b0515 | ||
|
|
30afa43ed4 | ||
|
|
f2e66abe67 | ||
|
|
cdb311a501 | ||
|
|
4c2b3e157c | ||
|
|
52625b710b | ||
|
|
b411bb4e85 | ||
|
|
f16111369f | ||
|
|
628d052749 | ||
|
|
2e26bb0e57 | ||
|
|
652c7d72f6 | ||
|
|
0b046ea8cf | ||
|
|
7133f05fea | ||
|
|
da1c23d7dd | ||
|
|
a329dcd844 | ||
|
|
b57212d5f7 | ||
|
|
12c9e16f37 | ||
|
|
422381ac01 | ||
|
|
4b817cef65 | ||
|
|
4255a9916d | ||
|
|
b1566e904b | ||
|
|
8629076814 | ||
|
|
761e4f2718 | ||
|
|
3441dd4d2d | ||
|
|
9a8139a8b2 | ||
|
|
a0f823910c | ||
|
|
755338ded0 | ||
|
|
ecd85a53a1 | ||
|
|
8faa0d9e01 | ||
|
|
20ca2eac37 | ||
|
|
85b56247a3 | ||
|
|
febc66fb02 | ||
|
|
3f929aee3c | ||
|
|
8c46dd194d | ||
|
|
a9f99d05b9 | ||
|
|
e224c33817 | ||
|
|
4e6afbc8ff | ||
|
|
80b912ea14 | ||
|
|
85a571521b | ||
|
|
98efa9f466 | ||
|
|
a30a9ad763 | ||
|
|
36787eeeeb | ||
|
|
104cafedb0 | ||
|
|
284d307c0f | ||
|
|
f50c98e10d | ||
|
|
a4a5d63da7 | ||
|
|
9f0f9e0928 | ||
|
|
ef62fd7e34 | ||
|
|
0151dd8875 | ||
|
|
2026024c8a | ||
|
|
3d56baddd7 | ||
|
|
c10e7b2b41 | ||
|
|
ba605e985a | ||
|
|
4cd1cdf495 | ||
|
|
f9c644b964 | ||
|
|
da68bcf952 | ||
|
|
2c3b625b6b | ||
|
|
16ef259ae1 | ||
|
|
c56b3e75ea | ||
|
|
772866389f | ||
|
|
41f8b5aee2 | ||
|
|
75052fc773 | ||
|
|
e7a580fd3a | ||
|
|
c967230969 | ||
|
|
f3e6b2ab57 | ||
|
|
7385cb0c89 | ||
|
|
d1be9e7dc8 | ||
|
|
a22052e85b | ||
|
|
ab401541f2 | ||
|
|
dab4427c18 | ||
|
|
ad7d508a3c | ||
|
|
cb30514cbc | ||
|
|
53af9db285 | ||
|
|
b557a14134 | ||
|
|
8922fd6dde | ||
|
|
6b39e549f7 | ||
|
|
eb0dd827b1 | ||
|
|
a48902d7d3 | ||
|
|
7fca1f865d | ||
|
|
c5dc06962d | ||
|
|
45ecdafd52 | ||
|
|
f9e8bf92bd | ||
|
|
de614b293c | ||
|
|
8382075147 | ||
|
|
b605630a9c | ||
|
|
0a89fb1928 | ||
|
|
4c81906b50 | ||
|
|
b6220e985a | ||
|
|
7a97a28e00 | ||
|
|
dda8f281a1 | ||
|
|
28b561a810 | ||
|
|
44aba93d37 | ||
|
|
efb5157027 | ||
|
|
f48c1562f3 | ||
|
|
098b5b28a8 | ||
|
|
998e8e748c | ||
|
|
be96c77467 | ||
|
|
b5e8aec548 | ||
|
|
278c7dc836 | ||
|
|
1425ad87ab | ||
|
|
f985a2a8ad | ||
|
|
20f423a2fc | ||
|
|
210c1215d6 | ||
|
|
1c507393a9 | ||
|
|
b04cfdc091 | ||
|
|
42a3006f6e |
No files matched your search
@@ -23,3 +23,5 @@ lbrynet.egg-info/PKG-INFO
|
||||
*.pem
|
||||
|
||||
*.decTest
|
||||
|
||||
.coverage
|
||||
File renamed without changes.
@@ -0,0 +1,379 @@
|
||||
[MASTER]
|
||||
|
||||
# Specify a configuration file.
|
||||
#rcfile=
|
||||
|
||||
# Python code to execute, usually for sys.path manipulation such as
|
||||
# pygtk.require().
|
||||
#init-hook=
|
||||
|
||||
# Add files or directories to the blacklist. They should be base names, not
|
||||
# paths.
|
||||
ignore=CVS
|
||||
|
||||
# Pickle collected data for later comparisons.
|
||||
persistent=yes
|
||||
|
||||
# List of plugins (as comma separated values of python modules names) to load,
|
||||
# usually to register additional checkers.
|
||||
load-plugins=
|
||||
|
||||
# Use multiple processes to speed up Pylint.
|
||||
jobs=1
|
||||
|
||||
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
||||
# active Python interpreter and may run arbitrary code.
|
||||
unsafe-load-any-extension=no
|
||||
|
||||
# A comma-separated list of package or module names from where C extensions may
|
||||
# be loaded. Extensions are loading into the active Python interpreter and may
|
||||
# run arbitrary code
|
||||
extension-pkg-whitelist=
|
||||
|
||||
# Allow optimization of some AST trees. This will activate a peephole AST
|
||||
# optimizer, which will apply various small optimizations. For instance, it can
|
||||
# be used to obtain the result of joining multiple strings with the addition
|
||||
# operator. Joining a lot of strings can lead to a maximum recursion error in
|
||||
# Pylint and this flag can prevent that. It has one side effect, the resulting
|
||||
# AST will be different than the one from reality.
|
||||
optimize-ast=no
|
||||
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
|
||||
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
|
||||
confidence=
|
||||
|
||||
# Enable the message, report, category or checker with the given id(s). You can
|
||||
# either give multiple identifier separated by comma (,) or put this option
|
||||
# multiple time (only on the command line, not in the configuration file where
|
||||
# it should appear only once). See also the "--disable" option for examples.
|
||||
#enable=
|
||||
|
||||
# Disable the message, report, category or checker with the given id(s). You
|
||||
# can either give multiple identifiers separated by comma (,) or put this
|
||||
# option multiple times (only on the command line, not in the configuration
|
||||
# file where it should appear only once).You can also use "--disable=all" to
|
||||
# disable everything first and then reenable specific checks. For example, if
|
||||
# you want to run only the similarities checker, you can use "--disable=all
|
||||
# --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
|
||||
|
||||
|
||||
[REPORTS]
|
||||
|
||||
# Set the output format. Available formats are text, parseable, colorized, msvs
|
||||
# (visual studio) and html. You can also give a reporter class, eg
|
||||
# mypackage.mymodule.MyReporterClass.
|
||||
output-format=text
|
||||
|
||||
# Put messages in a separate file for each module / package specified on the
|
||||
# command line instead of printing them on stdout. Reports (if any) will be
|
||||
# written in a file name "pylint_global.[txt|html]".
|
||||
files-output=no
|
||||
|
||||
# Tells whether to display a full report or only the messages
|
||||
reports=yes
|
||||
|
||||
# Python expression which should return a note less than 10 (10 is the highest
|
||||
# note). You have access to the variables errors warning, statement which
|
||||
# respectively contain the number of errors / warnings messages and the total
|
||||
# number of statements analyzed. This is used by the global evaluation report
|
||||
# (RP0004).
|
||||
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
|
||||
|
||||
# Template used to display messages. This is a python new-style format string
|
||||
# used to format the message information. See doc for all details
|
||||
#msg-template=
|
||||
|
||||
|
||||
[VARIABLES]
|
||||
|
||||
# Tells whether we should check for unused import in __init__ files.
|
||||
init-import=no
|
||||
|
||||
# A regular expression matching the name of dummy variables (i.e. expectedly
|
||||
# not used).
|
||||
dummy-variables-rgx=_$|dummy
|
||||
|
||||
# List of additional names supposed to be defined in builtins. Remember that
|
||||
# you should avoid to define new builtins when possible.
|
||||
additional-builtins=
|
||||
|
||||
# List of strings which can identify a callback function by name. A callback
|
||||
# name must start or end with one of those strings.
|
||||
callbacks=cb_,_cb
|
||||
|
||||
|
||||
[LOGGING]
|
||||
|
||||
# Logging modules to check that the string format arguments are in logging
|
||||
# function parameter format
|
||||
logging-modules=logging
|
||||
|
||||
|
||||
[BASIC]
|
||||
|
||||
# List of builtins function names that should not be used, separated by a comma
|
||||
bad-functions=map,filter,input
|
||||
|
||||
# Good variable names which should always be accepted, separated by a comma
|
||||
good-names=i,j,k,ex,Run,_
|
||||
|
||||
# Bad variable names which should always be refused, separated by a comma
|
||||
bad-names=foo,bar,baz,toto,tutu,tata
|
||||
|
||||
# Colon-delimited sets of names that determine each other's naming style when
|
||||
# the name regexes allow several styles.
|
||||
name-group=
|
||||
|
||||
# Include a hint for the correct naming format with invalid-name
|
||||
include-naming-hint=no
|
||||
|
||||
# Regular expression matching correct function names
|
||||
function-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for function names
|
||||
function-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression matching correct variable names
|
||||
variable-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for variable names
|
||||
variable-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression matching correct constant names
|
||||
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||
|
||||
# Naming hint for constant names
|
||||
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||
|
||||
# Regular expression matching correct attribute names
|
||||
attr-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for attribute names
|
||||
attr-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression matching correct argument names
|
||||
argument-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for argument names
|
||||
argument-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression matching correct class attribute names
|
||||
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
|
||||
|
||||
# Naming hint for class attribute names
|
||||
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
|
||||
|
||||
# Regular expression matching correct inline iteration names
|
||||
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
|
||||
|
||||
# Naming hint for inline iteration names
|
||||
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
|
||||
|
||||
# Regular expression matching correct class names
|
||||
class-rgx=[A-Z_][a-zA-Z0-9]+$
|
||||
|
||||
# Naming hint for class names
|
||||
class-name-hint=[A-Z_][a-zA-Z0-9]+$
|
||||
|
||||
# Regular expression matching correct module names
|
||||
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||
|
||||
# Naming hint for module names
|
||||
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||
|
||||
# Regular expression matching correct method names
|
||||
method-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for method names
|
||||
method-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression which should only match function or class names that do
|
||||
# not require a docstring.
|
||||
no-docstring-rgx=^_
|
||||
|
||||
# Minimum line length for functions/classes that require docstrings, shorter
|
||||
# ones are exempt.
|
||||
docstring-min-length=-1
|
||||
|
||||
|
||||
[ELIF]
|
||||
|
||||
# Maximum number of nested blocks for function / method body
|
||||
max-nested-blocks=5
|
||||
|
||||
|
||||
[SPELLING]
|
||||
|
||||
# Spelling dictionary name. Available dictionaries: none. To make it working
|
||||
# install python-enchant package.
|
||||
spelling-dict=
|
||||
|
||||
# List of comma separated words that should not be checked.
|
||||
spelling-ignore-words=
|
||||
|
||||
# A path to a file that contains private dictionary; one word per line.
|
||||
spelling-private-dict-file=
|
||||
|
||||
# Tells whether to store unknown words to indicated private dictionary in
|
||||
# --spelling-private-dict-file option instead of raising a message.
|
||||
spelling-store-unknown-words=no
|
||||
|
||||
|
||||
[FORMAT]
|
||||
|
||||
# Maximum number of characters on a single line.
|
||||
max-line-length=100
|
||||
|
||||
# Regexp for a line that is allowed to be longer than the limit.
|
||||
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
|
||||
|
||||
# Allow the body of an if to be on the same line as the test if there is no
|
||||
# else.
|
||||
single-line-if-stmt=no
|
||||
|
||||
# List of optional constructs for which whitespace checking is disabled. `dict-
|
||||
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
|
||||
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
|
||||
# `empty-line` allows space-only lines.
|
||||
no-space-check=trailing-comma,dict-separator
|
||||
|
||||
# Maximum number of lines in a module
|
||||
max-module-lines=1000
|
||||
|
||||
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||
# tab).
|
||||
indent-string=' '
|
||||
|
||||
# Number of spaces of indent required inside a hanging or continued line.
|
||||
indent-after-paren=4
|
||||
|
||||
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
|
||||
expected-line-ending-format=
|
||||
|
||||
|
||||
[MISCELLANEOUS]
|
||||
|
||||
# List of note tags to take in consideration, separated by a comma.
|
||||
notes=FIXME,XXX,TODO
|
||||
|
||||
|
||||
[SIMILARITIES]
|
||||
|
||||
# Minimum lines number of a similarity.
|
||||
min-similarity-lines=4
|
||||
|
||||
# Ignore comments when computing similarities.
|
||||
ignore-comments=yes
|
||||
|
||||
# Ignore docstrings when computing similarities.
|
||||
ignore-docstrings=yes
|
||||
|
||||
# Ignore imports when computing similarities.
|
||||
ignore-imports=no
|
||||
|
||||
|
||||
[TYPECHECK]
|
||||
|
||||
# Tells whether missing members accessed in mixin class should be ignored. A
|
||||
# mixin class is detected if its name ends with "mixin" (case insensitive).
|
||||
ignore-mixin-members=yes
|
||||
|
||||
# List of module names for which member attributes should not be checked
|
||||
# (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
|
||||
|
||||
# List of classes names for which member attributes should not be checked
|
||||
# (useful for classes with attributes dynamically set). This supports can work
|
||||
# with qualified names.
|
||||
ignored-classes=twisted.internet,RequestMessage
|
||||
|
||||
# List of members which are set dynamically and missed by pylint inference
|
||||
# system, and so shouldn't trigger E1101 when accessed. Python regular
|
||||
# expressions are accepted.
|
||||
generated-members=
|
||||
|
||||
|
||||
[IMPORTS]
|
||||
|
||||
# Deprecated modules which should not be used, separated by a comma
|
||||
deprecated-modules=regsub,TERMIOS,Bastion,rexec
|
||||
|
||||
# Create a graph of every (i.e. internal and external) dependencies in the
|
||||
# given file (report RP0402 must not be disabled)
|
||||
import-graph=
|
||||
|
||||
# Create a graph of external dependencies in the given file (report RP0402 must
|
||||
# not be disabled)
|
||||
ext-import-graph=
|
||||
|
||||
# Create a graph of internal dependencies in the given file (report RP0402 must
|
||||
# not be disabled)
|
||||
int-import-graph=
|
||||
|
||||
|
||||
[DESIGN]
|
||||
|
||||
# Maximum number of arguments for function / method
|
||||
max-args=5
|
||||
|
||||
# Argument names that match this expression will be ignored. Default to name
|
||||
# with leading underscore
|
||||
ignored-argument-names=_.*
|
||||
|
||||
# Maximum number of locals for function / method body
|
||||
max-locals=15
|
||||
|
||||
# Maximum number of return / yield for function / method body
|
||||
max-returns=6
|
||||
|
||||
# Maximum number of branch for function / method body
|
||||
max-branches=12
|
||||
|
||||
# Maximum number of statements in function / method body
|
||||
max-statements=50
|
||||
|
||||
# Maximum number of parents for a class (see R0901).
|
||||
max-parents=7
|
||||
|
||||
# Maximum number of attributes for a class (see R0902).
|
||||
max-attributes=7
|
||||
|
||||
# Minimum number of public methods for a class (see R0903).
|
||||
min-public-methods=2
|
||||
|
||||
# Maximum number of public methods for a class (see R0904).
|
||||
max-public-methods=20
|
||||
|
||||
# Maximum number of boolean expressions in a if statement
|
||||
max-bool-expr=5
|
||||
|
||||
|
||||
[CLASSES]
|
||||
|
||||
# List of method names used to declare (i.e. assign) instance attributes.
|
||||
defining-attr-methods=__init__,__new__,setUp
|
||||
|
||||
# List of valid names for the first argument in a class method.
|
||||
valid-classmethod-first-arg=cls
|
||||
|
||||
# List of valid names for the first argument in a metaclass class method.
|
||||
valid-metaclass-classmethod-first-arg=mcs
|
||||
|
||||
# List of member names, which should be excluded from the protected access
|
||||
# warning.
|
||||
exclude-protected=_asdict,_fields,_replace,_source,_make
|
||||
|
||||
|
||||
[EXCEPTIONS]
|
||||
|
||||
# Exceptions that will emit a warning when being caught. Defaults to
|
||||
# "Exception"
|
||||
overgeneral-exceptions=Exception
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
sudo: required
|
||||
dist: trusty
|
||||
# dh-virtualenv requires that we use the same python interpreter
|
||||
# that comes with the system, so we don't want to use anything that
|
||||
# travis would try to set-up for us in python
|
||||
language: generic
|
||||
- os: osx
|
||||
# Use generic language for osx
|
||||
# python 2.7 is broken on osx on travis, so follow we have to specify the installation ourselves
|
||||
# https://github.com/travis-ci/travis-ci/issues/2312#issuecomment-195620855
|
||||
language: generic
|
||||
osx_image: xcode7.3
|
||||
|
||||
before_install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./packaging/travis/setup_osx.sh; fi
|
||||
|
||||
install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./packaging/travis/install_dependencies_and_run_tests.sh; fi
|
||||
|
||||
before_script:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then openssl aes-256-cbc -k "$ENCRYPTION_SECRET" -in packaging/osx/certs/dist.cer.enc -d -a -out packaging/osx/certs/dist.cer; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then openssl aes-256-cbc -k "$ENCRYPTION_SECRET" -in packaging/osx/certs/dist.p12.enc -d -a -out packaging/osx/certs/dist.p12; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./packaging/osx/add-key.sh; fi
|
||||
|
||||
script:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then bash packaging/ubuntu/ubuntu_package_setup.sh -t; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd packaging/osx/lbry-osx-app && ./setup_app.sh && cd $TRAVIS_BUILD_DIR; fi
|
||||
# fail the build if this is a build for a tag and we don't have the versions matching; allow tags that start with 'test' to pass
|
||||
- if [[ -n "${TRAVIS_TAG}" ]]; then if [[ "${TRAVIS_TAG}" == test* ]] || [[ "v`python setup.py -V`" = "${TRAVIS_TAG}" ]]; then true; else false; fi; fi
|
||||
|
||||
deploy:
|
||||
- provider: releases
|
||||
file: "${TRAVIS_BUILD_DIR}/`python setup.py --name`_`python setup.py -V`_amd64.deb"
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
condition: "$TRAVIS_OS_NAME = linux"
|
||||
# this is the oauth token for the lbry-ci user
|
||||
api_key:
|
||||
secure: nKdWGROnLNodx9k9nWvq2wezkPvSVL8zF63qjPXjhdOe9kCUbcLp7WnFDYpn9EJj4Pofq/ejeCHwjA+5x7JUP3Szk7SlJV61B4c/5hl64rl7oSKOoKskjdE2jaOG3CJuOUrh0yQ59U3vMMABcsnw/wJaCIuu/erdPIm8g8R+stu1YHOGtl5Y9WiW+zLJn2vc3GooV1TWtki9EnrmFfw0Vrqc4RMVMFB1ojE7ggrK1LIwcmGSbLIYzker1ZRz8SCy+84sGk4//V+2i2NNiz5AkPuG7BBGrU2twE9nD23IlruJAdVdi71P3ytAmi0kKyvxIU4VeNaqyTk9zeL5IB9J5IIgvekHgKcsKhFUZ6QcXT1Xfxl4ELftvWCTHWiewnXFdqLcG9GZiUaE6+7wdalwDAP3tqS2emiibetlBZERHR+RMR00ej+1MBYWGMlTse/0Tglndv0a2qqgAJYLKPRT02hTRYGxZ1MrJe+WGnChRmzwgLVTIgZuiDciFOahN0TYGSORk6OpnZBsxvpzSqDw5UDJx0BmbJ1xMNDFbOs8ubZ9yIpB9yNMGw66FPacOF61XNYnmA68ILC28UtOFKuuHLrUPbM5JmQkDVhtTfFbBnyHefyCLAL4MHvJJKGi1oaOXjYaJ/J095h636/kQ0cHHuVMgoWUQZOQ44xRAz7tMuc=
|
||||
- provider: releases
|
||||
file: "${TRAVIS_BUILD_DIR}/packaging/osx/lbry-osx-app/`python setup.py --name`.`python setup.py -V`.dmg"
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
condition: "$TRAVIS_OS_NAME = osx"
|
||||
# this is the oauth token for the lbry-ci user
|
||||
api_key:
|
||||
secure: nKdWGROnLNodx9k9nWvq2wezkPvSVL8zF63qjPXjhdOe9kCUbcLp7WnFDYpn9EJj4Pofq/ejeCHwjA+5x7JUP3Szk7SlJV61B4c/5hl64rl7oSKOoKskjdE2jaOG3CJuOUrh0yQ59U3vMMABcsnw/wJaCIuu/erdPIm8g8R+stu1YHOGtl5Y9WiW+zLJn2vc3GooV1TWtki9EnrmFfw0Vrqc4RMVMFB1ojE7ggrK1LIwcmGSbLIYzker1ZRz8SCy+84sGk4//V+2i2NNiz5AkPuG7BBGrU2twE9nD23IlruJAdVdi71P3ytAmi0kKyvxIU4VeNaqyTk9zeL5IB9J5IIgvekHgKcsKhFUZ6QcXT1Xfxl4ELftvWCTHWiewnXFdqLcG9GZiUaE6+7wdalwDAP3tqS2emiibetlBZERHR+RMR00ej+1MBYWGMlTse/0Tglndv0a2qqgAJYLKPRT02hTRYGxZ1MrJe+WGnChRmzwgLVTIgZuiDciFOahN0TYGSORk6OpnZBsxvpzSqDw5UDJx0BmbJ1xMNDFbOs8ubZ9yIpB9yNMGw66FPacOF61XNYnmA68ILC28UtOFKuuHLrUPbM5JmQkDVhtTfFbBnyHefyCLAL4MHvJJKGi1oaOXjYaJ/J095h636/kQ0cHHuVMgoWUQZOQ44xRAz7tMuc=
|
||||
|
||||
env:
|
||||
global:
|
||||
# needed to unlock the identity file when its on the keychain
|
||||
- secure: "aqgVNHfeh6JUqTTWG5+W+tTsIJkePS6HyLkcZlq6ODYrfdGKa90EeV4q4wdGfP5IkrBbf+WBFACDGVp574E7vfMLMNKUDuUtgnGVPwqOIhjG82ud8Xa7qF7lsw50QOnRYYVd2GLlCIzk8sffT5ncjSPN2ClNVM5iTwCkC8TNSAVnEJxu6bG6hcaT4uCWWjs0m+39O1xJwxJ4vTjpE/gy+j2FTSaUR5cNavOVCyJqpeKlga9aoBVsQHWvxlYurdWbwRLwVIV7bDE+sYPnwn1nMFQpx5RZ1AX1Z2UxNFKcYzLJgcWe85OjxLyT4udX+XZ9SLsdOjm1n201OLEKsmTxmHS8yqpbu6+pKQ1rLMEVpgPGfS8DdtqZyb3z0u6q4jztpm+uBe8hnFgwQFGXO63nOQsI0n1PMR3evAnVx7jYt7y/UALs2A9yjosMwDqgql1FMhyd0OJGo8Ky8YpDsr2J5zGVvIqt2/N+lP+SOe2D1J/5EhGlY0o4tqIAFskh3q8/GR6UGm70KT2l4LJqrU1WGrGxPJ+HoOEmvG6eqLesk03fAX3v5+DgXZWErnzXMIOGDPaFVpmx+G9VZTIlmf+3Wbu9TnZE5PRwFTdP1rqjGpjUhHeF0VTc2qgNq1OfL98CBO1wLgA195+em58cELalnwDMWUTmY1Jt1kUuAtCc11U="
|
||||
# used to decypt the aes decrypt the certificate and identity files
|
||||
- secure: "FzftiEBFMngQIci5KZ+tpKs/BubalhWXJ9f8yogGNVa3XplLheUXYgcsNU8sYT2MJaKAHN9fSjHWb67UtKT7yXddXxeOPnW6wJ3ua/FXnpynsmeGKTfh3stvgjpzdXous67uHmCWMMklfb6z7UuDohjUMAe5n5HKw5tq1RzTKpc2kJacOC6qUT5laUOvULyCaO9E9HmbHeR5ZeXAC6pnzX2ccsSrcXvPozHzBIZ9RyothKs+CZw8PEuJo07RRL8meboegqYOUrOYuz6A2gS2mZJoy59ivZKOFxS5shEuv2Jt80RyfyxBoUpKFq8OG3Am5nAEzDiTIGzmIoKDEGKeTagk/sEtSZXiMDkzDT4GX/j1rUNLCBU87bXEFS2zfRsrfg8c1XZPIzDYBT1PY2QtLBdddF5zzDoKdPLJ3sjN+fZFE5RlnwfwnMHriVRZZlzjcdk0Z06gKTBCxUg5BZamnOOK+K8qunMJXVS+Vmi5u4RoTZZiCosUlYKnSKJ8suO9C0+znxoViusPqP4ONprNHgDoZw+UKio84QW3PrZv9h4zH/D+msDgJRZ0ceqDD+6Wz1J8Mm5ptW1GOLh/IU12TPXjxteqh0Um2vv5eIPmjK9uEK666kK7PqtPDkYhAfWvF+nmOOyPMJfbP4MW/i9WHNF4ghsIMbPKfqNhgSmfrYw="
|
||||
@@ -0,0 +1,85 @@
|
||||
#### Getting LBRY for development
|
||||
|
||||
Q: How do I get lbry for command line?
|
||||
|
||||
A: In order to run lbry from command line, you need more than the packaged app/deb.
|
||||
|
||||
######On OS X
|
||||
|
||||
You can install LBRY command line by running `curl -sL https://rawgit.com/lbryio/lbry-setup/master/lbry_setup_osx.sh | sudo bash` in a terminal. This script will install lbrynet and its dependancies, as well as the app.
|
||||
|
||||
######On Linux
|
||||
|
||||
On Ubuntu or Mint you can install the prerequisites and lbrynet by running
|
||||
|
||||
sudo apt-get install libgmp3-dev build-essential python2.7 python2.7-dev python-pip
|
||||
git clone https://github.com/lbryio/lbry.git
|
||||
cd lbry
|
||||
sudo python setup.py install
|
||||
|
||||
#### Using LBRY
|
||||
|
||||
Q: How do I run lbry from command line?
|
||||
|
||||
A: The command is `lbrynet-daemon`
|
||||
|
||||
***********
|
||||
|
||||
Q: How do I stop lbry from the command line?
|
||||
|
||||
A: You can ctrl-c or run `stop-lbrynet-daemon`
|
||||
|
||||
***********
|
||||
|
||||
Q: How do I run lbry with lbrycrdd (the blockchain node application)?
|
||||
|
||||
A: Start lbry with the --wallet flag set: `lbrynet-daemon --wallet=lbrycrd`
|
||||
|
||||
Note: when you change the wallet it is persistant until you specify you want to use another wallet - lbryum - with the --wallet flag again.
|
||||
|
||||
***********
|
||||
|
||||
Q: Where are all the behind the scenes files?
|
||||
|
||||
A: On linux, the relevant directories are `~/.lbrynet`, `~/.lbrycrd`, and `~/.lbryum`, depending on which wallets you've used. On OS X, the folders of interest are `~/Library/Application Support/LBRY`, `~/.lbrycrd` and `~/.lbryum`, also depending on which wallets you've used.
|
||||
|
||||
***********
|
||||
|
||||
Q: How can I see the log in the console?
|
||||
|
||||
A: Run lbry with the --log-to-console flag set: `lbrynet-daemon --log-to-console`
|
||||
|
||||
***********
|
||||
|
||||
Q: How do I specify a web-UI to use?
|
||||
|
||||
A: If the files for the UI you'd like to use are storred locally on your computer, start lbry with the --ui flag: `lbrynet-daemon --ui=/full/path/to/ui/files/root/folder`
|
||||
|
||||
Note, once set with the UI flag the given UI will be cached by lbry and used as the default going forward. Also, it will only successfully load a UI if it contains a conforming requirements.txt file to specify required lbrynet and lbryum versions. [Here](https://github.com/lbryio/lbry-web-ui/blob/master/dist/requirements.txt) is an example requirements.txt file.
|
||||
|
||||
To reset your ui to pull from lbryio, or to try a UI still in development, run lbry with the --branch flag: `lbrynet=daemon --branch=master`
|
||||
|
||||
***********
|
||||
|
||||
Q: How do I see the list of API functions I can call, and how do I call them?
|
||||
|
||||
A: Here is an example script to get the documentation for the various API calls. To use any of the functions displayed, just provide any specified arguments in a dictionary.
|
||||
|
||||
Note: the lbry api can only be used while either the app or lbrynet-daemon command line are running
|
||||
|
||||
import sys
|
||||
from jsonrpc.proxy import JSONRPCProxy
|
||||
|
||||
try:
|
||||
from lbrynet.conf import API_CONNECTION_STRING
|
||||
except:
|
||||
print "You don't have lbrynet installed!"
|
||||
sys.exit(0)
|
||||
|
||||
api = JSONRPCProxy.from_url(API_CONNECTION_STRING)
|
||||
if not api.is_running():
|
||||
print api.daemon_status()
|
||||
else:
|
||||
for func in api.help():
|
||||
print "%s:\n%s" % (func, api.help({'function': func}))
|
||||
|
||||
+26
-10
@@ -1,19 +1,35 @@
|
||||
#### Installing lbrynet on Linux
|
||||
#### Installing the LBRY app
|
||||
--------------------------
|
||||
|
||||
The following packages are necessary (the following are their names on Ubuntu):
|
||||
libgmp3-dev build-essential python2.7 python2.7-dev python-pip
|
||||
Installing LBRY is simple. You can get a dmg installer for OS X (Mavericks and up) or a .deb for linux [here](https://lbry.io/get).
|
||||
|
||||
To install them on Ubuntu:
|
||||
sudo apt-get install libgmp3-dev build-essential python2.7 python2.7-dev python-pip
|
||||
##### OS X
|
||||
Just drag and drop LBRY.app into your applications folder (replacing any older versions). When it's running you'll have a LBRY icon in your status bar.
|
||||
|
||||
python setup.py build bdist_egg
|
||||
sudo python setup.py install
|
||||
```
|
||||
##### Linux
|
||||
Double click the .deb file and follow the prompts. The app can be started by searching "LBRY", and it can be turned off by clicking the red 'x' in the browser interface.
|
||||
|
||||
this will install all of the libraries and a few applications
|
||||
On both systems you can also open the UI while the app is running by going to lbry://lbry in Firefox or Safari, or localhost:5279 in Chrome.
|
||||
|
||||
For running the file sharing application, see [RUNNING](RUNNING.md)
|
||||
|
||||
|
||||
#### Installing LBRY command line
|
||||
--------------------------
|
||||
|
||||
##### OS X
|
||||
You can install LBRY command line by running `curl -sL https://rawgit.com/lbryio/lbry-setup/master/lbry_setup_osx.sh | sudo bash` in a terminal. This script will install lbrynet and its dependancies, as well as the app. You can start LBRY by either starting the app or by running `lbrynet-daemon` from a terminal.
|
||||
|
||||
##### Linux
|
||||
On Ubuntu or Mint you can install the prerequisites and lbrynet by running
|
||||
|
||||
```
|
||||
sudo apt-get install libgmp3-dev build-essential python2.7 python2.7-dev python-pip
|
||||
git clone https://github.com/lbryio/lbry.git
|
||||
cd lbry
|
||||
sudo python setup.py install
|
||||
```
|
||||
|
||||
To start LBRY, run `lbrynet-daemon` in a terminal.
|
||||
|
||||
#### On windows:
|
||||
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
[](https://travis-ci.org/lbryio/lbry)
|
||||
|
||||
# LBRYnet
|
||||
|
||||
LBRYnet is a fully decentralized network for distributing data. It consists of peers uploading
|
||||
and downloading data from other peers, possibly in exchange for payments, and a distributed hash
|
||||
table, used by peers to discover other peers.
|
||||
|
||||
## Installation
|
||||
|
||||
Download the [latest release](https://github.com/lbryio/lbry/releases/latest) or see [INSTALL.md](INSTALL.md) for manual installation.
|
||||
|
||||
## Overview
|
||||
|
||||
On LBRYnet, data is broken into chunks, and each chunk is specified by its sha384 hash sum. This
|
||||
@@ -18,32 +24,48 @@ help peers find each other. For example, an application for which clients don't
|
||||
necessary chunks may use some identifier, chosen by the application, to find clients which do
|
||||
know all of the necessary chunks.
|
||||
|
||||
## Running
|
||||
## For Developers
|
||||
|
||||
LBRYnet comes with an file sharing application, called 'lbrynet-console', which breaks
|
||||
The bundled LBRY application uses the lbrynet JSONRPC api found in `lbrynet.lbrynet_daemon.LBRYDaemon`. This api allows for applications and web services like the lbry browser UI to interact with lbrynet. If you've installed lbrynet, you can run `lbrynet-daemon` without running the app. While the app or `lbrynet-daemon` is running, you can use the following to show the help for all the available commands:
|
||||
|
||||
```
|
||||
from jsonrpc.proxy import JSONRPCProxy
|
||||
|
||||
try:
|
||||
from lbrynet.conf import API_CONNECTION_STRING
|
||||
except:
|
||||
print "You don't have lbrynet installed!"
|
||||
API_CONNECTION_STRING = "http://localhost:5279/lbryapi"
|
||||
|
||||
api = JSONRPCProxy.from_url(API_CONNECTION_STRING)
|
||||
if not api.is_running():
|
||||
print api.daemon_status()
|
||||
else:
|
||||
for func in api.help():
|
||||
print "%s:\n%s" % (func, api.help({'function': func}))
|
||||
```
|
||||
|
||||
If you've installed lbrynet, it comes with a file sharing application, called `lbrynet-daemon`, which breaks
|
||||
files into chunks, encrypts them with a symmetric key, computes their sha384 hash sum, generates
|
||||
a special file called a 'stream descriptor' containing the hash sums and some other file metadata,
|
||||
and makes the chunks available for download by other peers. A peer wishing to download the file
|
||||
must first obtain the 'stream descriptor' and then may open it with his 'lbrynet-console' client,
|
||||
must first obtain the 'stream descriptor' and then may open it with his `lbrynet-daemon` client,
|
||||
download all of the chunks by locating peers with the chunks via the DHT, and then combine the
|
||||
chunks into the original file, according to the metadata included in the 'stream descriptor'.
|
||||
|
||||
To install and use this client, see [INSTALL](INSTALL.md) and [RUNNING](RUNNING.md)
|
||||
For detailed instructions, see [INSTALL.md](INSTALL.md) and [RUNNING.md](RUNNING.md).
|
||||
|
||||
## Installation
|
||||
Documentation: doc.lbry.io (may be out of date)
|
||||
|
||||
See [INSTALL](INSTALL.md)
|
||||
|
||||
## Developers
|
||||
|
||||
Documentation: doc.lbry.io
|
||||
Source code: https://github.com/lbryio/lbry
|
||||
|
||||
To contribute to the development of LBRYnet or lbrynet-console, contact jimmy@lbry.io
|
||||
To contribute, [join us on Slack](https://lbry-slackin.herokuapp.com/) or contact josh@lbry.io. Pull requests are also welcome.
|
||||
|
||||
## Support
|
||||
|
||||
Send all support requests to jimmy@lbry.io
|
||||
Please open an issue and describe your situation in detail. We will respond as soon as we can.
|
||||
|
||||
For private issues, contact josh@lbry.io.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import logging
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
log.setLevel(logging.ERROR)
|
||||
|
||||
|
||||
version = (0, 2, 3)
|
||||
version = (0, 2, 5)
|
||||
__version__ = ".".join([str(x) for x in version])
|
||||
+10
-5
@@ -3,9 +3,6 @@ Some network wide and also application specific parameters
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
|
||||
|
||||
MAX_HANDSHAKE_SIZE = 2**16
|
||||
MAX_REQUEST_SIZE = 2**16
|
||||
MAX_BLOB_REQUEST_SIZE = 2**16
|
||||
@@ -19,11 +16,17 @@ MIN_VALUABLE_BLOB_INFO_PAYMENT_RATE = .05 # points/1000 infos
|
||||
MIN_VALUABLE_BLOB_HASH_PAYMENT_RATE = .05 # points/1000 infos
|
||||
MAX_CONNECTIONS_PER_STREAM = 5
|
||||
|
||||
KNOWN_DHT_NODES = [('104.236.42.182', 4000)]
|
||||
KNOWN_DHT_NODES = [('104.236.42.182', 4000),
|
||||
('lbryum1.lbry.io', 4444),
|
||||
('lbryum2.lbry.io', 4444),
|
||||
('lbryum3.lbry.io', 4444)]
|
||||
|
||||
POINTTRADER_SERVER = 'http://ec2-54-187-192-68.us-west-2.compute.amazonaws.com:2424'
|
||||
#POINTTRADER_SERVER = 'http://127.0.0.1:2424'
|
||||
|
||||
LOG_FILE_NAME = "lbrynet.log"
|
||||
LOG_POST_URL = "https://lbry.io/log-upload"
|
||||
|
||||
CRYPTSD_FILE_EXTENSION = ".cryptsd"
|
||||
|
||||
API_INTERFACE = "localhost"
|
||||
@@ -36,8 +39,10 @@ UI_ADDRESS = "http://" + API_INTERFACE + ":" + str(API_PORT)
|
||||
PROTOCOL_PREFIX = "lbry"
|
||||
|
||||
DEFAULT_WALLET = "lbryum"
|
||||
WALLET_TYPES = ["lbryum", "lbrycrd"]
|
||||
DEFAULT_TIMEOUT = 30
|
||||
DEFAULT_MAX_SEARCH_RESULTS = 25
|
||||
DEFAULT_MAX_KEY_FEE = 100.0
|
||||
DEFAULT_SEARCH_TIMEOUT = 3.0
|
||||
DEFAULT_CACHE_TIME = 3600
|
||||
DEFAULT_CACHE_TIME = 3600
|
||||
DEFAULT_UI_BRANCH = "master"
|
||||
@@ -295,6 +295,11 @@ class LBRYWallet(object):
|
||||
d.addCallback(self._get_stream_info_from_value, name)
|
||||
return d
|
||||
|
||||
def get_txid_for_name(self, name):
|
||||
d = self._get_value_for_name(name)
|
||||
d.addCallback(lambda r: None if 'txid' not in r else r['txid'])
|
||||
return d
|
||||
|
||||
def get_stream_info_from_txid(self, name, txid):
|
||||
d = self.get_claims_from_tx(txid)
|
||||
|
||||
@@ -530,8 +535,10 @@ class LBRYWallet(object):
|
||||
" sd_hash text)")
|
||||
|
||||
def _save_name_metadata(self, name, sd_hash, txid):
|
||||
d = self.db.runQuery("insert into name_metadata values (?, ?, ?)",
|
||||
(name, txid, sd_hash))
|
||||
d = self.db.runQuery("select * from name_metadata where txid=?", (txid,))
|
||||
d.addCallback(lambda r: self.db.runQuery("insert into name_metadata values (?, ?, ?)", (name, txid, sd_hash))
|
||||
if not len(r) else None)
|
||||
|
||||
return d
|
||||
|
||||
def _get_claim_metadata_for_sd_hash(self, sd_hash):
|
||||
|
||||
@@ -28,7 +28,7 @@ class LBRYSession(object):
|
||||
def __init__(self, blob_data_payment_rate, db_dir=None, lbryid=None, peer_manager=None, dht_node_port=None,
|
||||
known_dht_nodes=None, peer_finder=None, hash_announcer=None,
|
||||
blob_dir=None, blob_manager=None, peer_port=None, use_upnp=True,
|
||||
rate_limiter=None, wallet=None):
|
||||
rate_limiter=None, wallet=None, dht_node_class=node.Node):
|
||||
"""
|
||||
@param blob_data_payment_rate: The default payment rate for blob data
|
||||
|
||||
@@ -99,7 +99,7 @@ class LBRYSession(object):
|
||||
self.upnp_redirects = []
|
||||
|
||||
self.wallet = wallet
|
||||
|
||||
self.dht_node_class = dht_node_class
|
||||
self.dht_node = None
|
||||
|
||||
self.base_payment_rate_manager = BasePaymentRateManager(blob_data_payment_rate)
|
||||
@@ -220,8 +220,11 @@ class LBRYSession(object):
|
||||
d.addCallback(match_port, port)
|
||||
ds.append(d)
|
||||
|
||||
self.dht_node = node.Node(udpPort=self.dht_node_port, lbryid=self.lbryid,
|
||||
externalIP=self.external_ip)
|
||||
self.dht_node = self.dht_node_class(
|
||||
udpPort=self.dht_node_port,
|
||||
lbryid=self.lbryid,
|
||||
externalIP=self.external_ip
|
||||
)
|
||||
self.peer_finder = DHTPeerFinder(self.dht_node, self.peer_manager)
|
||||
if self.hash_announcer is None:
|
||||
self.hash_announcer = DHTHashAnnouncer(self.dht_node, self.peer_port)
|
||||
@@ -269,4 +272,4 @@ class LBRYSession(object):
|
||||
|
||||
d = threads.deferToThread(threaded_unset_upnp)
|
||||
d.addErrback(lambda err: str(err))
|
||||
return d
|
||||
return d
|
||||
@@ -52,7 +52,7 @@ class DownloadManager(object):
|
||||
|
||||
def check_stop(result, manager):
|
||||
if isinstance(result, failure.Failure):
|
||||
log.error("Failed to stop the %s: %s", manager. result.getErrorMessage())
|
||||
log.error("Failed to stop the %s: %s", manager, result.getErrorMessage())
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -115,4 +115,4 @@ class DownloadManager(object):
|
||||
if not self.blobs:
|
||||
return self.calculate_total_bytes()
|
||||
else:
|
||||
return sum([b.length for b in self.needed_blobs() if b.length is not None])
|
||||
return sum([b.length for b in self.needed_blobs() if b.length is not None])
|
||||
@@ -25,6 +25,8 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
||||
stream_info_manager, payment_rate_manager, wallet, download_directory,
|
||||
upload_allowed, file_name)
|
||||
self.sd_hash = None
|
||||
self.txid = None
|
||||
self.uri = None
|
||||
self.rowid = rowid
|
||||
self.lbry_file_manager = lbry_file_manager
|
||||
self.saving_status = False
|
||||
@@ -35,10 +37,19 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
||||
def _save_sd_hash(sd_hash):
|
||||
if len(sd_hash):
|
||||
self.sd_hash = sd_hash[0]
|
||||
d = self.wallet._get_claim_metadata_for_sd_hash(self.sd_hash)
|
||||
else:
|
||||
d = defer.succeed(None)
|
||||
|
||||
return d
|
||||
|
||||
def _save_claim(name, txid):
|
||||
self.uri = name
|
||||
self.txid = txid
|
||||
return defer.succeed(None)
|
||||
|
||||
d.addCallback(_save_sd_hash)
|
||||
|
||||
d.addCallback(lambda r: _save_claim(r[0], r[1]) if r else None)
|
||||
d.addCallback(lambda _: self.lbry_file_manager.get_lbry_file_status(self))
|
||||
|
||||
def restore_status(status):
|
||||
@@ -100,11 +111,21 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
||||
d.addCallback(lambda _: self.stream_info_manager._get_sd_blob_hashes_for_stream(self.stream_hash))
|
||||
|
||||
def _save_sd_hash(sd_hash):
|
||||
self.sd_hash = sd_hash[0]
|
||||
if len(sd_hash):
|
||||
self.sd_hash = sd_hash[0]
|
||||
d = self.wallet._get_claim_metadata_for_sd_hash(self.sd_hash)
|
||||
else:
|
||||
d = defer.succeed(None)
|
||||
|
||||
return d
|
||||
|
||||
def _save_claim(name, txid):
|
||||
self.uri = name
|
||||
self.txid = txid
|
||||
return defer.succeed(None)
|
||||
|
||||
d.addCallback(_save_sd_hash)
|
||||
|
||||
d.addCallback(lambda r: _save_claim(r[0], r[1]) if r else None)
|
||||
d.addCallback(lambda _: self._save_status())
|
||||
|
||||
return d
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
# pylint: skip-file
|
||||
# This file is not maintained, but might be used in the future
|
||||
#
|
||||
import logging
|
||||
import sys
|
||||
from lbrynet.lbrylive.LiveStreamCreator import StdOutLiveStreamCreator
|
||||
@@ -15,7 +18,8 @@ from twisted.internet import defer, task
|
||||
|
||||
class LBRYStdinUploader():
|
||||
"""This class reads from standard in, creates a stream, and makes it available on the network."""
|
||||
def __init__(self, peer_port, dht_node_port, known_dht_nodes):
|
||||
def __init__(self, peer_port, dht_node_port, known_dht_nodes,
|
||||
stream_info_manager_class=DBLiveStreamMetadataManager, blob_manager_class=TempBlobManager):
|
||||
"""
|
||||
@param peer_port: the network port on which to listen for peers
|
||||
|
||||
@@ -25,8 +29,8 @@ class LBRYStdinUploader():
|
||||
"""
|
||||
self.peer_port = peer_port
|
||||
self.lbry_server_port = None
|
||||
self.session = LBRYSession(blob_manager_class=TempBlobManager,
|
||||
stream_info_manager_class=DBLiveStreamMetadataManager,
|
||||
self.session = LBRYSession(blob_manager_class=blob_manager_class,
|
||||
stream_info_manager_class=stream_info_manager_class,
|
||||
dht_node_class=Node, dht_node_port=dht_node_port,
|
||||
known_dht_nodes=known_dht_nodes, peer_port=self.peer_port,
|
||||
use_upnp=False)
|
||||
@@ -114,4 +118,4 @@ def launch_stdin_uploader():
|
||||
d.addCallback(lambda _: start_stdin_uploader())
|
||||
d.addCallback(lambda _: shut_down())
|
||||
reactor.addSystemEventTrigger('before', 'shutdown', uploader.shut_down)
|
||||
reactor.run()
|
||||
reactor.run()
|
||||
@@ -1,7 +1,10 @@
|
||||
# pylint: skip-file
|
||||
# This file is not maintained, but might be used in the future
|
||||
#
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from lbrynet.lbrynet_console.plugins.LBRYLive.LBRYLiveStreamDownloader import LBRYLiveStreamDownloader
|
||||
from lbrynet.lbrylive.client.LiveStreamDownloader import LBRYLiveStreamDownloader
|
||||
from lbrynet.core.BlobManager import TempBlobManager
|
||||
from lbrynet.core.Session import LBRYSession
|
||||
from lbrynet.core.client.StandaloneBlobDownloader import StandaloneBlobDownloader
|
||||
@@ -15,15 +18,17 @@ from twisted.internet import task
|
||||
|
||||
class LBRYStdoutDownloader():
|
||||
"""This class downloads a live stream from the network and outputs it to standard out."""
|
||||
def __init__(self, dht_node_port, known_dht_nodes):
|
||||
def __init__(self, dht_node_port, known_dht_nodes,
|
||||
stream_info_manager_class=DBLiveStreamMetadataManager, blob_manager_class=TempBlobManager):
|
||||
"""
|
||||
@param dht_node_port: the network port on which to listen for DHT node requests
|
||||
|
||||
@param known_dht_nodes: a list of (ip_address, dht_port) which will be used to join the DHT network
|
||||
|
||||
"""
|
||||
self.session = LBRYSession(blob_manager_class=TempBlobManager,
|
||||
stream_info_manager_class=DBLiveStreamMetadataManager,
|
||||
|
||||
self.session = LBRYSession(blob_manager_class=blob_manager_class,
|
||||
stream_info_manager_class=stream_info_manager_class,
|
||||
dht_node_class=Node, dht_node_port=dht_node_port, known_dht_nodes=known_dht_nodes,
|
||||
use_upnp=False)
|
||||
self.payment_rate_manager = BaseLiveStreamPaymentRateManager()
|
||||
@@ -93,4 +98,4 @@ def launch_stdout_downloader():
|
||||
d.addErrback(print_error)
|
||||
d.addCallback(lambda _: shut_down())
|
||||
reactor.addSystemEventTrigger('before', 'shutdown', downloader.shut_down)
|
||||
reactor.run()
|
||||
reactor.run()
|
||||
@@ -120,7 +120,7 @@ class CommandHandlerFactory(object):
|
||||
return self.control_handler_class.prompt_description
|
||||
|
||||
def get_handler(self, console):
|
||||
return self.control_handler_class(console, *self.args)
|
||||
return self.control_handler_class(console, *self.args) # pylint: disable=not-callable
|
||||
|
||||
|
||||
class CommandHandler(object):
|
||||
|
||||
@@ -101,7 +101,7 @@ class ValuableBlobHashQueryHandler(ValuableQueryHandler):
|
||||
for blob_hash, count in valuable_hashes:
|
||||
hashes_and_scores.append((blob_hash, 1.0 * count / 10.0))
|
||||
if len(hashes_and_scores) != 0:
|
||||
log.info("Responding to a valuable blob hashes request with %s blob hashes: %s",
|
||||
log.info("Responding to a valuable blob hashes request with %s blob hashes",
|
||||
str(len(hashes_and_scores)))
|
||||
expected_payment = 1.0 * len(hashes_and_scores) * self.valuable_blob_hash_payment_rate / 1000.0
|
||||
self.wallet.add_expected_payment(self.peer, expected_payment)
|
||||
@@ -193,10 +193,10 @@ class ValuableBlobLengthQueryHandler(ValuableQueryHandler):
|
||||
if success is True:
|
||||
lengths.append(response_pair)
|
||||
if len(lengths) > 0:
|
||||
log.info("Responding with %s blob lengths: %s", str(len(lengths)))
|
||||
log.info("Responding with %s blob lengths", str(len(lengths)))
|
||||
expected_payment = 1.0 * len(lengths) * self.blob_length_payment_rate / 1000.0
|
||||
self.wallet.add_expected_payment(self.peer, expected_payment)
|
||||
self.peer.update_stats('uploaded_valuable_blob_infos', len(lengths))
|
||||
return {'blob_length': {'blob_lengths': lengths}}
|
||||
|
||||
dl.addCallback(make_response)
|
||||
dl.addCallback(make_response)
|
||||
@@ -1,108 +0,0 @@
|
||||
import rumps
|
||||
import xmlrpclib
|
||||
import os
|
||||
import webbrowser
|
||||
import subprocess
|
||||
import argparse
|
||||
|
||||
|
||||
class DaemonStatusBarApp(rumps.App):
|
||||
def __init__(self):
|
||||
icon_path = 'app.icns'
|
||||
if os.path.isfile(icon_path):
|
||||
rumps.App.__init__(self, name="LBRY", icon=icon_path, quit_button=None,
|
||||
menu=["Open", "Preferences", "View balance", "Quit"])
|
||||
else:
|
||||
rumps.App.__init__(self, name="LBRY", title="LBRY", quit_button=None,
|
||||
menu=["Open", "Preferences", "View balance", "Quit"])
|
||||
|
||||
@rumps.timer(1)
|
||||
def alert_daemon_start(self):
|
||||
daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
|
||||
try:
|
||||
start_msg = daemon.is_running()
|
||||
if isinstance(start_msg, str):
|
||||
rumps.notification(title='LBRY', subtitle='', message=str(start_msg), sound=True)
|
||||
update_info = daemon.check_for_new_version()
|
||||
update_msg = ""
|
||||
for p in update_info:
|
||||
if not p[0]:
|
||||
update_msg += p[1] + "\n"
|
||||
if update_msg:
|
||||
update_msg += "\n Try running the installer again to fix this"
|
||||
rumps.notification(title='LBRY', subtitle='', message=update_msg, sound=True)
|
||||
except:
|
||||
pass
|
||||
|
||||
@rumps.clicked('Open')
|
||||
def get_ui(self):
|
||||
daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
|
||||
try:
|
||||
daemon.is_running()
|
||||
webbrowser.get('safari').open("lbry://lbry")
|
||||
except:
|
||||
try:
|
||||
rumps.notification(title='LBRY', subtitle='', message="Couldn't connect to lbrynet daemon", sound=True)
|
||||
except:
|
||||
rumps.alert(title='LBRY', message="Couldn't connect to lbrynet daemon")
|
||||
|
||||
@rumps.clicked("Preferences")
|
||||
def prefs(self):
|
||||
daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
|
||||
try:
|
||||
daemon.is_running()
|
||||
webbrowser.get('safari').open("lbry://settings")
|
||||
except:
|
||||
rumps.notification(title='LBRY', subtitle='', message="Couldn't connect to lbrynet daemon", sound=True)
|
||||
|
||||
@rumps.clicked("View balance")
|
||||
def disp_balance(self):
|
||||
daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
|
||||
try:
|
||||
balance = daemon.get_balance()
|
||||
r = round(float(balance), 2)
|
||||
try:
|
||||
rumps.notification(title='LBRY', subtitle='', message=str("Your balance is %.2f LBC" % r), sound=False)
|
||||
except:
|
||||
rumps.alert(title='LBRY', message=str("Your balance is %.2f LBC" % r))
|
||||
|
||||
except:
|
||||
try:
|
||||
rumps.notification(title='LBRY', subtitle='', message="Couldn't connect to lbrynet daemon", sound=True)
|
||||
except:
|
||||
rumps.alert(title='LBRY', message="Couldn't connect to lbrynet daemon")
|
||||
|
||||
@rumps.clicked('Quit')
|
||||
def clean_quit(self):
|
||||
daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
|
||||
try:
|
||||
daemon.stop()
|
||||
except:
|
||||
pass
|
||||
rumps.quit_application()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Launch lbrynet status bar application")
|
||||
parser.add_argument("--startdaemon",
|
||||
help="true or false, default true",
|
||||
type=str,
|
||||
default="true")
|
||||
args = parser.parse_args()
|
||||
|
||||
if str(args.startdaemon).lower() == "true":
|
||||
daemon = xmlrpclib.ServerProxy('http://localhost:7080')
|
||||
try:
|
||||
daemon.is_running()
|
||||
except:
|
||||
subprocess.Popen("screen -dmS lbrynet bash -c "
|
||||
"'PYTHONPATH=$PYTHONPATH:`cat /Users/${USER}/Library/Application\ Support/lbrynet/.python_path`; "
|
||||
"PATH=$PATH:`cat /Users/${USER}/Library/Application\ Support/lbrynet/.lbry_bin_path`; "
|
||||
"lbrynet-daemon --update=False'", shell=True)
|
||||
|
||||
status_app = DaemonStatusBarApp()
|
||||
status_app.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,5 +1,7 @@
|
||||
import locale
|
||||
import mimetypes
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import simplejson as json
|
||||
import binascii
|
||||
@@ -31,19 +33,23 @@ from lbrynet.core.Error import UnknownNameError, InsufficientFundsError
|
||||
from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
|
||||
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileSaverFactory, LBRYFileOpenerFactory
|
||||
from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier
|
||||
from lbrynet.lbrynet_daemon.LBRYUIManager import LBRYUIManager
|
||||
from lbrynet.lbrynet_daemon.LBRYDownloader import GetStream
|
||||
from lbrynet.lbrynet_daemon.LBRYPublisher import Publisher
|
||||
from lbrynet.core.utils import generate_id
|
||||
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
||||
from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE, DEFAULT_MAX_SEARCH_RESULTS, KNOWN_DHT_NODES, DEFAULT_MAX_KEY_FEE, \
|
||||
DEFAULT_WALLET, DEFAULT_SEARCH_TIMEOUT, DEFAULT_CACHE_TIME
|
||||
from lbrynet.conf import API_CONNECTION_STRING, API_PORT, API_ADDRESS, DEFAULT_TIMEOUT, UI_ADDRESS
|
||||
DEFAULT_WALLET, DEFAULT_SEARCH_TIMEOUT, DEFAULT_CACHE_TIME, DEFAULT_UI_BRANCH, LOG_POST_URL, LOG_FILE_NAME
|
||||
from lbrynet.conf import DEFAULT_TIMEOUT, WALLET_TYPES
|
||||
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob
|
||||
from lbrynet.core.Session import LBRYSession
|
||||
from lbrynet.core.PTCWallet import PTCWallet
|
||||
from lbrynet.core.LBRYcrdWallet import LBRYcrdWallet, LBRYumWallet
|
||||
from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager
|
||||
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
||||
from lbryum import LOG_PATH as lbryum_log
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
if sys.platform != "darwin":
|
||||
@@ -54,33 +60,41 @@ else:
|
||||
if not os.path.isdir(log_dir):
|
||||
os.mkdir(log_dir)
|
||||
|
||||
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
|
||||
|
||||
if os.path.isfile(LOG_FILENAME):
|
||||
f = open(LOG_FILENAME, 'r')
|
||||
PREVIOUS_LOG = len(f.read())
|
||||
f.close()
|
||||
else:
|
||||
PREVIOUS_LOG = 0
|
||||
lbrynet_log = os.path.join(log_dir, LOG_FILE_NAME)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=2097152, backupCount=5)
|
||||
handler = logging.handlers.RotatingFileHandler(lbrynet_log, maxBytes=2097152, backupCount=5)
|
||||
log.addHandler(handler)
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
if os.path.isfile(lbryum_log):
|
||||
f = open(lbryum_log, 'r')
|
||||
PREVIOUS_LBRYUM_LOG = len(f.read())
|
||||
f.close()
|
||||
else:
|
||||
PREVIOUS_LBRYUM_LOG = 0
|
||||
if os.path.isfile(lbrynet_log):
|
||||
f = open(lbrynet_log, 'r')
|
||||
PREVIOUS_LBRYNET_LOG = len(f.read())
|
||||
f.close()
|
||||
else:
|
||||
PREVIOUS_LBRYNET_LOG = 0
|
||||
|
||||
INITIALIZING_CODE = 'initializing'
|
||||
LOADING_DB_CODE = 'loading_db'
|
||||
LOADING_WALLET_CODE = 'loading_wallet'
|
||||
LOADING_FILE_MANAGER_CODE = 'loading_file_manager'
|
||||
LOADING_SERVER_CODE = 'loading_server'
|
||||
STARTED_CODE = 'started'
|
||||
WAITING_FOR_FIRST_RUN_CREDITS = 'waiting_for_credits'
|
||||
STARTUP_STAGES = [
|
||||
(INITIALIZING_CODE, 'Initializing...'),
|
||||
(LOADING_DB_CODE, 'Loading databases...'),
|
||||
(LOADING_WALLET_CODE, 'Catching up with the blockchain... %s'),
|
||||
(LOADING_FILE_MANAGER_CODE, 'Setting up file manager'),
|
||||
(LOADING_SERVER_CODE, 'Starting lbrynet'),
|
||||
(STARTED_CODE, 'Started lbrynet')
|
||||
(STARTED_CODE, 'Started lbrynet'),
|
||||
(WAITING_FOR_FIRST_RUN_CREDITS, 'Waiting for first run credits...')
|
||||
]
|
||||
|
||||
DOWNLOAD_METADATA_CODE = 'downloading_metadata'
|
||||
@@ -107,7 +121,7 @@ CONNECTION_PROBLEM_CODES = [
|
||||
ALLOWED_DURING_STARTUP = ['is_running', 'is_first_run',
|
||||
'get_time_behind_blockchain', 'stop',
|
||||
'daemon_status', 'get_start_notice',
|
||||
'version', 'check_for_new_version']
|
||||
'version']
|
||||
|
||||
BAD_REQUEST = 400
|
||||
NOT_FOUND = 404
|
||||
@@ -127,7 +141,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
|
||||
isLeaf = True
|
||||
|
||||
def __init__(self, ui_version_info, wallet_type=DEFAULT_WALLET):
|
||||
def __init__(self, root, wallet_type=None):
|
||||
jsonrpc.JSONRPC.__init__(self)
|
||||
reactor.addSystemEventTrigger('before', 'shutdown', self._shutdown)
|
||||
|
||||
@@ -137,83 +151,33 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
self.connected_to_internet = True
|
||||
self.connection_problem = None
|
||||
self.query_handlers = {}
|
||||
self.ui_version = ui_version_info.replace('\n', '')
|
||||
self.git_lbrynet_version = None
|
||||
self.git_lbryum_version = None
|
||||
self.ui_version = None
|
||||
self.ip = None
|
||||
self.wallet_type = wallet_type
|
||||
self.first_run = None
|
||||
self.log_file = LOG_FILENAME
|
||||
self.log_file = lbrynet_log
|
||||
self.current_db_revision = 1
|
||||
self.run_server = True
|
||||
self.session = None
|
||||
self.waiting_on = {}
|
||||
self.streams = {}
|
||||
self.known_dht_nodes = KNOWN_DHT_NODES
|
||||
self.platform_info = {
|
||||
"processor": platform.processor(),
|
||||
"python_version: ": platform.python_version(),
|
||||
"platform": platform.platform(),
|
||||
"os_release": platform.release(),
|
||||
"os_system": platform.system(),
|
||||
"lbrynet_version: ": lbrynet_version,
|
||||
"lbryum_version: ": lbryum_version,
|
||||
"ui_version": self.ui_version,
|
||||
}
|
||||
try:
|
||||
self.platform_info['ip'] = json.load(urlopen('http://jsonip.com'))['ip']
|
||||
except:
|
||||
self.platform_info['ip'] = "Could not determine"
|
||||
self.first_run_after_update = False
|
||||
|
||||
if os.name == "nt":
|
||||
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
|
||||
default_download_directory = get_path(FOLDERID.Downloads, UserHandle.current)
|
||||
self.db_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbrynet")
|
||||
self.lbrycrdd_path = "lbrycrdd.exe"
|
||||
if wallet_type == "lbrycrd":
|
||||
self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbrycrd")
|
||||
else:
|
||||
self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbryum")
|
||||
elif sys.platform == "darwin":
|
||||
default_download_directory = os.path.join(os.path.expanduser("~"), 'Downloads')
|
||||
self.db_dir = user_data_dir("LBRY")
|
||||
self.lbrycrdd_path = "./lbrycrdd"
|
||||
if wallet_type == "lbrycrd":
|
||||
self.wallet_dir = user_data_dir("lbrycrd")
|
||||
else:
|
||||
self.wallet_dir = user_data_dir("LBRY")
|
||||
else:
|
||||
default_download_directory = os.getcwd()
|
||||
self.db_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
||||
self.lbrycrdd_path = "./lbrycrdd"
|
||||
if wallet_type == "lbrycrd":
|
||||
self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
|
||||
else:
|
||||
self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbryum")
|
||||
|
||||
self.created_data_dir = False
|
||||
if not os.path.exists(self.db_dir):
|
||||
os.mkdir(self.db_dir)
|
||||
self.created_data_dir = True
|
||||
|
||||
self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
|
||||
self.lbrycrd_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
|
||||
self.autofetcher_conf = os.path.join(self.wallet_dir, "autofetcher.conf")
|
||||
self.daemon_conf = os.path.join(self.db_dir, 'daemon_settings.json')
|
||||
self.wallet_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
|
||||
self.wallet_user = None
|
||||
self.wallet_password = None
|
||||
|
||||
self.internet_connection_checker = LoopingCall(self._check_network_connection)
|
||||
self.version_checker = LoopingCall(self._check_remote_versions)
|
||||
self.connection_problem_checker = LoopingCall(self._check_connection_problems)
|
||||
# self.lbrynet_connection_checker = LoopingCall(self._check_lbrynet_connection)
|
||||
|
||||
self.sd_identifier = StreamDescriptorIdentifier()
|
||||
self.stream_info_manager = TempLBRYFileMetadataManager()
|
||||
self.settings = LBRYSettings(self.db_dir)
|
||||
self.blob_request_payment_rate_manager = None
|
||||
self.lbry_file_metadata_manager = None
|
||||
self.lbry_file_manager = None
|
||||
|
||||
self.default_settings = {
|
||||
'run_on_startup': False,
|
||||
@@ -226,14 +190,16 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
'search_timeout': DEFAULT_SEARCH_TIMEOUT,
|
||||
'download_timeout': DEFAULT_TIMEOUT,
|
||||
'max_search_results': DEFAULT_MAX_SEARCH_RESULTS,
|
||||
'wallet_type': wallet_type,
|
||||
'wallet_type': DEFAULT_WALLET,
|
||||
'delete_blobs_on_remove': True,
|
||||
'peer_port': 3333,
|
||||
'dht_node_port': 4444,
|
||||
'use_upnp': True,
|
||||
'start_lbrycrdd': True,
|
||||
'requested_first_run_credits': False,
|
||||
'cache_time': DEFAULT_CACHE_TIME
|
||||
'cache_time': DEFAULT_CACHE_TIME,
|
||||
'startup_scripts': [],
|
||||
'last_version': {'lbrynet': lbrynet_version, 'lbryum': lbryum_version}
|
||||
}
|
||||
|
||||
if os.path.isfile(self.daemon_conf):
|
||||
@@ -253,22 +219,33 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
for k in missing_settings.keys():
|
||||
log.info("Adding missing setting: " + k + " with default value: " + str(missing_settings[k]))
|
||||
loaded_settings[k] = missing_settings[k]
|
||||
if loaded_settings['wallet_type'] != self.wallet_type and self.wallet_type:
|
||||
loaded_settings['wallet_type'] = self.wallet_type
|
||||
|
||||
if missing_settings or removed_settings:
|
||||
f = open(self.daemon_conf, "w")
|
||||
f.write(json.dumps(loaded_settings))
|
||||
f.close()
|
||||
log.info("Updated and loaded lbrynet-daemon configuration")
|
||||
else:
|
||||
log.info("Loaded lbrynet-daemon configuration")
|
||||
settings_dict = loaded_settings
|
||||
self.session_settings = loaded_settings
|
||||
else:
|
||||
log.info(
|
||||
"Writing default settings : " + json.dumps(self.default_settings) + " --> " + str(self.daemon_conf))
|
||||
f = open(self.daemon_conf, "w")
|
||||
f.write(json.dumps(self.default_settings))
|
||||
f.close()
|
||||
settings_dict = self.default_settings
|
||||
missing_settings = self.default_settings
|
||||
log.info("Writing default settings : " + json.dumps(self.default_settings) + " --> " + str(self.daemon_conf))
|
||||
self.session_settings = self.default_settings
|
||||
|
||||
self.session_settings = settings_dict
|
||||
if 'last_version' in missing_settings.keys():
|
||||
self.session_settings['last_version'] = None
|
||||
|
||||
if self.session_settings['last_version'] != self.default_settings['last_version']:
|
||||
self.session_settings['last_version'] = self.default_settings['last_version']
|
||||
|
||||
self.first_run_after_update = True
|
||||
log.info("First run after update")
|
||||
if lbrynet_version == '0.2.5':
|
||||
self.session_settings['startup_scripts'].append({'script_name': 'migrateto025', 'run_once': True})
|
||||
|
||||
f = open(self.daemon_conf, "w")
|
||||
f.write(json.dumps(self.session_settings))
|
||||
f.close()
|
||||
|
||||
self.run_on_startup = self.session_settings['run_on_startup']
|
||||
self.data_rate = self.session_settings['data_rate']
|
||||
@@ -280,7 +257,13 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
self.search_timeout = self.session_settings['search_timeout']
|
||||
self.download_timeout = self.session_settings['download_timeout']
|
||||
self.max_search_results = self.session_settings['max_search_results']
|
||||
self.wallet_type = self.session_settings['wallet_type']
|
||||
if self.session_settings['wallet_type'] in WALLET_TYPES and not wallet_type:
|
||||
self.wallet_type = self.session_settings['wallet_type']
|
||||
log.info("Using wallet type %s from config" % self.wallet_type)
|
||||
else:
|
||||
self.wallet_type = wallet_type
|
||||
self.session_settings['wallet_type'] = wallet_type
|
||||
log.info("Using wallet type %s specified from command line" % self.wallet_type)
|
||||
self.delete_blobs_on_remove = self.session_settings['delete_blobs_on_remove']
|
||||
self.peer_port = self.session_settings['peer_port']
|
||||
self.dht_node_port = self.session_settings['dht_node_port']
|
||||
@@ -288,6 +271,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
self.start_lbrycrdd = self.session_settings['start_lbrycrdd']
|
||||
self.requested_first_run_credits = self.session_settings['requested_first_run_credits']
|
||||
self.cache_time = self.session_settings['cache_time']
|
||||
self.startup_scripts = self.session_settings['startup_scripts']
|
||||
|
||||
if os.path.isfile(os.path.join(self.db_dir, "stream_info_cache.json")):
|
||||
f = open(os.path.join(self.db_dir, "stream_info_cache.json"), "r")
|
||||
@@ -297,6 +281,51 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
else:
|
||||
self.name_cache = {}
|
||||
|
||||
if os.name == "nt":
|
||||
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
|
||||
self.lbrycrdd_path = "lbrycrdd.exe"
|
||||
if self.wallet_type == "lbrycrd":
|
||||
self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbrycrd")
|
||||
else:
|
||||
self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbryum")
|
||||
elif sys.platform == "darwin":
|
||||
self.lbrycrdd_path = "./lbrycrdd"
|
||||
if self.wallet_type == "lbrycrd":
|
||||
self.wallet_dir = user_data_dir("lbrycrd")
|
||||
else:
|
||||
self.wallet_dir = user_data_dir("LBRY")
|
||||
else:
|
||||
self.lbrycrdd_path = "./lbrycrdd"
|
||||
if self.wallet_type == "lbrycrd":
|
||||
self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
|
||||
else:
|
||||
self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbryum")
|
||||
|
||||
self.created_data_dir = False
|
||||
if not os.path.exists(self.db_dir):
|
||||
os.mkdir(self.db_dir)
|
||||
self.created_data_dir = True
|
||||
|
||||
self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
|
||||
self.lbrycrd_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
|
||||
self.autofetcher_conf = os.path.join(self.wallet_dir, "autofetcher.conf")
|
||||
self.wallet_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
|
||||
self.wallet_user = None
|
||||
self.wallet_password = None
|
||||
|
||||
self.internet_connection_checker = LoopingCall(self._check_network_connection)
|
||||
self.version_checker = LoopingCall(self._check_remote_versions)
|
||||
self.connection_problem_checker = LoopingCall(self._check_connection_problems)
|
||||
# self.lbrynet_connection_checker = LoopingCall(self._check_lbrynet_connection)
|
||||
|
||||
self.sd_identifier = StreamDescriptorIdentifier()
|
||||
self.stream_info_manager = TempLBRYFileMetadataManager()
|
||||
self.settings = LBRYSettings(self.db_dir)
|
||||
self.lbry_ui_manager = LBRYUIManager(root)
|
||||
self.blob_request_payment_rate_manager = None
|
||||
self.lbry_file_metadata_manager = None
|
||||
self.lbry_file_manager = None
|
||||
|
||||
def render(self, request):
|
||||
request.content.seek(0, 0)
|
||||
# Unmarshal the JSON-RPC data.
|
||||
@@ -322,6 +351,9 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
if functionPath not in ALLOWED_DURING_STARTUP:
|
||||
return server.failure
|
||||
|
||||
if self.wallet_type == "lbryum" and functionPath in ['set_miner', 'get_miner_status']:
|
||||
return server.failure
|
||||
|
||||
try:
|
||||
function = self._getFunction(functionPath)
|
||||
except jsonrpclib.Fault, f:
|
||||
@@ -363,7 +395,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
log.error(failure)
|
||||
return jsonrpclib.Fault(self.FAILURE, "error")
|
||||
|
||||
def setup(self):
|
||||
def setup(self, branch=DEFAULT_UI_BRANCH, user_specified=False, branch_specified=False):
|
||||
def _log_starting_vals():
|
||||
d = self._get_lbry_files()
|
||||
d.addCallback(lambda r: json.dumps([d[1] for d in r]))
|
||||
@@ -372,22 +404,35 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
return d
|
||||
|
||||
def _announce_startup():
|
||||
def _wait_for_credits():
|
||||
if float(self.session.wallet.wallet_balance) == 0.0:
|
||||
self.startup_status = STARTUP_STAGES[6]
|
||||
return reactor.callLater(1, _wait_for_credits)
|
||||
else:
|
||||
return _announce()
|
||||
|
||||
def _announce():
|
||||
self.announced_startup = True
|
||||
self.startup_status = STARTUP_STAGES[5]
|
||||
log.info("[" + str(datetime.now()) + "] Started lbrynet-daemon")
|
||||
if len(self.startup_scripts):
|
||||
log.info("Scheduling scripts")
|
||||
reactor.callLater(3, self._run_scripts)
|
||||
|
||||
# self.lbrynet_connection_checker.start(3600)
|
||||
|
||||
if self.first_run:
|
||||
d = self._upload_log(name_prefix="fr")
|
||||
d = self._upload_log(log_type="first_run")
|
||||
elif self.upload_log:
|
||||
d = self._upload_log(exclude_previous=True, log_type="start")
|
||||
else:
|
||||
d = self._upload_log(exclude_previous=True, name_prefix="start")
|
||||
d = defer.succeed(None)
|
||||
|
||||
if float(self.session.wallet.wallet_balance) == 0.0:
|
||||
d.addCallback(lambda _: self._check_first_run())
|
||||
d.addCallback(self._show_first_run_result)
|
||||
|
||||
d.addCallback(lambda _: _announce())
|
||||
d.addCallback(lambda _: _wait_for_credits() if self.requested_first_run_credits else _announce())
|
||||
return d
|
||||
|
||||
log.info("[" + str(datetime.now()) + "] Starting lbrynet-daemon")
|
||||
@@ -397,6 +442,9 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
self.connection_problem_checker.start(1)
|
||||
|
||||
d = defer.Deferred()
|
||||
d.addCallback(lambda _: self.lbry_ui_manager.setup(branch=branch,
|
||||
user_specified=user_specified,
|
||||
branch_specified=branch_specified))
|
||||
d.addCallback(lambda _: self._initial_setup())
|
||||
d.addCallback(lambda _: threads.deferToThread(self._setup_data_directory))
|
||||
d.addCallback(lambda _: self._check_db_migration())
|
||||
@@ -415,9 +463,29 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
|
||||
return defer.succeed(None)
|
||||
|
||||
def _get_platform(self):
|
||||
r = {
|
||||
"processor": platform.processor(),
|
||||
"python_version: ": platform.python_version(),
|
||||
"platform": platform.platform(),
|
||||
"os_release": platform.release(),
|
||||
"os_system": platform.system(),
|
||||
"lbrynet_version: ": lbrynet_version,
|
||||
"lbryum_version: ": lbryum_version,
|
||||
"ui_version": self.lbry_ui_manager.loaded_git_version,
|
||||
}
|
||||
if not self.ip:
|
||||
try:
|
||||
r['ip'] = json.load(urlopen('http://jsonip.com'))['ip']
|
||||
self.ip = r['ip']
|
||||
except:
|
||||
r['ip'] = "Could not determine"
|
||||
|
||||
return r
|
||||
|
||||
def _initial_setup(self):
|
||||
def _log_platform():
|
||||
log.info("Platform: " + json.dumps(self.platform_info))
|
||||
log.info("Platform: " + json.dumps(self._get_platform()))
|
||||
return defer.succeed(None)
|
||||
|
||||
d = _log_platform()
|
||||
@@ -505,10 +573,13 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
return defer.succeed(True)
|
||||
|
||||
def _stop_server(self):
|
||||
if self.lbry_server_port is not None:
|
||||
self.lbry_server_port, p = None, self.lbry_server_port
|
||||
return defer.maybeDeferred(p.stopListening)
|
||||
else:
|
||||
try:
|
||||
if self.lbry_server_port is not None:
|
||||
self.lbry_server_port, p = None, self.lbry_server_port
|
||||
return defer.maybeDeferred(p.stopListening)
|
||||
else:
|
||||
return defer.succeed(True)
|
||||
except AttributeError:
|
||||
return defer.succeed(True)
|
||||
|
||||
def _setup_server(self):
|
||||
@@ -561,28 +632,28 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
dl.addCallback(_set_query_handlers)
|
||||
return dl
|
||||
|
||||
def _upload_log(self, name_prefix=None, exclude_previous=False, force=False):
|
||||
if name_prefix:
|
||||
name_prefix = name_prefix + "-" + platform.system()
|
||||
else:
|
||||
name_prefix = platform.system()
|
||||
|
||||
def _upload_log(self, log_type=None, exclude_previous=False, force=False):
|
||||
if self.upload_log or force:
|
||||
LOG_URL = "https://lbry.io/log-upload"
|
||||
if exclude_previous:
|
||||
f = open(self.log_file, "r")
|
||||
f.seek(PREVIOUS_LOG)
|
||||
log_contents = f.read()
|
||||
f.close()
|
||||
else:
|
||||
f = open(self.log_file, "r")
|
||||
log_contents = f.read()
|
||||
f.close()
|
||||
t = datetime.now()
|
||||
log_name = name_prefix + "-" + base58.b58encode(self.lbryid)[:20] + "-" + str(t.month) + "-" + str(t.day) + "-" + str(t.year) + "-" + str(t.hour) + "-" + str(t.minute)
|
||||
params = {'name': log_name, 'log': log_contents}
|
||||
for lm, lp in [('lbrynet', lbrynet_log), ('lbryum', lbryum_log)]:
|
||||
if os.path.isfile(lp):
|
||||
if exclude_previous:
|
||||
f = open(lp, "r")
|
||||
f.seek(PREVIOUS_LBRYNET_LOG if lm == 'lbrynet' else PREVIOUS_LBRYUM_LOG)
|
||||
log_contents = f.read()
|
||||
f.close()
|
||||
else:
|
||||
f = open(lp, "r")
|
||||
log_contents = f.read()
|
||||
f.close()
|
||||
params = {
|
||||
'date': datetime.utcnow().strftime('%Y%m%d-%H%M%S'),
|
||||
'hash': base58.b58encode(self.lbryid)[:20],
|
||||
'sys': platform.system(),
|
||||
'type': "%s-%s" % (lm, log_type) if log_type else lm,
|
||||
'log': log_contents
|
||||
}
|
||||
requests.post(LOG_POST_URL, params)
|
||||
|
||||
requests.post(LOG_URL, params)
|
||||
return defer.succeed(None)
|
||||
else:
|
||||
return defer.succeed(None)
|
||||
@@ -590,13 +661,21 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
def _shutdown(self):
|
||||
log.info("Closing lbrynet session")
|
||||
log.info("Status at time of shutdown: " + self.startup_status[0])
|
||||
if self.internet_connection_checker.running:
|
||||
self.internet_connection_checker.stop()
|
||||
if self.version_checker.running:
|
||||
self.version_checker.stop()
|
||||
if self.connection_problem_checker.running:
|
||||
self.connection_problem_checker.stop()
|
||||
|
||||
d = self._upload_log(name_prefix="close", exclude_previous=False if self.first_run else True)
|
||||
d = self._upload_log(log_type="close", exclude_previous=False if self.first_run else True)
|
||||
d.addCallback(lambda _: self._stop_server())
|
||||
d.addErrback(lambda err: log.info("Bad server shutdown: " + err.getTraceback()))
|
||||
d.addErrback(lambda err: True)
|
||||
d.addCallback(lambda _: self.lbry_file_manager.stop())
|
||||
d.addErrback(lambda err: True)
|
||||
if self.session is not None:
|
||||
d.addCallback(lambda _: self.session.shut_down())
|
||||
d.addErrback(lambda err: log.info("Bad session shutdown: " + err.getTraceback()))
|
||||
d.addErrback(lambda err: True)
|
||||
return d
|
||||
|
||||
def _update_settings(self, settings):
|
||||
@@ -650,16 +729,22 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
elif k == 'download_timeout':
|
||||
if type(settings['download_timeout']) is int:
|
||||
self.session_settings['download_timeout'] = settings['download_timeout']
|
||||
elif type(settings['download_timeout']) is float:
|
||||
self.session_settings['download_timeout'] = int(settings['download_timeout'])
|
||||
else:
|
||||
return defer.fail()
|
||||
elif k == 'search_timeout':
|
||||
if type(settings['search_timeout']) is float:
|
||||
self.session_settings['search_timeout'] = settings['search_timeout']
|
||||
elif type(settings['search_timeout']) is int:
|
||||
self.session_settings['search_timeout'] = float(settings['search_timeout'])
|
||||
else:
|
||||
return defer.fail()
|
||||
elif k == 'cache_time':
|
||||
if type(settings['cache_time']) is int:
|
||||
self.session_settings['cache_time'] = settings['cache_time']
|
||||
elif type(settings['cache_time']) is float:
|
||||
self.session_settings['cache_time'] = int(settings['cache_time'])
|
||||
else:
|
||||
return defer.fail()
|
||||
self.run_on_startup = self.session_settings['run_on_startup']
|
||||
@@ -775,7 +860,8 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
log.info("Using PTC wallet")
|
||||
d = defer.succeed(PTCWallet(self.db_dir))
|
||||
else:
|
||||
d = defer.fail()
|
||||
log.info("Requested unknown wallet '%s', using default lbryum" % self.wallet_type)
|
||||
d = defer.succeed(LBRYumWallet(self.db_dir))
|
||||
|
||||
d.addCallback(lambda wallet: {"wallet": wallet})
|
||||
return d
|
||||
@@ -808,11 +894,19 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
def _set_first_run_false():
|
||||
log.info("Not first run")
|
||||
self.first_run = False
|
||||
self.session_settings['requested_first_run_credits'] = True
|
||||
f = open(self.daemon_conf, "w")
|
||||
f.write(json.dumps(self.session_settings))
|
||||
f.close()
|
||||
return 0.0
|
||||
|
||||
d = self.session.wallet.is_first_run()
|
||||
d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run or not self.requested_first_run_credits
|
||||
else _set_first_run_false())
|
||||
if self.wallet_type == 'lbryum':
|
||||
d = self.session.wallet.is_first_run()
|
||||
d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run or not self.requested_first_run_credits
|
||||
else _set_first_run_false())
|
||||
else:
|
||||
d = defer.succeed(None)
|
||||
d.addCallback(lambda _: _set_first_run_false())
|
||||
return d
|
||||
|
||||
def _do_first_run(self):
|
||||
@@ -821,6 +915,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
r = requests.post(url, json=data)
|
||||
if r.status_code == 200:
|
||||
self.requested_first_run_credits = True
|
||||
self.session_settings['requested_first_run_credits'] = True
|
||||
f = open(self.daemon_conf, "w")
|
||||
f.write(json.dumps(self.session_settings))
|
||||
f.close()
|
||||
@@ -889,7 +984,8 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, downloader_factory)
|
||||
return defer.succeed(True)
|
||||
|
||||
def _download_name(self, name, timeout=DEFAULT_TIMEOUT, download_directory=None, file_name=None, stream_info=None):
|
||||
def _download_name(self, name, timeout=DEFAULT_TIMEOUT, download_directory=None,
|
||||
file_name=None, stream_info=None, wait_for_write=True):
|
||||
"""
|
||||
Add a lbry file to the file manager, start the download, and return the new lbry file.
|
||||
If it already exists in the file manager, return the existing lbry file
|
||||
@@ -912,21 +1008,58 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
|
||||
d = self._get_lbry_file_by_sd_hash(stream_hash)
|
||||
def _add_results(l):
|
||||
return defer.succeed((stream_info, l))
|
||||
if l:
|
||||
if os.path.isfile(os.path.join(self.download_directory, l.file_name)):
|
||||
return defer.succeed((stream_info, l))
|
||||
return defer.succeed((stream_info, None))
|
||||
d.addCallback(_add_results)
|
||||
return d
|
||||
|
||||
def _wait_on_lbry_file(f):
|
||||
if os.path.isfile(os.path.join(self.download_directory, f.file_name)):
|
||||
written_file = file(os.path.join(self.download_directory, f.file_name))
|
||||
written_file.seek(0, os.SEEK_END)
|
||||
written_bytes = written_file.tell()
|
||||
written_file.close()
|
||||
else:
|
||||
written_bytes = False
|
||||
|
||||
if not written_bytes:
|
||||
d = defer.succeed(None)
|
||||
d.addCallback(lambda _: reactor.callLater(1, _wait_on_lbry_file, f))
|
||||
return d
|
||||
else:
|
||||
return defer.succeed(_disp_file(f))
|
||||
|
||||
def _disp_file(f):
|
||||
file_path = os.path.join(self.download_directory, f.file_name)
|
||||
log.info("[" + str(datetime.now()) + "] Already downloaded: " + str(f.sd_hash) + " --> " + file_path)
|
||||
return f
|
||||
|
||||
def _get_stream(stream_info):
|
||||
def _wait_for_write():
|
||||
if os.path.isfile(os.path.join(self.download_directory, self.streams[name].downloader.file_name)):
|
||||
written_file = file(os.path.join(self.download_directory, self.streams[name].downloader.file_name))
|
||||
written_file.seek(0, os.SEEK_END)
|
||||
written_bytes = written_file.tell()
|
||||
written_file.close()
|
||||
else:
|
||||
written_bytes = False
|
||||
|
||||
if not written_bytes:
|
||||
d = defer.succeed(None)
|
||||
d.addCallback(lambda _: reactor.callLater(1, _wait_for_write))
|
||||
return d
|
||||
else:
|
||||
return defer.succeed(None)
|
||||
|
||||
self.streams[name] = GetStream(self.sd_identifier, self.session, self.session.wallet,
|
||||
self.lbry_file_manager, max_key_fee=self.max_key_fee,
|
||||
data_rate=self.data_rate, timeout=timeout,
|
||||
download_directory=download_directory, file_name=file_name)
|
||||
d = self.streams[name].start(stream_info, name)
|
||||
if wait_for_write:
|
||||
d.addCallback(lambda _: _wait_for_write())
|
||||
d.addCallback(lambda _: self.streams[name].downloader)
|
||||
|
||||
return d
|
||||
@@ -937,10 +1070,9 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
else:
|
||||
d = defer.succeed(stream_info)
|
||||
d.addCallback(_setup_stream)
|
||||
d.addCallback(lambda (stream_info, lbry_file): _get_stream(stream_info) if not lbry_file else _disp_file(lbry_file))
|
||||
d.addCallback(lambda (stream_info, lbry_file): _get_stream(stream_info) if not lbry_file else _wait_on_lbry_file(lbry_file))
|
||||
if not stream_info:
|
||||
d.addCallback(_remove_from_wait)
|
||||
|
||||
return d
|
||||
|
||||
def _get_long_count_timestamp(self):
|
||||
@@ -952,19 +1084,31 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
f.close()
|
||||
return defer.succeed(True)
|
||||
|
||||
def _resolve_name(self, name):
|
||||
def _resolve_name(self, name, force_refresh=False):
|
||||
def _cache_stream_info(stream_info):
|
||||
def _add_txid(txid):
|
||||
self.name_cache[name]['txid'] = txid
|
||||
return defer.succeed(None)
|
||||
|
||||
self.name_cache[name] = {'claim_metadata': stream_info, 'timestamp': self._get_long_count_timestamp()}
|
||||
d = self._update_claim_cache()
|
||||
d = self.session.wallet.get_txid_for_name(name)
|
||||
d.addCallback(_add_txid)
|
||||
d.addCallback(lambda _: self._update_claim_cache())
|
||||
d.addCallback(lambda _: self.name_cache[name]['claim_metadata'])
|
||||
|
||||
return d
|
||||
|
||||
if name in self.name_cache.keys():
|
||||
if (self._get_long_count_timestamp() - self.name_cache[name]['timestamp']) < self.cache_time:
|
||||
log.info("[" + str(datetime.now()) + "] Returning cached stream info for lbry://" + name)
|
||||
d = defer.succeed(self.name_cache[name]['claim_metadata'])
|
||||
if not force_refresh:
|
||||
if name in self.name_cache.keys():
|
||||
if (self._get_long_count_timestamp() - self.name_cache[name]['timestamp']) < self.cache_time:
|
||||
log.info("[" + str(datetime.now()) + "] Returning cached stream info for lbry://" + name)
|
||||
d = defer.succeed(self.name_cache[name]['claim_metadata'])
|
||||
else:
|
||||
log.info("[" + str(datetime.now()) + "] Refreshing stream info for lbry://" + name)
|
||||
d = self.session.wallet.get_stream_info_for_name(name)
|
||||
d.addCallbacks(_cache_stream_info, lambda _: defer.fail(UnknownNameError))
|
||||
else:
|
||||
log.info("[" + str(datetime.now()) + "] Refreshing stream info for lbry://" + name)
|
||||
log.info("[" + str(datetime.now()) + "] Resolving stream info for lbry://" + name)
|
||||
d = self.session.wallet.get_stream_info_for_name(name)
|
||||
d.addCallbacks(_cache_stream_info, lambda _: defer.fail(UnknownNameError))
|
||||
else:
|
||||
@@ -974,7 +1118,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
|
||||
return d
|
||||
|
||||
def _delete_lbry_file(self, lbry_file):
|
||||
def _delete_lbry_file(self, lbry_file, delete_file=True):
|
||||
d = self.lbry_file_manager.delete_lbry_file(lbry_file)
|
||||
|
||||
def finish_deletion(lbry_file):
|
||||
@@ -987,7 +1131,8 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
d = self.lbry_file_manager.get_count_for_stream_hash(s_h)
|
||||
# TODO: could possibly be a timing issue here
|
||||
d.addCallback(lambda c: self.stream_info_manager.delete_stream(s_h) if c == 0 else True)
|
||||
d.addCallback(lambda _: os.remove(os.path.join(self.download_directory, lbry_file.file_name)) if
|
||||
if delete_file:
|
||||
d.addCallback(lambda _: os.remove(os.path.join(self.download_directory, lbry_file.file_name)) if
|
||||
os.path.isfile(os.path.join(self.download_directory, lbry_file.file_name)) else defer.succeed(None))
|
||||
return d
|
||||
|
||||
@@ -1095,27 +1240,49 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
if status[0] == DOWNLOAD_RUNNING_CODE:
|
||||
d = f.status()
|
||||
d.addCallback(_get_file_status)
|
||||
d.addCallback(lambda message: {'completed': f.completed, 'file_name': f.file_name, 'key': key,
|
||||
d.addCallback(lambda message: {'completed': f.completed, 'file_name': f.file_name,
|
||||
'download_directory': f.download_directory,
|
||||
'download_path': os.path.join(f.download_directory, f.file_name),
|
||||
'mime_type': mimetypes.guess_type(os.path.join(f.download_directory, f.file_name))[0],
|
||||
'key': key,
|
||||
'points_paid': f.points_paid, 'stopped': f.stopped,
|
||||
'stream_hash': f.stream_hash,
|
||||
'stream_name': f.stream_name,
|
||||
'suggested_file_name': f.suggested_file_name,
|
||||
'upload_allowed': f.upload_allowed, 'sd_hash': f.sd_hash,
|
||||
'lbry_uri': f.uri, 'txid': f.txid,
|
||||
'total_bytes': size,
|
||||
'written_bytes': written_bytes, 'code': status[0],
|
||||
'message': message})
|
||||
else:
|
||||
d = defer.succeed({'completed': f.completed, 'file_name': f.file_name, 'key': key,
|
||||
'download_directory': f.download_directory,
|
||||
'download_path': os.path.join(f.download_directory, f.file_name),
|
||||
'mime_type': mimetypes.guess_type(os.path.join(f.download_directory, f.file_name))[0],
|
||||
'points_paid': f.points_paid, 'stopped': f.stopped, 'stream_hash': f.stream_hash,
|
||||
'stream_name': f.stream_name, 'suggested_file_name': f.suggested_file_name,
|
||||
'upload_allowed': f.upload_allowed, 'sd_hash': f.sd_hash, 'total_bytes': size,
|
||||
'written_bytes': written_bytes, 'code': status[0], 'message': status[1]})
|
||||
'written_bytes': written_bytes, 'lbry_uri': f.uri, 'txid': f.txid,
|
||||
'code': status[0], 'message': status[1]})
|
||||
|
||||
return d
|
||||
|
||||
def _add_metadata(message):
|
||||
def _add_to_dict(metadata):
|
||||
message['metadata'] = metadata
|
||||
return defer.succeed(message)
|
||||
|
||||
if f.txid:
|
||||
d = self._resolve_name(f.uri)
|
||||
d.addCallback(_add_to_dict)
|
||||
else:
|
||||
d = defer.succeed(message)
|
||||
return d
|
||||
|
||||
if f:
|
||||
d = f.get_total_bytes()
|
||||
d.addCallback(_generate_reply)
|
||||
d.addCallback(_add_metadata)
|
||||
return d
|
||||
else:
|
||||
return False
|
||||
@@ -1141,6 +1308,30 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
requests.post(URL, json.dumps({"text": msg}))
|
||||
return defer.succeed(None)
|
||||
|
||||
def _run_scripts(self):
|
||||
if len([k for k in self.startup_scripts if 'run_once' in k.keys()]):
|
||||
log.info("Removing one time startup scripts")
|
||||
remaining_scripts = [s for s in self.startup_scripts if 'run_once' not in s.keys()]
|
||||
startup_scripts = self.startup_scripts
|
||||
self.startup_scripts = self.session_settings['startup_scripts'] = remaining_scripts
|
||||
|
||||
f = open(self.daemon_conf, "w")
|
||||
f.write(json.dumps(self.session_settings))
|
||||
f.close()
|
||||
|
||||
for script in startup_scripts:
|
||||
if script['script_name'] == 'migrateto025':
|
||||
log.info("Running migrator to 0.2.5")
|
||||
from lbrynet.lbrynet_daemon.daemon_scripts.migrateto025 import run as run_migrate
|
||||
run_migrate(self)
|
||||
|
||||
if script['script_name'] == 'Autofetcher':
|
||||
log.info("Starting autofetcher script")
|
||||
from lbrynet.lbrynet_daemon.daemon_scripts.Autofetcher import run as run_autofetcher
|
||||
run_autofetcher(self)
|
||||
|
||||
return defer.succeed(None)
|
||||
|
||||
def _render_response(self, result, code):
|
||||
return defer.succeed({'result': result, 'code': code})
|
||||
|
||||
@@ -1181,9 +1372,13 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
r['message'] = self.connection_problem[1]
|
||||
r['is_lagging'] = True
|
||||
elif self.startup_status[0] == LOADING_WALLET_CODE:
|
||||
if self.session.wallet.blocks_behind_alert != 0:
|
||||
r['message'] = r['message'] % (str(self.session.wallet.blocks_behind_alert) + " blocks behind")
|
||||
r['progress'] = self.session.wallet.catchup_progress
|
||||
if self.wallet_type == 'lbryum':
|
||||
if self.session.wallet.blocks_behind_alert != 0:
|
||||
r['message'] = r['message'] % (str(self.session.wallet.blocks_behind_alert) + " blocks behind")
|
||||
r['progress'] = self.session.wallet.catchup_progress
|
||||
else:
|
||||
r['message'] = "Catching up with the blockchain"
|
||||
r['progress'] = 0
|
||||
else:
|
||||
r['message'] = "Catching up with the blockchain"
|
||||
r['progress'] = 0
|
||||
@@ -1246,10 +1441,11 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
"remote_lbryum": most recent lbryum version available from github
|
||||
"""
|
||||
|
||||
platform_info = self._get_platform()
|
||||
msg = {
|
||||
'platform': self.platform_info['platform'],
|
||||
'os_release': self.platform_info['os_release'],
|
||||
'os_system': self.platform_info['os_system'],
|
||||
'platform': platform_info['platform'],
|
||||
'os_release': platform_info['os_release'],
|
||||
'os_system': platform_info['os_system'],
|
||||
'lbrynet_version': lbrynet_version,
|
||||
'lbryum_version': lbryum_version,
|
||||
'ui_version': self.ui_version,
|
||||
@@ -1309,6 +1505,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
log.info("[" + str(datetime.now()) + "] Set daemon settings to " + json.dumps(self.session_settings))
|
||||
|
||||
d = self._update_settings(p)
|
||||
d.addErrback(lambda err: log.info(err.getTraceback()))
|
||||
d.addCallback(lambda _: _log_settings_change())
|
||||
d.addCallback(lambda _: self._render_response(self.session_settings, OK_CODE))
|
||||
|
||||
@@ -1482,11 +1679,16 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
else:
|
||||
stream_info = None
|
||||
|
||||
if 'wait_for_write' in p.keys():
|
||||
wait_for_write = p['wait_for_write']
|
||||
else:
|
||||
wait_for_write = True
|
||||
|
||||
if 'name' in p.keys():
|
||||
name = p['name']
|
||||
if p['name'] not in self.waiting_on.keys():
|
||||
d = self._download_name(name=name, timeout=timeout, download_directory=download_directory,
|
||||
stream_info=stream_info, file_name=file_name)
|
||||
stream_info=stream_info, file_name=file_name, wait_for_write=wait_for_write)
|
||||
d.addCallback(lambda l: {'stream_hash': sd_hash,
|
||||
'path': os.path.join(self.download_directory, l.file_name)}
|
||||
if stream_info else
|
||||
@@ -1622,14 +1824,19 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
confirmation message
|
||||
"""
|
||||
|
||||
if 'delete_target_file' in p.keys():
|
||||
delete_file = p['delete_target_file']
|
||||
else:
|
||||
delete_file = True
|
||||
|
||||
def _delete_file(f):
|
||||
file_name = f.file_name
|
||||
d = self._delete_lbry_file(f)
|
||||
d = self._delete_lbry_file(f, delete_file=delete_file)
|
||||
d.addCallback(lambda _: "Deleted LBRY file" + file_name)
|
||||
return d
|
||||
|
||||
if p.keys()[0] in ['name', 'sd_hash', 'file_name']:
|
||||
search_type = p.keys()[0]
|
||||
if 'name' in p.keys() or 'sd_hash' in p.keys() or 'file_name' in p.keys():
|
||||
search_type = [k for k in p.keys() if k != 'delete_target_file'][0]
|
||||
d = self._get_lbry_file(search_type, p[search_type], return_json=False)
|
||||
d.addCallback(lambda l: _delete_file(l) if l else False)
|
||||
|
||||
@@ -1909,6 +2116,39 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
d.addCallback(lambda r: self._render_response(r, OK_CODE))
|
||||
return d
|
||||
|
||||
def jsonrpc_set_miner(self, p):
|
||||
"""
|
||||
Start of stop the miner, function only available when lbrycrd is set as the wallet
|
||||
|
||||
Args:
|
||||
run: True/False
|
||||
Returns:
|
||||
miner status, True/False
|
||||
"""
|
||||
|
||||
stat = p['run']
|
||||
if stat:
|
||||
d = self.session.wallet.start_miner()
|
||||
else:
|
||||
d = self.session.wallet.stop_miner()
|
||||
d.addCallback(lambda _: self.session.wallet.get_miner_status())
|
||||
d.addCallback(lambda r: self._render_response(r, OK_CODE))
|
||||
return d
|
||||
|
||||
def jsonrpc_get_miner_status(self):
|
||||
"""
|
||||
Get status of miner
|
||||
|
||||
Args:
|
||||
None
|
||||
Returns:
|
||||
True/False
|
||||
"""
|
||||
|
||||
d = self.session.wallet.get_miner_status()
|
||||
d.addCallback(lambda r: self._render_response(r, OK_CODE))
|
||||
return d
|
||||
|
||||
# def jsonrpc_update_name(self, metadata):
|
||||
# def _disp(x):
|
||||
# print x
|
||||
@@ -1929,25 +2169,19 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
#
|
||||
# return d
|
||||
|
||||
def jsonrpc_check_for_new_version(self):
|
||||
def jsonrpc_log(self, p):
|
||||
"""
|
||||
Checks local version against versions in __init__.py and version.py in the lbrynet and lbryum repos
|
||||
Log message
|
||||
|
||||
Args:
|
||||
None
|
||||
'message': message to be logged
|
||||
Returns:
|
||||
true/false, true meaning that there is a new version available
|
||||
True
|
||||
"""
|
||||
|
||||
def _check_version():
|
||||
if (lbrynet_version >= self.git_lbrynet_version) and (lbryum_version >= self.git_lbryum_version):
|
||||
log.info("[" + str(datetime.now()) + "] Up to date")
|
||||
return self._render_response(False, OK_CODE)
|
||||
else:
|
||||
log.info("[" + str(datetime.now()) + "] Updates available")
|
||||
return self._render_response(True, OK_CODE)
|
||||
|
||||
return _check_version()
|
||||
message = p['message']
|
||||
log.info("API client log request: %s" % message)
|
||||
return self._render_response(True, OK_CODE)
|
||||
|
||||
def jsonrpc_upload_log(self, p=None):
|
||||
"""
|
||||
@@ -1956,15 +2190,17 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
Args, optional:
|
||||
'name_prefix': prefix to indicate what is requesting the log upload
|
||||
'exclude_previous': true/false, whether or not to exclude previous sessions from upload, defaults on true
|
||||
Returns
|
||||
Returns:
|
||||
True
|
||||
"""
|
||||
|
||||
if p:
|
||||
if 'name_prefix' in p.keys():
|
||||
prefix = p['name_prefix'] + '_api'
|
||||
log_type = p['name_prefix'] + '_api'
|
||||
elif 'log_type' in p.keys():
|
||||
log_type = p['log_type'] + '_api'
|
||||
else:
|
||||
prefix = None
|
||||
log_type = None
|
||||
|
||||
if 'exclude_previous' in p.keys():
|
||||
exclude_previous = p['exclude_previous']
|
||||
@@ -1979,11 +2215,49 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
else:
|
||||
force = False
|
||||
else:
|
||||
prefix = "api"
|
||||
log_type = "api"
|
||||
exclude_previous = True
|
||||
|
||||
d = self._upload_log(name_prefix=prefix, exclude_previous=exclude_previous, force=force)
|
||||
d = self._upload_log(log_type=log_type, exclude_previous=exclude_previous, force=force)
|
||||
if 'message' in p.keys():
|
||||
d.addCallback(lambda _: self._log_to_slack(p['message']))
|
||||
d.addCallback(lambda _: self._render_response(True, OK_CODE))
|
||||
return d
|
||||
|
||||
def jsonrpc_configure_ui(self, p):
|
||||
"""
|
||||
Configure the UI being hosted
|
||||
|
||||
Args, optional:
|
||||
'branch': a branch name on lbryio/lbry-web-ui
|
||||
'path': path to a ui folder
|
||||
"""
|
||||
|
||||
if 'path' in p.keys():
|
||||
d = self.lbry_ui_manager.setup(user_specified=p['path'])
|
||||
elif 'branch' in p.keys():
|
||||
d = self.lbry_ui_manager.setup(branch=p['branch'])
|
||||
else:
|
||||
d = self.lbry_ui_manager.setup()
|
||||
d.addCallback(lambda r: self._render_response(r, OK_CODE))
|
||||
|
||||
return d
|
||||
|
||||
def jsonrpc_reveal(self, p):
|
||||
"""
|
||||
Open a folder in finder/file explorer
|
||||
|
||||
Args:
|
||||
'path': path to be selected in finder
|
||||
Returns:
|
||||
True, opens finder
|
||||
"""
|
||||
|
||||
path = p['path']
|
||||
if sys.platform == "darwin":
|
||||
d = threads.deferToThread(subprocess.Popen, ['open', '-R', path])
|
||||
else:
|
||||
d = threads.deferToThread(subprocess.Popen, ['xdg-open', '-R', path])
|
||||
|
||||
d.addCallback(lambda _: self._render_response(True, OK_CODE))
|
||||
return d
|
||||
@@ -6,15 +6,15 @@ import webbrowser
|
||||
import sys
|
||||
import socket
|
||||
import platform
|
||||
|
||||
from appdirs import user_data_dir
|
||||
|
||||
from twisted.web import server
|
||||
from twisted.internet import reactor, defer
|
||||
from jsonrpc.proxy import JSONRPCProxy
|
||||
|
||||
from lbrynet.lbrynet_daemon.LBRYDaemonServer import LBRYDaemonServer
|
||||
from lbrynet.conf import API_CONNECTION_STRING, API_INTERFACE, API_ADDRESS, API_PORT, DEFAULT_WALLET, UI_ADDRESS
|
||||
|
||||
from lbrynet.conf import API_CONNECTION_STRING, API_INTERFACE, API_ADDRESS, API_PORT, \
|
||||
DEFAULT_WALLET, UI_ADDRESS, DEFAULT_UI_BRANCH, LOG_FILE_NAME
|
||||
|
||||
if sys.platform != "darwin":
|
||||
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
||||
@@ -24,13 +24,12 @@ else:
|
||||
if not os.path.isdir(log_dir):
|
||||
os.mkdir(log_dir)
|
||||
|
||||
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
|
||||
lbrynet_log = os.path.join(log_dir, LOG_FILE_NAME)
|
||||
log = logging.getLogger(__name__)
|
||||
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=2097152, backupCount=5)
|
||||
handler = logging.handlers.RotatingFileHandler(lbrynet_log, maxBytes=2097152, backupCount=5)
|
||||
log.addHandler(handler)
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
|
||||
REMOTE_SERVER = "www.google.com"
|
||||
|
||||
|
||||
@@ -63,17 +62,16 @@ def start():
|
||||
parser.add_argument("--wallet",
|
||||
help="lbrycrd or lbryum, default lbryum",
|
||||
type=str,
|
||||
default=DEFAULT_WALLET)
|
||||
default='')
|
||||
parser.add_argument("--ui",
|
||||
help="path to custom UI folder",
|
||||
default=None)
|
||||
parser.add_argument("--branch",
|
||||
help="Branch of lbry-web-ui repo to use, defaults on master",
|
||||
default="master")
|
||||
help="Branch of lbry-web-ui repo to use, defaults on master")
|
||||
parser.add_argument('--no-launch', dest='launchui', action="store_false")
|
||||
parser.add_argument('--log-to-console', dest='logtoconsole', action="store_true")
|
||||
parser.add_argument('--quiet', dest='quiet', action="store_true")
|
||||
parser.set_defaults(launchui=True, logtoconsole=False, quiet=False)
|
||||
parser.set_defaults(branch=False, launchui=True, logtoconsole=False, quiet=False)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.logtoconsole:
|
||||
@@ -96,7 +94,7 @@ def start():
|
||||
|
||||
if not args.logtoconsole and not args.quiet:
|
||||
print "Starting lbrynet-daemon from command line"
|
||||
print "To view activity, view the log file here: " + LOG_FILENAME
|
||||
print "To view activity, view the log file here: " + lbrynet_log
|
||||
print "Web UI is available at http://%s:%i" % (API_INTERFACE, API_PORT)
|
||||
print "JSONRPC API is available at " + API_CONNECTION_STRING
|
||||
print "To quit press ctrl-c or call 'stop' via the API"
|
||||
@@ -104,7 +102,10 @@ def start():
|
||||
if test_internet_connection():
|
||||
lbry = LBRYDaemonServer()
|
||||
|
||||
d = lbry.start(branch=args.branch, user_specified=args.ui)
|
||||
d = lbry.start(branch=args.branch if args.branch else DEFAULT_UI_BRANCH,
|
||||
user_specified=args.ui,
|
||||
wallet=args.wallet,
|
||||
branch_specified=True if args.branch else False)
|
||||
if args.launchui:
|
||||
d.addCallback(lambda _: webbrowser.open(UI_ADDRESS))
|
||||
|
||||
|
||||
@@ -5,38 +5,28 @@ import json
|
||||
import sys
|
||||
import mimetypes
|
||||
|
||||
from StringIO import StringIO
|
||||
from zipfile import ZipFile
|
||||
from urllib import urlopen
|
||||
from datetime import datetime
|
||||
from appdirs import user_data_dir
|
||||
from twisted.web import server, static, resource
|
||||
from twisted.internet import defer, interfaces, error, reactor, task, threads
|
||||
from twisted.python.failure import Failure
|
||||
from txjsonrpc.web import jsonrpc
|
||||
|
||||
from zope.interface import implements
|
||||
|
||||
from lbrynet.lbrynet_daemon.LBRYDaemon import LBRYDaemon
|
||||
from lbrynet.conf import API_CONNECTION_STRING, API_ADDRESS, DEFAULT_WALLET, UI_ADDRESS
|
||||
from lbrynet.conf import API_CONNECTION_STRING, API_ADDRESS, DEFAULT_WALLET, UI_ADDRESS, DEFAULT_UI_BRANCH, LOG_FILE_NAME
|
||||
|
||||
|
||||
if sys.platform != "darwin":
|
||||
data_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
||||
else:
|
||||
data_dir = user_data_dir("LBRY")
|
||||
|
||||
if not os.path.isdir(data_dir):
|
||||
os.mkdir(data_dir)
|
||||
version_dir = os.path.join(data_dir, "ui_version_history")
|
||||
if not os.path.isdir(version_dir):
|
||||
os.mkdir(version_dir)
|
||||
|
||||
version_log = logging.getLogger("lbry_version")
|
||||
version_log.addHandler(logging.FileHandler(os.path.join(version_dir, "lbry_version.log")))
|
||||
version_log.setLevel(logging.INFO)
|
||||
lbrynet_log = os.path.join(data_dir, LOG_FILE_NAME)
|
||||
log = logging.getLogger(__name__)
|
||||
log.addHandler(logging.FileHandler(os.path.join(data_dir, 'lbrynet-daemon.log')))
|
||||
handler = logging.handlers.RotatingFileHandler(lbrynet_log, maxBytes=2097152, backupCount=5)
|
||||
log.addHandler(handler)
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
|
||||
@@ -149,22 +139,23 @@ class HostedLBRYFile(resource.Resource):
|
||||
self._producer = None
|
||||
resource.Resource.__init__(self)
|
||||
|
||||
def makeProducer(self, request, stream):
|
||||
def _save_producer(producer):
|
||||
self._producer = producer
|
||||
return defer.succeed(None)
|
||||
|
||||
range_header = request.getAllHeaders()['range'].replace('bytes=', '').split('-')
|
||||
start, stop = int(range_header[0]), range_header[1]
|
||||
log.info("[" + str(datetime.now()) + "] GET range %s-%s" % (start, stop))
|
||||
path = os.path.join(self._api.download_directory, stream.file_name)
|
||||
|
||||
d = stream.get_total_bytes()
|
||||
d.addCallback(lambda size: _save_producer(LBRYFileStreamer(request, path, start, stop, size)))
|
||||
d.addCallback(lambda _: request.registerProducer(self._producer, streaming=True))
|
||||
# request.notifyFinish().addCallback(lambda _: self._producer.stopProducing())
|
||||
request.notifyFinish().addErrback(self._responseFailed, d)
|
||||
return d
|
||||
# todo: fix LBRYFileStreamer and use it instead of static.File
|
||||
# def makeProducer(self, request, stream):
|
||||
# def _save_producer(producer):
|
||||
# self._producer = producer
|
||||
# return defer.succeed(None)
|
||||
#
|
||||
# range_header = request.getAllHeaders()['range'].replace('bytes=', '').split('-')
|
||||
# start, stop = int(range_header[0]), range_header[1]
|
||||
# log.info("[" + str(datetime.now()) + "] GET range %s-%s" % (start, stop))
|
||||
# path = os.path.join(self._api.download_directory, stream.file_name)
|
||||
#
|
||||
# d = stream.get_total_bytes()
|
||||
# d.addCallback(lambda size: _save_producer(LBRYFileStreamer(request, path, start, stop, size)))
|
||||
# d.addCallback(lambda _: request.registerProducer(self._producer, streaming=True))
|
||||
# # request.notifyFinish().addCallback(lambda _: self._producer.stopProducing())
|
||||
# request.notifyFinish().addErrback(self._responseFailed, d)
|
||||
# return d
|
||||
|
||||
def render_GET(self, request):
|
||||
if 'name' in request.args.keys():
|
||||
@@ -182,172 +173,22 @@ class HostedLBRYFile(resource.Resource):
|
||||
request.finish()
|
||||
return server.NOT_DONE_YET
|
||||
|
||||
def _responseFailed(self, err, call):
|
||||
call.addErrback(lambda err: err.trap(error.ConnectionDone))
|
||||
call.addErrback(lambda err: err.trap(defer.CancelledError))
|
||||
call.addErrback(lambda err: log.info("Error: " + str(err)))
|
||||
call.cancel()
|
||||
|
||||
|
||||
class MyLBRYFiles(resource.Resource):
|
||||
isLeaf = False
|
||||
|
||||
def __init__(self):
|
||||
resource.Resource.__init__(self)
|
||||
self.files_table = None
|
||||
|
||||
def delayed_render(self, request, result):
|
||||
request.write(result.encode('utf-8'))
|
||||
request.finish()
|
||||
|
||||
def render_GET(self, request):
|
||||
self.files_table = None
|
||||
api = jsonrpc.Proxy(API_CONNECTION_STRING)
|
||||
d = api.callRemote("get_lbry_files", {})
|
||||
d.addCallback(self._get_table)
|
||||
d.addCallback(lambda results: self.delayed_render(request, results))
|
||||
|
||||
return server.NOT_DONE_YET
|
||||
|
||||
def _get_table(self, files):
|
||||
if not self.files_table:
|
||||
self.files_table = r'<html><head><title>My LBRY files</title></head><body><table border="1">'
|
||||
self.files_table += r'<tr>'
|
||||
self.files_table += r'<td>Stream name</td>'
|
||||
self.files_table += r'<td>Completed</td>'
|
||||
self.files_table += r'<td>Toggle</td>'
|
||||
self.files_table += r'<td>Remove</td>'
|
||||
self.files_table += r'</tr>'
|
||||
return self._get_table(files)
|
||||
if not len(files):
|
||||
self.files_table += r'</table></body></html>'
|
||||
return self.files_table
|
||||
else:
|
||||
f = files.pop()
|
||||
self.files_table += r'<tr>'
|
||||
self.files_table += r'<td>%s</td>' % (f['stream_name'])
|
||||
self.files_table += r'<td>%s</td>' % (f['completed'])
|
||||
self.files_table += r'<td>Start</td>' if f['stopped'] else r'<td>Stop</td>'
|
||||
self.files_table += r'<td>Delete</td>'
|
||||
self.files_table += r'</tr>'
|
||||
return self._get_table(files)
|
||||
# def _responseFailed(self, err, call):
|
||||
# call.addErrback(lambda err: err.trap(error.ConnectionDone))
|
||||
# call.addErrback(lambda err: err.trap(defer.CancelledError))
|
||||
# call.addErrback(lambda err: log.info("Error: " + str(err)))
|
||||
# call.cancel()
|
||||
|
||||
|
||||
class LBRYDaemonServer(object):
|
||||
def __init__(self):
|
||||
self.data_dir = user_data_dir("LBRY")
|
||||
if not os.path.isdir(self.data_dir):
|
||||
os.mkdir(self.data_dir)
|
||||
self.version_dir = os.path.join(self.data_dir, "ui_version_history")
|
||||
if not os.path.isdir(self.version_dir):
|
||||
os.mkdir(self.version_dir)
|
||||
self.config = os.path.join(self.version_dir, "active.json")
|
||||
self.ui_dir = os.path.join(self.data_dir, "lbry-web-ui")
|
||||
self.git_version = None
|
||||
self._api = None
|
||||
self.root = None
|
||||
|
||||
if not os.path.isfile(os.path.join(self.config)):
|
||||
self.loaded_git_version = None
|
||||
else:
|
||||
try:
|
||||
f = open(self.config, "r")
|
||||
loaded_ui = json.loads(f.read())
|
||||
f.close()
|
||||
self.loaded_git_version = loaded_ui['commit']
|
||||
self.loaded_branch = loaded_ui['branch']
|
||||
version_log.info("[" + str(datetime.now()) + "] Last used " + self.loaded_branch + " commit " + str(self.loaded_git_version).replace("\n", ""))
|
||||
except:
|
||||
self.loaded_git_version = None
|
||||
self.loaded_branch = None
|
||||
|
||||
def setup(self, branch="master", user_specified=None):
|
||||
self.branch = branch
|
||||
if user_specified:
|
||||
if os.path.isdir(user_specified):
|
||||
log.info("Using user specified UI directory: " + str(user_specified))
|
||||
self.branch = "user-specified"
|
||||
self.loaded_git_version = "user-specified"
|
||||
self.ui_dir = user_specified
|
||||
return defer.succeed("user-specified")
|
||||
else:
|
||||
log.info("User specified UI directory doesn't exist, using " + branch)
|
||||
else:
|
||||
log.info("Using UI branch: " + branch)
|
||||
self._git_url = "https://api.github.com/repos/lbryio/lbry-web-ui/git/refs/heads/%s" % branch
|
||||
self._dist_url = "https://raw.githubusercontent.com/lbryio/lbry-web-ui/%s/dist.zip" % branch
|
||||
|
||||
d = self._up_to_date()
|
||||
d.addCallback(lambda r: self._download_ui() if not r else self.branch)
|
||||
return d
|
||||
|
||||
def _up_to_date(self):
|
||||
def _get_git_info():
|
||||
response = urlopen(self._git_url)
|
||||
data = json.loads(response.read())
|
||||
return defer.succeed(data['object']['sha'])
|
||||
|
||||
def _set_git(version):
|
||||
self.git_version = version
|
||||
version_log.info("[" + str(datetime.now()) + "] UI branch " + self.branch + " has a most recent commit of: " + str(self.git_version).replace("\n", ""))
|
||||
|
||||
if self.git_version == self.loaded_git_version and os.path.isdir(self.ui_dir):
|
||||
version_log.info("[" + str(datetime.now()) + "] local copy of " + self.branch + " is up to date")
|
||||
return defer.succeed(True)
|
||||
else:
|
||||
if self.git_version == self.loaded_git_version:
|
||||
version_log.info("[" + str(datetime.now()) + "] Can't find ui files, downloading them again")
|
||||
else:
|
||||
version_log.info("[" + str(datetime.now()) + "] local copy of " + self.branch + " branch is out of date, updating")
|
||||
f = open(self.config, "w")
|
||||
f.write(json.dumps({'commit': self.git_version,
|
||||
'time': str(datetime.now()),
|
||||
'branch': self.branch}))
|
||||
f.close()
|
||||
return defer.succeed(False)
|
||||
|
||||
d = _get_git_info()
|
||||
d.addCallback(_set_git)
|
||||
return d
|
||||
|
||||
def _download_ui(self):
|
||||
def _delete_ui_dir():
|
||||
if os.path.isdir(self.ui_dir):
|
||||
if self.loaded_git_version:
|
||||
version_log.info("[" + str(datetime.now()) + "] Removed ui files for commit " + str(self.loaded_git_version).replace("\n", ""))
|
||||
log.info("Removing out of date ui files")
|
||||
shutil.rmtree(self.ui_dir)
|
||||
return defer.succeed(None)
|
||||
|
||||
def _dl_ui():
|
||||
url = urlopen(self._dist_url)
|
||||
z = ZipFile(StringIO(url.read()))
|
||||
names = [i for i in z.namelist() if '.DS_exStore' not in i and '__MACOSX' not in i]
|
||||
z.extractall(self.ui_dir, members=names)
|
||||
version_log.info("[" + str(datetime.now()) + "] Updated branch " + self.branch + ": " + str(self.loaded_git_version).replace("\n", "") + " --> " + self.git_version.replace("\n", ""))
|
||||
log.info("Downloaded files for UI commit " + str(self.git_version).replace("\n", ""))
|
||||
self.loaded_git_version = self.git_version
|
||||
return self.branch
|
||||
|
||||
d = _delete_ui_dir()
|
||||
d.addCallback(lambda _: _dl_ui())
|
||||
return d
|
||||
|
||||
def _setup_server(self, ui_ver, wallet):
|
||||
self._api = LBRYDaemon(ui_ver, wallet_type=wallet)
|
||||
self.root = LBRYindex(self.ui_dir)
|
||||
self.root.putChild("css", static.File(os.path.join(self.ui_dir, "css")))
|
||||
self.root.putChild("font", static.File(os.path.join(self.ui_dir, "font")))
|
||||
self.root.putChild("img", static.File(os.path.join(self.ui_dir, "img")))
|
||||
self.root.putChild("js", static.File(os.path.join(self.ui_dir, "js")))
|
||||
def _setup_server(self, wallet):
|
||||
self.root = LBRYindex(os.path.join(os.path.join(data_dir, "lbry-ui"), "active"))
|
||||
self._api = LBRYDaemon(self.root, wallet_type=wallet)
|
||||
self.root.putChild("view", HostedLBRYFile(self._api))
|
||||
self.root.putChild("files", MyLBRYFiles())
|
||||
self.root.putChild(API_ADDRESS, self._api)
|
||||
return defer.succeed(True)
|
||||
|
||||
def start(self, branch="master", user_specified=False, wallet=DEFAULT_WALLET):
|
||||
d = self.setup(branch=branch, user_specified=user_specified)
|
||||
d.addCallback(lambda v: self._setup_server(v, wallet))
|
||||
d.addCallback(lambda _: self._api.setup())
|
||||
|
||||
def start(self, branch=DEFAULT_UI_BRANCH, user_specified=False, branch_specified=False, wallet=None):
|
||||
d = self._setup_server(wallet)
|
||||
d.addCallback(lambda _: self._api.setup(branch, user_specified, branch_specified))
|
||||
return d
|
||||
@@ -12,7 +12,7 @@ from lbrynet.core.Error import InvalidStreamInfoError, InsufficientFundsError
|
||||
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
||||
from lbrynet.core.StreamDescriptor import download_sd_blob
|
||||
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloaderFactory
|
||||
from lbrynet.conf import DEFAULT_TIMEOUT
|
||||
from lbrynet.conf import DEFAULT_TIMEOUT, LOG_FILE_NAME
|
||||
|
||||
INITIALIZING_CODE = 'initializing'
|
||||
DOWNLOAD_METADATA_CODE = 'downloading_metadata'
|
||||
@@ -35,13 +35,12 @@ else:
|
||||
if not os.path.isdir(log_dir):
|
||||
os.mkdir(log_dir)
|
||||
|
||||
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
|
||||
lbrynet_log = os.path.join(log_dir, LOG_FILE_NAME)
|
||||
log = logging.getLogger(__name__)
|
||||
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=2097152, backupCount=5)
|
||||
handler = logging.handlers.RotatingFileHandler(lbrynet_log, maxBytes=2097152, backupCount=5)
|
||||
log.addHandler(handler)
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
|
||||
class GetStream(object):
|
||||
def __init__(self, sd_identifier, session, wallet, lbry_file_manager, max_key_fee, pay_key=True, data_rate=0.5,
|
||||
timeout=DEFAULT_TIMEOUT, download_directory=None, file_name=None):
|
||||
|
||||
@@ -10,6 +10,7 @@ from lbrynet.lbryfilemanager.LBRYFileCreator import create_lbry_file
|
||||
from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob
|
||||
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
||||
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader
|
||||
from lbrynet.conf import LOG_FILE_NAME
|
||||
from twisted.internet import threads, defer
|
||||
|
||||
if sys.platform != "darwin":
|
||||
@@ -20,9 +21,9 @@ else:
|
||||
if not os.path.isdir(log_dir):
|
||||
os.mkdir(log_dir)
|
||||
|
||||
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
|
||||
lbrynet_log = os.path.join(log_dir, LOG_FILE_NAME)
|
||||
log = logging.getLogger(__name__)
|
||||
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=2097152, backupCount=5)
|
||||
handler = logging.handlers.RotatingFileHandler(lbrynet_log, maxBytes=2097152, backupCount=5)
|
||||
log.addHandler(handler)
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
import os
|
||||
import logging
|
||||
import shutil
|
||||
import sys
|
||||
import json
|
||||
|
||||
from urllib2 import urlopen
|
||||
from StringIO import StringIO
|
||||
from twisted.web import static
|
||||
from twisted.internet import defer
|
||||
from lbrynet.conf import DEFAULT_UI_BRANCH, LOG_FILE_NAME
|
||||
from lbrynet import __version__ as lbrynet_version
|
||||
from lbryum.version import ELECTRUM_VERSION as lbryum_version
|
||||
from zipfile import ZipFile
|
||||
from appdirs import user_data_dir
|
||||
|
||||
if sys.platform != "darwin":
|
||||
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
||||
else:
|
||||
log_dir = user_data_dir("LBRY")
|
||||
|
||||
if not os.path.isdir(log_dir):
|
||||
os.mkdir(log_dir)
|
||||
|
||||
lbrynet_log = os.path.join(log_dir, LOG_FILE_NAME)
|
||||
log = logging.getLogger(__name__)
|
||||
handler = logging.handlers.RotatingFileHandler(lbrynet_log, maxBytes=2097152, backupCount=5)
|
||||
log.addHandler(handler)
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
|
||||
class LBRYUIManager(object):
|
||||
def __init__(self, root):
|
||||
if sys.platform != "darwin":
|
||||
self.data_dir = os.path.join(os.path.expanduser("~"), '.lbrynet')
|
||||
else:
|
||||
self.data_dir = user_data_dir("LBRY")
|
||||
|
||||
self.ui_root = os.path.join(self.data_dir, "lbry-ui")
|
||||
self.active_dir = os.path.join(self.ui_root, "active")
|
||||
self.update_dir = os.path.join(self.ui_root, "update")
|
||||
|
||||
if not os.path.isdir(self.data_dir):
|
||||
os.mkdir(self.data_dir)
|
||||
if not os.path.isdir(self.ui_root):
|
||||
os.mkdir(self.ui_root)
|
||||
if not os.path.isdir(self.active_dir):
|
||||
os.mkdir(self.active_dir)
|
||||
if not os.path.isdir(self.update_dir):
|
||||
os.mkdir(self.update_dir)
|
||||
|
||||
self.config = os.path.join(self.ui_root, "active.json")
|
||||
self.update_requires = os.path.join(self.update_dir, "requirements.txt")
|
||||
self.requirements = {}
|
||||
self.ui_dir = self.active_dir
|
||||
self.git_version = None
|
||||
self.root = root
|
||||
|
||||
if not os.path.isfile(os.path.join(self.config)):
|
||||
self.loaded_git_version = None
|
||||
self.loaded_branch = None
|
||||
self.loaded_requirements = None
|
||||
else:
|
||||
try:
|
||||
f = open(self.config, "r")
|
||||
loaded_ui = json.loads(f.read())
|
||||
f.close()
|
||||
self.loaded_git_version = loaded_ui['commit']
|
||||
self.loaded_branch = loaded_ui['branch']
|
||||
self.loaded_requirements = loaded_ui['requirements']
|
||||
except:
|
||||
self.loaded_git_version = None
|
||||
self.loaded_branch = None
|
||||
self.loaded_requirements = None
|
||||
|
||||
def setup(self, branch=DEFAULT_UI_BRANCH, user_specified=None, branch_specified=False):
|
||||
self.branch = branch
|
||||
if user_specified:
|
||||
if os.path.isdir(user_specified):
|
||||
log.info("Checking user specified UI directory: " + str(user_specified))
|
||||
self.branch = "user-specified"
|
||||
self.loaded_git_version = "user-specified"
|
||||
d = self.migrate_ui(source=user_specified)
|
||||
d.addCallback(lambda _: self._load_ui())
|
||||
return d
|
||||
else:
|
||||
log.info("User specified UI directory doesn't exist, using " + branch)
|
||||
elif self.loaded_branch == "user-specified" and not branch_specified:
|
||||
log.info("Loading user provided UI")
|
||||
d = self._load_ui()
|
||||
return d
|
||||
else:
|
||||
log.info("Checking for updates for UI branch: " + branch)
|
||||
self._git_url = "https://api.github.com/repos/lbryio/lbry-web-ui/git/refs/heads/%s" % branch
|
||||
self._dist_url = "https://raw.githubusercontent.com/lbryio/lbry-web-ui/%s/dist.zip" % branch
|
||||
|
||||
d = self._up_to_date()
|
||||
d.addCallback(lambda r: self._download_ui() if not r else self._load_ui())
|
||||
return d
|
||||
|
||||
def _up_to_date(self):
|
||||
def _get_git_info():
|
||||
response = urlopen(self._git_url)
|
||||
data = json.loads(response.read())
|
||||
return defer.succeed(data['object']['sha'])
|
||||
|
||||
def _set_git(version):
|
||||
self.git_version = version.replace('\n', '')
|
||||
if self.git_version == self.loaded_git_version:
|
||||
log.info("UI is up to date")
|
||||
return defer.succeed(True)
|
||||
else:
|
||||
log.info("UI updates available, checking if installation meets requirements")
|
||||
return defer.succeed(False)
|
||||
|
||||
d = _get_git_info()
|
||||
d.addCallback(_set_git)
|
||||
return d
|
||||
|
||||
def migrate_ui(self, source=None):
|
||||
if not source:
|
||||
requires_file = self.update_requires
|
||||
source_dir = self.update_dir
|
||||
delete_source = True
|
||||
else:
|
||||
requires_file = os.path.join(source, "requirements.txt")
|
||||
source_dir = source
|
||||
delete_source = False
|
||||
|
||||
def _check_requirements():
|
||||
if not os.path.isfile(requires_file):
|
||||
log.info("No requirements.txt file, rejecting request to migrate this UI")
|
||||
return defer.succeed(False)
|
||||
|
||||
f = open(requires_file, "r")
|
||||
for requirement in [line for line in f.read().split('\n') if line]:
|
||||
t = requirement.split('=')
|
||||
if len(t) == 3:
|
||||
self.requirements[t[0]] = {'version': t[1], 'operator': '=='}
|
||||
elif t[0][-1] == ">":
|
||||
self.requirements[t[0][:-1]] = {'version': t[1], 'operator': '>='}
|
||||
elif t[0][-1] == "<":
|
||||
self.requirements[t[0][:-1]] = {'version': t[1], 'operator': '<='}
|
||||
f.close()
|
||||
passed_requirements = True
|
||||
for r in self.requirements:
|
||||
if r == 'lbrynet':
|
||||
c = lbrynet_version
|
||||
elif r == 'lbryum':
|
||||
c = lbryum_version
|
||||
else:
|
||||
c = None
|
||||
if c:
|
||||
if self.requirements[r]['operator'] == '==':
|
||||
if not self.requirements[r]['version'] == c:
|
||||
passed_requirements = False
|
||||
log.info("Local version %s of %s does not meet UI requirement for version %s" % (
|
||||
c, r, self.requirements[r]['version']))
|
||||
else:
|
||||
log.info("Local version of %s meets ui requirement" % r)
|
||||
if self.requirements[r]['operator'] == '>=':
|
||||
if not self.requirements[r]['version'] <= c:
|
||||
passed_requirements = False
|
||||
log.info("Local version %s of %s does not meet UI requirement for version %s" % (
|
||||
c, r, self.requirements[r]['version']))
|
||||
else:
|
||||
log.info("Local version of %s meets ui requirement" % r)
|
||||
if self.requirements[r]['operator'] == '<=':
|
||||
if not self.requirements[r]['version'] >= c:
|
||||
passed_requirements = False
|
||||
log.info("Local version %s of %s does not meet UI requirement for version %s" % (
|
||||
c, r, self.requirements[r]['version']))
|
||||
else:
|
||||
log.info("Local version of %s meets ui requirement" % r)
|
||||
return defer.succeed(passed_requirements)
|
||||
|
||||
def _disp_failure():
|
||||
log.info("Failed to satisfy requirements for branch '%s', update was not loaded" % self.branch)
|
||||
return defer.succeed(False)
|
||||
|
||||
def _do_migrate():
|
||||
if os.path.isdir(self.active_dir):
|
||||
shutil.rmtree(self.active_dir)
|
||||
shutil.copytree(source_dir, self.active_dir)
|
||||
if delete_source:
|
||||
shutil.rmtree(source_dir)
|
||||
|
||||
log.info("Loaded UI update")
|
||||
|
||||
f = open(self.config, "w")
|
||||
loaded_ui = {'commit': self.git_version, 'branch': self.branch, 'requirements': self.requirements}
|
||||
f.write(json.dumps(loaded_ui))
|
||||
f.close()
|
||||
|
||||
self.loaded_git_version = loaded_ui['commit']
|
||||
self.loaded_branch = loaded_ui['branch']
|
||||
self.loaded_requirements = loaded_ui['requirements']
|
||||
return defer.succeed(True)
|
||||
|
||||
d = _check_requirements()
|
||||
d.addCallback(lambda r: _do_migrate() if r else _disp_failure())
|
||||
return d
|
||||
|
||||
def _download_ui(self):
|
||||
def _delete_update_dir():
|
||||
if os.path.isdir(self.update_dir):
|
||||
shutil.rmtree(self.update_dir)
|
||||
return defer.succeed(None)
|
||||
|
||||
def _dl_ui():
|
||||
url = urlopen(self._dist_url)
|
||||
z = ZipFile(StringIO(url.read()))
|
||||
names = [i for i in z.namelist() if '.DS_exStore' not in i and '__MACOSX' not in i]
|
||||
z.extractall(self.update_dir, members=names)
|
||||
log.info("Downloaded files for UI commit " + str(self.git_version).replace("\n", ""))
|
||||
return self.branch
|
||||
|
||||
d = _delete_update_dir()
|
||||
d.addCallback(lambda _: _dl_ui())
|
||||
d.addCallback(lambda _: self.migrate_ui())
|
||||
d.addCallback(lambda _: self._load_ui())
|
||||
return d
|
||||
|
||||
def _load_ui(self):
|
||||
for d in [i[0] for i in os.walk(self.active_dir) if os.path.dirname(i[0]) == self.active_dir]:
|
||||
self.root.putChild(os.path.basename(d), static.File(d))
|
||||
return defer.succeed(True)
|
||||
@@ -0,0 +1,68 @@
|
||||
import json
|
||||
import logging.handlers
|
||||
import sys
|
||||
import os
|
||||
|
||||
from appdirs import user_data_dir
|
||||
from twisted.internet.task import LoopingCall
|
||||
from twisted.internet import reactor
|
||||
|
||||
|
||||
if sys.platform != "darwin":
|
||||
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
||||
else:
|
||||
log_dir = user_data_dir("LBRY")
|
||||
|
||||
if not os.path.isdir(log_dir):
|
||||
os.mkdir(log_dir)
|
||||
|
||||
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
|
||||
|
||||
if os.path.isfile(LOG_FILENAME):
|
||||
f = open(LOG_FILENAME, 'r')
|
||||
PREVIOUS_LOG = len(f.read())
|
||||
f.close()
|
||||
else:
|
||||
PREVIOUS_LOG = 0
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=2097152, backupCount=5)
|
||||
log.addHandler(handler)
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
|
||||
class Autofetcher(object):
|
||||
"""
|
||||
Download name claims as they occur
|
||||
"""
|
||||
|
||||
def __init__(self, api):
|
||||
self._api = api
|
||||
self._checker = LoopingCall(self._check_for_new_claims)
|
||||
self.best_block = None
|
||||
|
||||
def start(self):
|
||||
reactor.addSystemEventTrigger('before', 'shutdown', self.stop)
|
||||
self._checker.start(5)
|
||||
|
||||
def stop(self):
|
||||
log.info("Stopping autofetcher")
|
||||
self._checker.stop()
|
||||
|
||||
def _check_for_new_claims(self):
|
||||
block = self._api.get_best_blockhash()
|
||||
if block != self.best_block:
|
||||
log.info("Checking new block for name claims, block hash: %s" % block)
|
||||
self.best_block = block
|
||||
transactions = self._api.get_block({'blockhash': block})['tx']
|
||||
for t in transactions:
|
||||
c = self._api.get_claims_for_tx({'txid': t})
|
||||
if len(c):
|
||||
for i in c:
|
||||
log.info("Downloading stream for claim txid: %s" % t)
|
||||
self._api.get({'name': t, 'stream_info': json.loads(i['value'])})
|
||||
|
||||
|
||||
def run(api):
|
||||
fetcher = Autofetcher(api)
|
||||
fetcher.start()
|
||||
Whitespace-only changes.
@@ -0,0 +1,32 @@
|
||||
from twisted.internet import defer
|
||||
|
||||
|
||||
class migrator(object):
|
||||
"""
|
||||
Re-resolve lbry names to write missing data to blockchain.db and to cache the nametrie
|
||||
"""
|
||||
|
||||
def __init__(self, api):
|
||||
self._api = api
|
||||
|
||||
def start(self):
|
||||
def _resolve_claims(claimtrie):
|
||||
claims = [i for i in claimtrie if 'txid' in i.keys()]
|
||||
r = defer.DeferredList([self._api._resolve_name(claim['name'], force_refresh=True) for claim in claims], consumeErrors=True)
|
||||
return r
|
||||
|
||||
def _restart_lbry_files():
|
||||
def _restart_lbry_file(lbry_file):
|
||||
return lbry_file.restore()
|
||||
|
||||
r = defer.DeferredList([_restart_lbry_file(lbry_file) for lbry_file in self._api.lbry_file_manager.lbry_files if not lbry_file.txid], consumeErrors=True)
|
||||
return r
|
||||
|
||||
d = self._api.session.wallet.get_nametrie()
|
||||
d.addCallback(_resolve_claims)
|
||||
d.addCallback(lambda _: _restart_lbry_files())
|
||||
|
||||
|
||||
def run(api):
|
||||
refresher = migrator(api)
|
||||
refresher.start()
|
||||
@@ -176,10 +176,10 @@ class DownloaderApp(object):
|
||||
style="Stop.TButton", cursor=button_cursor)
|
||||
self.wallet_menu_button.grid(row=0, column=1, padx=(5, 0))
|
||||
|
||||
def popup(event):
|
||||
def popup_wallet(event):
|
||||
self.wallet_menu.tk_popup(event.x_root, event.y_root)
|
||||
|
||||
self.wallet_menu_button.bind("<Button-1>", popup)
|
||||
self.wallet_menu_button.bind("<Button-1>", popup_wallet)
|
||||
|
||||
self.uri_frame = ttk.Frame(self.frame, style="B.TFrame")
|
||||
self.uri_frame.grid()
|
||||
@@ -204,7 +204,7 @@ class DownloaderApp(object):
|
||||
def paste_command():
|
||||
self.uri_entry.event_generate('<Control-v>')
|
||||
|
||||
def popup(event):
|
||||
def popup_uri(event):
|
||||
selection_menu = tk.Menu(
|
||||
self.master, tearoff=0
|
||||
)
|
||||
@@ -214,7 +214,7 @@ class DownloaderApp(object):
|
||||
selection_menu.add_command(label=" Paste ", command=paste_command)
|
||||
selection_menu.tk_popup(event.x_root, event.y_root)
|
||||
|
||||
self.uri_entry.bind("<Button-3>", popup)
|
||||
self.uri_entry.bind("<Button-3>", popup_uri)
|
||||
|
||||
self.uri_button = ttk.Button(
|
||||
self.uri_frame, text="Go", command=self._open_stream,
|
||||
@@ -349,4 +349,4 @@ class AddressWindow(object):
|
||||
window, text="OK", command=window.destroy, style="LBRY.TButton"
|
||||
)
|
||||
done_button.grid(row=1, column=1, pady=(0, 5), padx=5, sticky=tk.W)
|
||||
window.focus_set()
|
||||
window.focus_set()
|
||||
@@ -118,7 +118,7 @@ class StreamFrame(object):
|
||||
|
||||
def cancel(self):
|
||||
if self.cancel_func is not None:
|
||||
self.cancel_func()
|
||||
self.cancel_func() # pylint: disable=not-callable
|
||||
self.stream_frame.destroy()
|
||||
self.app.stream_removed()
|
||||
|
||||
@@ -460,4 +460,4 @@ class StreamFrame(object):
|
||||
if self.cost_label is not None and self.cost_label.winfo_exists():
|
||||
self.cost_label.config(text=locale.format_string("%.2f LBC",
|
||||
(round(total_points_paid, 2),),
|
||||
grouping=True))
|
||||
grouping=True))
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 19 KiB |
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# http://stackoverflow.com/a/246128
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# adapted from https://www.objc.io/issues/6-build-tools/travis-ci/#add-scripts
|
||||
|
||||
KEYCHAIN_PASSWORD=travis
|
||||
|
||||
# Create a custom keychain
|
||||
security create-keychain -p ${KEYCHAIN_PASSWORD} osx-build.keychain
|
||||
|
||||
# Make the custom keychain default, so xcodebuild will use it for signing
|
||||
security default-keychain -s osx-build.keychain
|
||||
|
||||
# Unlock the keychain
|
||||
security unlock-keychain -p ${KEYCHAIN_PASSWORD} osx-build.keychain
|
||||
|
||||
# Set keychain timeout to 1 hour for long builds
|
||||
# see http://www.egeek.me/2013/02/23/jenkins-and-xcode-user-interaction-is-not-allowed/
|
||||
security set-keychain-settings -t 3600 -l ~/Library/Keychains/osx-build.keychain
|
||||
|
||||
# Add certificates to keychain and allow codesign to access them
|
||||
security import ${DIR}/certs/dist.cer -k ~/Library/Keychains/osx-build.keychain -T /usr/bin/codesign
|
||||
security import ${DIR}/certs/dist.p12 -k ~/Library/Keychains/osx-build.keychain -P $KEY_PASSWORD -T /usr/bin/codesign
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
dist.cer
|
||||
dist.p12
|
||||
@@ -0,0 +1,30 @@
|
||||
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
|
||||
wHO80TEZVEqyfOeJTST/jA==
|
||||
@@ -0,0 +1,67 @@
|
||||
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
|
||||
EjIMJeXgdGFW7PEdY/kROQ==
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
*.pyc
|
||||
|
||||
*.pyo
|
||||
|
||||
*.so
|
||||
|
||||
*.xml
|
||||
|
||||
*.iml
|
||||
|
||||
id.conf
|
||||
Binary file not shown.
File renamed without changes.
@@ -0,0 +1,77 @@
|
||||
import AppKit
|
||||
import webbrowser
|
||||
import sys
|
||||
import logging
|
||||
import socket
|
||||
import platform
|
||||
|
||||
from PyObjCTools import AppHelper
|
||||
|
||||
from twisted.internet import reactor
|
||||
from twisted.web import server
|
||||
|
||||
from lbrynet.lbrynet_daemon.LBRYDaemonServer import LBRYDaemonServer
|
||||
from lbrynet.conf import API_PORT, API_INTERFACE, ICON_PATH, APP_NAME
|
||||
from lbrynet.conf import UI_ADDRESS
|
||||
|
||||
if platform.mac_ver()[0] >= "10.10":
|
||||
from LBRYNotify import LBRYNotify
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
REMOTE_SERVER = "www.google.com"
|
||||
|
||||
|
||||
def test_internet_connection():
|
||||
try:
|
||||
host = socket.gethostbyname(REMOTE_SERVER)
|
||||
s = socket.create_connection((host, 80), 2)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
class LBRYDaemonApp(AppKit.NSApplication):
|
||||
def finishLaunching(self):
|
||||
self.connection = False
|
||||
statusbar = AppKit.NSStatusBar.systemStatusBar()
|
||||
self.statusitem = statusbar.statusItemWithLength_(AppKit.NSVariableStatusItemLength)
|
||||
self.icon = AppKit.NSImage.alloc().initByReferencingFile_(ICON_PATH)
|
||||
self.icon.setScalesWhenResized_(True)
|
||||
self.icon.setSize_((20, 20))
|
||||
self.statusitem.setImage_(self.icon)
|
||||
self.menubarMenu = AppKit.NSMenu.alloc().init()
|
||||
self.open = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Open", "openui:", "")
|
||||
self.menubarMenu.addItem_(self.open)
|
||||
self.quit = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Quit", "replyToApplicationShouldTerminate:", "")
|
||||
self.menubarMenu.addItem_(self.quit)
|
||||
self.statusitem.setMenu_(self.menubarMenu)
|
||||
self.statusitem.setToolTip_(APP_NAME)
|
||||
|
||||
|
||||
if test_internet_connection():
|
||||
if platform.mac_ver()[0] >= "10.10":
|
||||
LBRYNotify("Starting LBRY")
|
||||
else:
|
||||
if platform.mac_ver()[0] >= "10.10":
|
||||
LBRYNotify("LBRY needs an internet connection to start, try again when one is available")
|
||||
sys.exit(0)
|
||||
|
||||
# if not subprocess.check_output("git ls-remote https://github.com/lbryio/lbry-web-ui.git | grep HEAD | cut -f 1",
|
||||
# shell=True):
|
||||
# LBRYNotify(
|
||||
# "You should have been prompted to install xcode command line tools, please do so and then start LBRY")
|
||||
# sys.exit(0)
|
||||
|
||||
lbry = LBRYDaemonServer()
|
||||
d = lbry.start()
|
||||
d.addCallback(lambda _: webbrowser.open(UI_ADDRESS))
|
||||
reactor.listenTCP(API_PORT, server.Site(lbry.root), interface=API_INTERFACE)
|
||||
|
||||
def openui_(self, sender):
|
||||
webbrowser.open(UI_ADDRESS)
|
||||
|
||||
def replyToApplicationShouldTerminate_(self, shouldTerminate):
|
||||
if platform.mac_ver()[0] >= "10.10":
|
||||
LBRYNotify("Goodbye!")
|
||||
reactor.stop()
|
||||
@@ -0,0 +1,27 @@
|
||||
import Foundation
|
||||
import objc
|
||||
import AppKit
|
||||
|
||||
NSUserNotification = objc.lookUpClass('NSUserNotification')
|
||||
NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
|
||||
|
||||
def LBRYNotify(message):
|
||||
notification = NSUserNotification.alloc().init()
|
||||
notification.setTitle_("LBRY")
|
||||
notification.setSubtitle_("")
|
||||
notification.setInformativeText_(message)
|
||||
notification.setUserInfo_({})
|
||||
notification.setSoundName_("NSUserNotificationDefaultSoundName")
|
||||
notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(0, Foundation.NSDate.date()))
|
||||
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
|
||||
|
||||
def notify(title, subtitle, info_text, delay=0, sound=False, userInfo={}):
|
||||
notification = NSUserNotification.alloc().init()
|
||||
notification.setTitle_(title)
|
||||
notification.setSubtitle_(subtitle)
|
||||
notification.setInformativeText_(info_text)
|
||||
notification.setUserInfo_(userInfo)
|
||||
if sound:
|
||||
notification.setSoundName_("NSUserNotificationDefaultSoundName")
|
||||
notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(delay, Foundation.NSDate.date()))
|
||||
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
|
||||
Whitespace-only changes.
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
from PyObjCTools import AppHelper
|
||||
from twisted.internet.cfreactor import install
|
||||
install(runner=AppHelper.runEventLoop)
|
||||
from twisted.internet import reactor
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
from appdirs import user_data_dir
|
||||
|
||||
from LBRYApp import LBRYDaemonApp
|
||||
|
||||
if sys.platform != "darwin":
|
||||
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
||||
else:
|
||||
log_dir = user_data_dir("LBRY")
|
||||
|
||||
if not os.path.isdir(log_dir):
|
||||
os.mkdir(log_dir)
|
||||
|
||||
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=2097152, backupCount=5)
|
||||
log.addHandler(handler)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def main():
|
||||
app = LBRYDaemonApp.sharedApplication()
|
||||
reactor.addSystemEventTrigger("after", "shutdown", AppHelper.stopEventLoop)
|
||||
reactor.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
from setuptools import setup
|
||||
from lbrynet.conf import PROTOCOL_PREFIX, APP_NAME, ICON_PATH
|
||||
import sys
|
||||
|
||||
APP = [os.path.join('lbrygui', 'main.py')]
|
||||
DATA_FILES = []
|
||||
DATA_FILES.append('app.icns')
|
||||
|
||||
OPTIONS = {
|
||||
'iconfile': ICON_PATH,
|
||||
'plist': {
|
||||
'CFBundleIdentifier': 'io.lbry.LBRY',
|
||||
'LSUIElement': True,
|
||||
},
|
||||
'packages': [
|
||||
'lbrynet', 'lbryum', 'requests', 'unqlite', 'certifi',
|
||||
'pkg_resources', 'json', 'jsonrpc', 'seccure',
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
setup(
|
||||
name=APP_NAME,
|
||||
app=APP,
|
||||
options={'py2app': OPTIONS},
|
||||
data_files=DATA_FILES,
|
||||
)
|
||||
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
set -o xtrace
|
||||
|
||||
DEST=`pwd`
|
||||
tmp="${DEST}/build"
|
||||
|
||||
rm -rf build dist LBRY.app
|
||||
|
||||
# the default py2app (v0.9) has a bug that is fixed in the head of /metachris/py2app
|
||||
pip install git+https://github.com/metachris/py2app
|
||||
pip install jsonrpc
|
||||
|
||||
mkdir -p $tmp
|
||||
cd $tmp
|
||||
|
||||
echo "Updating lbrynet"
|
||||
if [ -z ${TRAVIS_BUILD_DIR+x} ]; then
|
||||
# building locally
|
||||
git clone --depth 1 http://github.com/lbryio/lbry.git
|
||||
cd lbry
|
||||
LBRY="${tmp}/lbry"
|
||||
else
|
||||
# building on travis
|
||||
cd ${TRAVIS_BUILD_DIR}
|
||||
LBRY=${TRAVIS_BUILD_DIR}
|
||||
fi
|
||||
NAME=`python setup.py --name`
|
||||
VERSION=`python setup.py -V`
|
||||
pip install -r requirements.txt
|
||||
# not totally sure if pyOpenSSl is needed (JIE)
|
||||
pip install pyOpenSSL
|
||||
python setup.py install
|
||||
|
||||
echo "Building URI Handler"
|
||||
cd "${DEST}"
|
||||
rm -rf build dist
|
||||
python setup_uri_handler.py py2app
|
||||
|
||||
echo "Signing URI Handler"
|
||||
codesign -s "${LBRY_DEVELOPER_ID}" -f "${DEST}/dist/LBRYURIHandler.app/Contents/Frameworks/Python.framework/Versions/2.7"
|
||||
codesign -s "${LBRY_DEVELOPER_ID}" -f "${DEST}/dist/LBRYURIHandler.app/Contents/MacOS/python"
|
||||
# not sure if --deep is appropriate here, but need to get LBRYURIHandler.app/Contents/Frameworks/libcrypto.1.0.0.dylib signed
|
||||
codesign --deep -s "${LBRY_DEVELOPER_ID}" -f "${DEST}/dist/LBRYURIHandler.app/Contents/MacOS/LBRYURIHandler"
|
||||
codesign -vvvv "${DEST}/dist/LBRYURIHandler.app"
|
||||
|
||||
pip install certifi pyobjc-core pyobjc-framework-Cocoa pyobjc-framework-CFNetwork
|
||||
python setup_app.py py2app
|
||||
|
||||
echo "Removing i386 libraries"
|
||||
|
||||
remove_arch () {
|
||||
if [[ `lipo "$2" -verify_arch "$1"` ]]; then
|
||||
lipo -output build/lipo.tmp -remove "$1" "$2" && mv build/lipo.tmp "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
for i in `find dist/LBRY.app/Contents/Resources/lib/python2.7/lib-dynload/ -name "*.so"`; do
|
||||
remove_arch i386 $i
|
||||
done
|
||||
|
||||
|
||||
echo "Moving LBRYURIHandler.app into LBRY.app"
|
||||
mv "${DEST}/dist/LBRYURIHandler.app" "${DEST}/dist/LBRY.app/Contents/Resources"
|
||||
|
||||
echo "Signing LBRY.app"
|
||||
codesign -s "${LBRY_DEVELOPER_ID}" -f "${DEST}/dist/LBRY.app/Contents/Frameworks/Python.framework/Versions/2.7"
|
||||
codesign -s "${LBRY_DEVELOPER_ID}" -f "${DEST}/dist/LBRY.app/Contents/Frameworks/libgmp.10.dylib"
|
||||
codesign -s "${LBRY_DEVELOPER_ID}" -f "${DEST}/dist/LBRY.app/Contents/MacOS/python"
|
||||
# adding deep here as well because of subcomponent issues
|
||||
codesign --deep -s "${LBRY_DEVELOPER_ID}" -f "${DEST}/dist/LBRY.app/Contents/MacOS/LBRY"
|
||||
codesign -vvvv "${DEST}/dist/LBRY.app"
|
||||
|
||||
rm -rf $tmp
|
||||
mv dist/LBRY.app LBRY.app
|
||||
rm -rf dist
|
||||
hdiutil create "${NAME}.${VERSION}.dmg" -volname lbry -srcfolder LBRY.app
|
||||
@@ -1,7 +1,7 @@
|
||||
from setuptools import setup
|
||||
import os
|
||||
|
||||
APP = [os.path.join('lbrynet', 'lbrynet_daemon', 'Apps', 'LBRYURIHandler.py')]
|
||||
APP = [os.path.join('lbry_uri_handler', 'LBRYURIHandler.py')]
|
||||
DATA_FILES = []
|
||||
OPTIONS = {'argv_emulation': True,
|
||||
'packages': ['jsonrpc'],
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script is used by travis to install lbry from source
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
set -o xtrace
|
||||
|
||||
SUDO=''
|
||||
if (( $EUID != 0 )); then
|
||||
SUDO='sudo'
|
||||
fi
|
||||
|
||||
if [ -z ${TRAVIS+x} ]; then
|
||||
# if not on travis, its nice to see progress
|
||||
QUIET=""
|
||||
else
|
||||
QUIET="-qq"
|
||||
fi
|
||||
|
||||
# get the required OS packages
|
||||
$SUDO apt-get ${QUIET} update
|
||||
$SUDO apt-get ${QUIET} install -y --no-install-recommends \
|
||||
build-essential python-dev libffi-dev libssl-dev git \
|
||||
libgmp3-dev wget ca-certificates python-virtualenv
|
||||
|
||||
# create a virtualenv so we don't muck with anything on the system
|
||||
virtualenv venv
|
||||
# need to unset these or else we can't activate
|
||||
set +eu
|
||||
source venv/bin/activate
|
||||
set -eu
|
||||
|
||||
# need a modern version of pip (more modern than ubuntu default)
|
||||
wget https://bootstrap.pypa.io/get-pip.py
|
||||
python get-pip.py
|
||||
rm get-pip.py
|
||||
|
||||
pip install -r requirements.txt
|
||||
|
||||
pip install nose coverage coveralls pylint
|
||||
nosetests --with-coverage --cover-package=lbrynet -v -I functional_tests.py tests/
|
||||
# TODO: submit coverage report to coveralls
|
||||
|
||||
# TODO: as code quality improves, make pylint be more strict
|
||||
pylint -E --disable=inherit-non-class --disable=no-member lbrynet
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -euo pipefail
|
||||
set -o xtrace
|
||||
|
||||
wget https://www.python.org/ftp/python/2.7.11/python-2.7.11-macosx10.6.pkg
|
||||
sudo installer -pkg python-2.7.11-macosx10.6.pkg -target /
|
||||
pip install -U pip
|
||||
brew install gmp
|
||||
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
|
||||
(
|
||||
|
||||
sleep 4
|
||||
|
||||
zenity --question --text="<span size=\"xx-large\">LBRY Installed</span>\n\nRun LBRY now?" --title="LBRY Installed" --ok-label=" Yes" \
|
||||
--cancel-label=" No" --icon-name="system-software-install"
|
||||
|
||||
case $? in
|
||||
0) RUN=1 # yes
|
||||
;;
|
||||
1) RUN=0 # no
|
||||
;;
|
||||
*) RUN=0 # timeout or escape or whatever
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $RUN = 1 ]; then
|
||||
xdg-open "lbry://lbry"
|
||||
else
|
||||
zenity --info --text="<span size=\"xx-large\">LBRY Installed</span>\n\nNo problem. You can run LBRY later by going to
|
||||
|
||||
lbry://lbry
|
||||
|
||||
in your browser." --title="LBRY Installed" --icon-name="system-software-install"
|
||||
fi
|
||||
|
||||
) &
|
||||
@@ -1,38 +1,124 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Tested on fresh Ubuntu 14.04 install.
|
||||
|
||||
# wget https://raw.githubusercontent.com/lbryio/lbry/master/packaging/ubuntu/ubuntu_package_setup.sh
|
||||
# bash ubuntu_package_setup.sh [BRANCH] [WEB-UI-BRANCH]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BRANCH=${1:-master}
|
||||
WEB_UI_BRANCH=${2:-}
|
||||
function HELP {
|
||||
echo "Build a debian package for lbry"
|
||||
echo "-----"
|
||||
echo "When run without any arguments, this script expects the current directory"
|
||||
echo "to be the main lbry repo and it builds what is in that directory"
|
||||
echo
|
||||
echo "Optional arguments:"
|
||||
echo
|
||||
echo "-c: clone a fresh copy of the repo"
|
||||
echo "-b <branch>: use the specified branch of the lbry repo"
|
||||
echo "-w <web-ui-branch>: set the webui branch"
|
||||
echo "-d <build-dir>: specifiy the build directory"
|
||||
echo "-h: show help"
|
||||
echo "-t: turn trace on"
|
||||
exit 1
|
||||
}
|
||||
|
||||
BUILD_DIR="lbry-build-$(date +%Y%m%d-%H%M%S)"
|
||||
mkdir "$BUILD_DIR"
|
||||
CLONE=false
|
||||
BUILD_DIR=""
|
||||
BRANCH=""
|
||||
WEB_UI_BRANCH="master"
|
||||
|
||||
while getopts :hctb:w:d: FLAG; do
|
||||
case $FLAG in
|
||||
c)
|
||||
CLONE=true
|
||||
;;
|
||||
b)
|
||||
BRANCH=${OPTARG}
|
||||
;;
|
||||
w)
|
||||
WEB_UI_BRANCH=${OPTARG}
|
||||
;;
|
||||
d)
|
||||
BUILD_DIR=${OPTARG}
|
||||
;;
|
||||
t)
|
||||
set -o xtrace
|
||||
;;
|
||||
h)
|
||||
HELP
|
||||
;;
|
||||
\?) #unrecognized option - show help
|
||||
echo "Option -$OPTARG not allowed."
|
||||
HELP
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument."
|
||||
HELP
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
|
||||
SUDO=''
|
||||
if (( $EUID != 0 )); then
|
||||
SUDO='sudo'
|
||||
fi
|
||||
|
||||
if [ "$CLONE" = false ]; then
|
||||
if [ `basename $PWD` != "lbry" ]; then
|
||||
echo "Not currently in the lbry directory. Cowardly refusing to go forward"
|
||||
exit 1
|
||||
fi
|
||||
SOURCE_DIR=$PWD
|
||||
fi
|
||||
|
||||
if [ -z "${BUILD_DIR}" ]; then
|
||||
if [ "$CLONE" = true ]; then
|
||||
# build in the current directory
|
||||
BUILD_DIR="lbry-build-$(date +%Y%m%d-%H%M%S)"
|
||||
else
|
||||
BUILD_DIR="../lbry-build-$(date +%Y%m%d-%H%M%S)"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
if [ -z ${TRAVIS+x} ]; then
|
||||
# if not on travis, its nice to see progress
|
||||
QUIET=""
|
||||
else
|
||||
QUIET="-qq"
|
||||
fi
|
||||
|
||||
# get the required OS packages
|
||||
sudo add-apt-repository -y ppa:spotify-jyrki/dh-virtualenv
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential git python-dev libffi-dev libssl-dev libgmp3-dev dh-virtualenv debhelper
|
||||
$SUDO apt-get ${QUIET} update
|
||||
$SUDO apt-get ${QUIET} install -y --no-install-recommends software-properties-common
|
||||
$SUDO add-apt-repository -y ppa:spotify-jyrki/dh-virtualenv
|
||||
$SUDO apt-get ${QUIET} update
|
||||
$SUDO apt-get ${QUIET} install -y --no-install-recommends \
|
||||
build-essential git python-dev libffi-dev libssl-dev \
|
||||
libgmp3-dev dh-virtualenv debhelper wget python-pip fakeroot
|
||||
|
||||
# need a modern version of pip (more modern than ubuntu default)
|
||||
wget https://bootstrap.pypa.io/get-pip.py
|
||||
sudo python get-pip.py
|
||||
rm get-pip.py
|
||||
sudo pip install make-deb
|
||||
|
||||
# check out LBRY
|
||||
git clone https://github.com/lbryio/lbry.git --branch "$BRANCH"
|
||||
$SUDO pip install --upgrade pip
|
||||
$SUDO pip install make-deb
|
||||
|
||||
# build packages
|
||||
#
|
||||
# dpkg-buildpackage outputs its results into '..' so
|
||||
# we need to move/clone lbry into the build directory
|
||||
if [ "$CLONE" == true ]; then
|
||||
git clone https://github.com/lbryio/lbry.git
|
||||
else
|
||||
cp -a $SOURCE_DIR lbry
|
||||
fi
|
||||
(
|
||||
cd lbry
|
||||
make-deb
|
||||
dpkg-buildpackage -us -uc
|
||||
cd lbry
|
||||
if [ -n "${BRANCH}" ]; then
|
||||
git checkout "${BRANCH}"
|
||||
fi
|
||||
make-deb
|
||||
dpkg-buildpackage -us -uc
|
||||
)
|
||||
|
||||
|
||||
@@ -42,15 +128,20 @@ git clone https://github.com/lbryio/lbry.git --branch "$BRANCH"
|
||||
PACKAGE="$(ls | grep '.deb')"
|
||||
ar vx "$PACKAGE"
|
||||
mkdir control data
|
||||
tar -xvzf control.tar.gz --directory control
|
||||
tar -xvJf data.tar.xz --directory data
|
||||
tar -xzf control.tar.gz --directory control
|
||||
|
||||
# The output of the travis build is a
|
||||
# tar.gz and the output locally is tar.xz.
|
||||
# Instead of having tar detect the compression used, we
|
||||
# could update the config to output the same in either spot.
|
||||
# Unfortunately, doing so requires editting some auto-generated
|
||||
# files: http://linux.spiney.org/forcing_gzip_compression_when_building_debian_packages
|
||||
tar -xf data.tar.?z --directory data
|
||||
|
||||
PACKAGING_DIR='lbry/packaging/ubuntu'
|
||||
|
||||
# set web ui branch
|
||||
if [ -z "$WEB_UI_BRANCH" ]; then
|
||||
sed -i "s/^WEB_UI_BRANCH='[^']\+'/WEB_UI_BRANCH='$WEB_UI_BRANCH'/" "$PACKAGING_DIR/lbry"
|
||||
fi
|
||||
sed -i "s/^WEB_UI_BRANCH='[^']\+'/WEB_UI_BRANCH='$WEB_UI_BRANCH'/" "$PACKAGING_DIR/lbry"
|
||||
|
||||
# add files
|
||||
function addfile() {
|
||||
@@ -62,13 +153,22 @@ function addfile() {
|
||||
}
|
||||
addfile "$PACKAGING_DIR/lbry" usr/share/python/lbrynet/bin/lbry
|
||||
addfile "$PACKAGING_DIR/lbry.desktop" usr/share/applications/lbry.desktop
|
||||
#addfile lbry/packaging/ubuntu/lbry-init.conf etc/init/lbry.conf
|
||||
|
||||
cat "$PACKAGING_DIR/postinst_append" >> control/postinst
|
||||
|
||||
# repackage .deb
|
||||
sudo chown -R root:root control data
|
||||
tar -cvzf control.tar.gz -C control .
|
||||
tar -cvJf data.tar.xz -C data .
|
||||
sudo chown root:root debian-binary control.tar.gz data.tar.xz
|
||||
$SUDO chown -R root:root control data
|
||||
tar -czf control.tar.gz -C control .
|
||||
tar -cJf data.tar.xz -C data .
|
||||
$SUDO chown root:root debian-binary control.tar.gz data.tar.xz
|
||||
ar r "$PACKAGE" debian-binary control.tar.gz data.tar.xz
|
||||
|
||||
# TODO: we can append to data.tar instead of extracting it all and recompressing
|
||||
|
||||
if [[ ! -z "${TRAVIS_BUILD_DIR+x}" ]]; then
|
||||
# move it to a consistent place so that later it can be uploaded
|
||||
# to the github releases page
|
||||
mv "${PACKAGE}" "${TRAVIS_BUILD_DIR}/${PACKAGE}"
|
||||
# want to be able to check the size of the result in the log
|
||||
ls -l "${TRAVIS_BUILD_DIR}/${PACKAGE}"
|
||||
fi
|
||||
@@ -33,7 +33,7 @@ gui_data_files = ['close2.gif', 'lbry-dark-242x80.gif', 'lbry-dark-icon.xbm', 'l
|
||||
gui_data_paths = [os.path.join(base_dir, 'lbrynet', 'lbrynet_gui', f) for f in gui_data_files]
|
||||
|
||||
setup(name='lbrynet',
|
||||
description='A fully decentralized network for distributing data',
|
||||
description='A fully-decentralized content marketplace',
|
||||
version=__version__,
|
||||
maintainer='Jimmy Kiselak',
|
||||
maintainer_email='jimmy@lbry.io',
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
import xmlrpclib
|
||||
import json
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
from slackclient import SlackClient
|
||||
|
||||
def get_conf():
|
||||
f = open('testbot.conf', 'r')
|
||||
token = f.readline().replace('\n', '')
|
||||
f.close()
|
||||
return token
|
||||
|
||||
def test_lbrynet(lbry, slack, channel):
|
||||
logfile = open('lbrynet_test_log.txt', 'a')
|
||||
|
||||
try:
|
||||
path = lbry.get('testlbrynet')['path']
|
||||
except:
|
||||
msg = '[' + str(datetime.now()) + '] ! Failed to obtain LBRYnet test file'
|
||||
slack.rtm_connect()
|
||||
slack.rtm_send_message(channel, msg)
|
||||
print msg
|
||||
logfile.write(msg + '\n')
|
||||
|
||||
file_name = path.split('/')[len(path.split('/'))-1]
|
||||
|
||||
for n in range(10):
|
||||
files = [f for f in lbry.get_lbry_files() if (json.loads(f)['file_name'] == file_name) and json.loads(f)['completed']]
|
||||
if files:
|
||||
break
|
||||
sleep(30)
|
||||
|
||||
if files:
|
||||
msg = '[' + str(datetime.now()) + '] LBRYnet download test successful'
|
||||
slack.rtm_connect()
|
||||
# slack.rtm_send_message(channel, msg)
|
||||
print msg
|
||||
logfile.write(msg + '\n')
|
||||
|
||||
else:
|
||||
msg = '[' + str(datetime.now()) + '] ! Failed to obtain LBRYnet test file'
|
||||
slack.rtm_connect()
|
||||
slack.rtm_send_message(channel, msg)
|
||||
print msg
|
||||
logfile.write(msg + '\n')
|
||||
|
||||
lbry.delete_lbry_file('test.jpg')
|
||||
logfile.close()
|
||||
|
||||
token = get_conf()
|
||||
|
||||
sc = SlackClient(token)
|
||||
sc.rtm_connect()
|
||||
channel = [c['id'] for c in json.loads(sc.api_call('channels.list'))['channels'] if c['name'] == 'tech'][0]
|
||||
print 'Connected to slack'
|
||||
daemon = xmlrpclib.ServerProxy("http://localhost:7080")
|
||||
|
||||
while True:
|
||||
test_lbrynet(daemon, sc, channel)
|
||||
sleep(600)
|
||||
Reference in new issue
Block a user