Compare commits

...
505 Commits
Author SHA1 Message Date
Jack 1d39ec0317 Bump version: 0.4.1 → 0.4.2 2016-08-29 16:41:48 -04:00
Jack Robison 281b6468a0 Merge pull request #145 from lbryio/appveyor
build msi in appveyor
2016-08-29 16:39:46 -04:00
Jack Robison 9ba6da1f4d set development version to false 2016-08-29 16:28:49 -04:00
Jack bde7a7fed6 use normal lighthouse servers 2016-08-29 16:27:45 -04:00
Jack 6a5289b2a2 add master to branches 2016-08-29 15:50:54 -04:00
Jack 081a5df82c notifications 2016-08-29 15:24:55 -04:00
Jack 3e77ec8008 add slack notifications 2016-08-29 15:21:06 -04:00
Jack b0b222afa8 add errback 2016-08-29 14:55:26 -04:00
Jack d85d6f627d Merge branch 'master' into appveyor 2016-08-29 14:48:05 -04:00
Jack 9505f93da6 skip reflector test on windows 2016-08-29 14:47:54 -04:00
Jack 1671034330 fix json bug 2016-08-29 14:33:56 -04:00
Jack 3f0ca563e4 json encode metadata just before sending it 2016-08-29 14:26:20 -04:00
Jack ffa2a5e8fd skip pylint for now 2016-08-29 13:48:45 -04:00
Jack c3633895d0 Merge branch 'master' into appveyor 2016-08-29 13:46:08 -04:00
Jack c15af0a63a Bump version: 0.4.0 → 0.4.1 2016-08-29 13:44:46 -04:00
Jack 56e2d77039 fix _send_name_claim json 2016-08-29 13:44:18 -04:00
Jack 2cf6fa14a1 pylint path 2016-08-29 00:34:24 -04:00
Jack c374725255 test_script 2016-08-28 23:11:24 -04:00
Jack babfb6b8d6 add . to appveyor file, try tests 2016-08-28 23:05:40 -04:00
Jack 2ffa8ec7d0 use yml generated from appveyor 2016-08-28 19:26:37 -04:00
Jack b516119224 build appveyor branch only 2016-08-28 19:23:16 -04:00
Jack c0e6bb97d8 remove lbrynet_gui include 2016-08-28 17:33:30 -04:00
Jack cc30223ff1 don't cd to lbry in init 2016-08-28 16:42:07 -04:00
Jack 53c8748942 try again 2016-08-28 16:20:28 -04:00
Jack b3a8966e71 fix path 2016-08-28 15:42:14 -04:00
Jack 74800a0767 download lbrynet tar.gz 2016-08-28 15:34:04 -04:00
Jack cadd1f993d clone lbryio/lbry repo in appveyor build script 2016-08-28 15:10:29 -04:00
Jack a6619a628e flag to use development lighthouse servers 2016-08-28 05:25:48 -04:00
Jack 456572f87c Bump version: 0.3.22 → 0.4.0 2016-08-28 05:01:49 -04:00
Jack f024b96934 allow int fee amount 2016-08-28 03:09:36 -04:00
Jack Robison 25c71bcd98 Merge pull request #140 from lbryio/reflect-blobs
reflect_all_blobs daemon command
2016-08-28 01:33:13 -04:00
Jack Robison 319e7ecc61 Merge pull request #131 from lbryio/content_type
change content-type to content_type, refactor metadata validation
2016-08-28 01:29:51 -04:00
Jack Robison d9ece5e96a Merge pull request #143 from lbryio/sandbox-displayed-files
prevent lbry files opened through the ui from making api calls
2016-08-28 01:28:56 -04:00
Jack Robison 4bfe4450b1 Merge pull request #144 from lbryio/pr/141
Add windows URI Handling
2016-08-28 01:28:12 -04:00
Jack f9f12ffb61 move uri handler to packaging/uri_handler 2016-08-28 01:10:28 -04:00
Jack 63f81d1033 prevent a lbry files opened through the ui from making api calls 2016-08-27 23:16:48 -04:00
David Amrhein 2ac1ebeaa0 Temp solution for distributing the regedit for windows URI handling 2016-08-27 01:37:25 -04:00
David Amrhein 25437602d7 Add URI handling as an arg 2016-08-27 01:32:28 -04:00
Jack Robison 8159c71950 update os x instructions 2016-08-26 22:13:04 -04:00
Jack aa66af7ba6 fix tests 2016-08-26 20:22:11 -04:00
Jack be3633622c whoops 2016-08-26 20:13:10 -04:00
Jack 31655a641c fix setup.py 2016-08-26 19:59:17 -04:00
Jack b235f6fc6b send all blobs to reflector 2016-08-26 19:58:53 -04:00
Jack Robison 76b297b173 Merge pull request #139 from lbryio/get_all_verified_blobs
Get all verified blobs
2016-08-26 19:45:49 -04:00
Jack Robison 1e5cff1d8b Merge pull request #130 from lbryio/osx-command-line-install
add os x install script to replace out of date and non existent one in lbry-setup
2016-08-26 16:08:08 -04:00
Jack Robison 4e2296d5f6 Merge pull request #115 from lbryio/get-stream-timeout
raise Exception on GetStream timeout
2016-08-26 16:07:42 -04:00
Dave-A 18310632eb Merge pull request #9 from lbryio/master
Update
2016-08-26 10:16:46 -04:00
Jack 80ed8d9869 Bump version: 0.3.21 → 0.3.22 2016-08-26 00:56:06 -04:00
Jack 2a2658d440 fix Access-Control-Allow-Origin problem 2016-08-26 00:50:31 -04:00
Jack 710e549c03 add get_all_verified_blobs 2016-08-26 00:32:33 -04:00
Jack 47fae977dd fix Access-Control-Allow-Origin problem 2016-08-25 23:39:05 -04:00
Alex Grintsvayg 0111919975 jack fixed the unicode bug here 2016-08-25 19:09:55 -04:00
Jack 80837cb040 Merge branch 'master' into content_type
fix conflicts:
	lbrynet/lbrynet_daemon/LBRYPublisher.py
2016-08-25 17:59:20 -04:00
Jack 46153a8991 second shot at pylint error 2016-08-23 02:25:32 -04:00
Jack a9fccfd4ce fix pylint error 2016-08-23 02:17:32 -04:00
Dave-A dfb57e9438 Merge pull request #8 from lbryio/master
Update version
2016-08-23 02:17:29 -04:00
Jack eda2731702 Bump version: 0.3.20 -> 0.3.21 2016-08-23 01:59:50 -04:00
Jack Robison f47eac5935 Merge pull request #136 from DaveA50/master
Add Windows support
2016-08-23 01:53:50 -04:00
David Amrhein 3bb4dece5a Use main lbry repo for gmpy wheel url 2016-08-23 01:26:35 -04:00
David Amrhein 0504e231a1 Use main lbryum repo 2016-08-23 01:16:04 -04:00
David Amrhein 6097e14617 Make systray thread a daemon to close on api.stop() 2016-08-23 01:05:07 -04:00
David Amrhein 0b149ce5f1 Remove old osx imports 2016-08-22 21:21:56 -04:00
Dave-A 79384e7bf8 Merge pull request #7 from lbryio/master
Update
2016-08-22 20:02:35 -04:00
Jack Robison 01eb79cac2 Merge pull request #135 from lbryio/lbrycrdwallet-updateclaim-fix
LBRYcrdWallet update claim fix
2016-08-22 19:58:28 -04:00
Jack 128b32c62c even less noisy logs 2016-08-22 19:56:42 -04:00
David Amrhein c1233bd26b Make 'rb' file mode windows specific 2016-08-22 19:55:08 -04:00
David Amrhein e23f67def6 File handle for publishing on windows needs to handle binary data as 'rb' 2016-08-22 19:24:57 -04:00
Jack 95f4b29be5 noisy log 2016-08-22 18:59:17 -04:00
Jack 5727c708cf fix get_transaction
previously get_tx_json was only in LBRYumWallet
2016-08-22 18:43:52 -04:00
Jack e49f0f99a1 LBRYcrdWallet update claim fix
-fix log line that could raise an exception
-json encode value sent to lbrycrd-cli updateclaim
2016-08-22 16:57:22 -04:00
David Amrhein 84d340382b Fix for icon path when running shortcut 2016-08-21 18:58:50 -04:00
David Amrhein 5bfb067d0f Rename to just Open 2016-08-21 18:49:41 -04:00
David Amrhein d8cb62a92c Run win32 as systray app 2016-08-21 18:44:16 -04:00
Dave-A aab8cc40f9 Merge pull request #6 from lbryio/master
Update from Origin
2016-08-21 14:13:59 -04:00
Jack 9c82689f65 Bump version: 0.3.19 -> 0.3.20 2016-08-21 04:04:11 -04:00
Jack Robison ce2755467d Merge pull request #133 from sonatagreen/patch-1
spelling fix
2016-08-21 03:44:10 -04:00
Jack Robison 02b19402ae Merge pull request #116 from lbryio/reflector
Backend for pushing newly created files to a designated server
2016-08-21 03:43:03 -04:00
Jack 80af66e852 Merge branch 'master' into reflector
# Conflicts:
#	lbrynet/core/log_support.py
2016-08-21 01:12:29 -04:00
Jack 15cfa45646 remove duplicate function 2016-08-21 00:58:25 -04:00
Jack Robison ac63849b49 Merge pull request #132 from lbryio/fix-get-history
fix get_history in lbrycrdwallet
2016-08-21 00:07:41 -04:00
Jack Robison 02142e352b Merge pull request #127 from lbryio/disable-more-noisy-loggers
reduce logging to sub fire hazard levels
2016-08-21 00:07:19 -04:00
Jack 3d92413372 debug logging 2016-08-20 23:47:41 -04:00
Jack 5022ed2acc blob_completed before moving to next one
otherwise blob files download to the blobfiles directory, but they are
never recorded in blobs.db
2016-08-20 23:47:12 -04:00
Sonata Green 31b9d22649 spelling fix 2016-08-19 21:12:02 -05:00
Jack 7a54894015 debugging stuff 2016-08-19 02:41:23 -04:00
Jack 7100345a09 Merge branch 'master' into reflector 2016-08-18 22:42:27 -04:00
Jack 929db15214 fix get_history in lbrycrdwallet 2016-08-18 22:15:49 -04:00
Jack d9455926c5 Merge branch 'master' into content_type 2016-08-18 21:56:55 -04:00
David Amrhein ba5cd741e1 Testing copying instead of moving upload file to avoid access error 2016-08-18 10:45:03 -04:00
Dave-A 8c94b6243e Merge pull request #5 from lbryio/master
Update to 0.3.19
2016-08-18 10:38:07 -04:00
Jack f6473e3383 Bump version: 0.3.18 -> 0.3.19 2016-08-18 06:41:17 -04:00
Jack Robison 3cd9d6a604 Merge pull request #129 from kimihiro64/patch-2
Proper no-cache for web-ui index.html
2016-08-18 06:39:11 -04:00
Jack 142281777e stop heartbeat looping call on shutdown 2016-08-18 06:37:57 -04:00
Jack 8e7b8af180 call blob_completed when is_validated is true 2016-08-18 06:23:27 -04:00
Jack c046cd02d5 call blob_completed after receiving blob 2016-08-18 05:58:13 -04:00
Jack f5508fcdf1 typo 2016-08-18 05:36:17 -04:00
Jack adc2eab6da log request dict 2016-08-18 05:36:01 -04:00
Jack 702698d8aa stop heartbeat looping call on shutdown 2016-08-18 05:25:23 -04:00
David Amrhein 73dbe1de37 Fix relative pathing for cacert for win builds 2016-08-18 01:25:48 -04:00
Jack c5706fa28b fix imports in tests 2016-08-18 00:38:38 -04:00
Jack c906a9571e add service identity 2016-08-18 00:31:05 -04:00
Jack 038712f431 install script 2016-08-18 00:30:57 -04:00
David Amrhein ed2d2c6f86 Ignore msi_data shortcuts, which didn't work anyway 2016-08-18 00:13:31 -04:00
kimihiro64 e7158e5a4b Fix editor spacing again 2016-08-17 23:02:38 -05:00
kimihiro64 c66df259a6 fix editor spacing 2016-08-17 23:02:00 -05:00
kimihiro64 0b8437fa12 Proper no-cache for web-ui index.html 2016-08-17 22:34:20 -05:00
Jack a32b6ebf82 add reflect jsonrpc command 2016-08-17 21:33:41 -04:00
Jack edbda1696e logging fire hazard 2016-08-17 20:24:48 -04:00
Jack ece218785c reduce logging to sub fire hazard levels 2016-08-17 20:20:03 -04:00
Jack cc1b3609a1 Merge branch 'master' into reflector
# Conflicts:
#	lbrynet/__init__.py
2016-08-17 19:01:38 -04:00
Alex Grintsvayg 0841aad07a fix double-tab bug on linux 2016-08-17 14:30:56 -04:00
David Amrhein 30b04ed0c2 Change naming conventions 2016-08-17 14:25:02 -04:00
David Amrhein 90b28b3dbd Pass WindowsError when moving uploaded file 2016-08-17 14:15:55 -04:00
Jack 0f7ca8f24e move metadata and validator classes into their own directory 2016-08-17 12:28:15 -04:00
David Amrhein 726d85ebd0 Remove blindrepeater.yapsy-plugin from build 2016-08-17 12:13:47 -04:00
David Amrhein c524de9198 Update protobuf out of beta 2016-08-17 12:12:28 -04:00
Dave-A 2fbf03d8ca Merge pull request #4 from lbryio/master
Update from lbry
2016-08-17 12:03:08 -04:00
Jack 68b8112af0 Merge branch 'master' into content_type 2016-08-17 03:04:14 -04:00
Jack 975e83a015 Bump version: 0.3.17 -> 0.3.18 2016-08-17 02:39:48 -04:00
Jack 1ddb02dbb7 speed up search
get results for get_est_cost from lighthouse instead of manually trying
unless force=True
2016-08-17 02:38:59 -04:00
Jack Robison 1159204ed8 Merge pull request #126 from lbryio/pretty-dmg
Make a pretty dmg
2016-08-17 01:36:44 -04:00
Jack Robison a5212e7741 Merge pull request #121 from lbryio/save-settings
Save settings
2016-08-17 01:34:50 -04:00
Jack Robison 1932fd72e3 Merge pull request #123 from lbryio/add-heartbeat
Add basic analytics api and heartbeat event
2016-08-17 01:34:31 -04:00
Jack Robison c061fe091b Merge pull request #122 from lbryio/add-debug-logging
Add debug logging
2016-08-17 01:33:07 -04:00
Jack Robison 3621983a4d Merge pull request #119 from lbryio/update-protobuf
Update protobuf
2016-08-17 01:31:48 -04:00
Dave-A b6656690ca Merge pull request #3 from lbryio/master
Update from lbry
2016-08-16 21:13:24 -04:00
David Amrhein 0c9e82ee6b Update appveyor to DaveA50 git repo links 2016-08-16 20:04:11 -04:00
David Amrhein b8ebb1faf1 Convert to lbryum github repo 2016-08-16 19:58:47 -04:00
David Amrhein 690575193f Add gmpy windows wheel 2016-08-16 18:01:18 -04:00
David Amrhein 9e9cf63c90 Add appveyor.yml build script 2016-08-16 17:54:36 -04:00
Job Evers-Meltzer f5dc213e53 need to not be in build dir 2016-08-16 15:16:55 -05:00
Job Evers-Meltzer 138e9c1486 throw more things at wall 2016-08-16 15:03:41 -05:00
Job Evers-Meltzer 7053c0dc93 argh. so much hate 2016-08-16 14:52:08 -05:00
Job Evers-Meltzer ee8a653b13 argh. so much hate 2016-08-16 14:43:49 -05:00
Job Evers-Meltzer 71fad7e97f also need wheel 2016-08-16 13:41:04 -05:00
Job Evers-Meltzer 04740eb928 need to detect if ON_TRAVIS earlier 2016-08-16 13:24:38 -05:00
Job Evers-Meltzer 8c63d58c96 tmp: debug travis 2016-08-16 13:21:38 -05:00
Job Evers-Meltzer 991672d423 move pyobj building earlier 2016-08-16 13:16:25 -05:00
Job Evers-Meltzer 55ce38cc87 temp: debug travis 2016-08-16 12:52:55 -05:00
Job Evers‐Meltzer 96f3390407 Merge pull request #120 from lbryio/defer-later
replace callLater with deferLater
2016-08-16 12:36:43 -05:00
Job Evers-Meltzer aa2426d4e4 ignore DS_Store files 2016-08-16 12:26:19 -05:00
Job Evers-Meltzer d0e3e13852 ignore osx build artifacts 2016-08-16 12:25:35 -05:00
Job Evers-Meltzer a2a1e30d68 remove unnecessary libgmp 2016-08-16 12:25:18 -05:00
Job Evers-Meltzer a6f08b9e0c Prettifies the osx dmg
Adds a new background image, along with precisely located icon files.
Also updates the icon files to have white backgrounds. The icon files were
created using the 256px icon used in the ubuntu build.
2016-08-16 12:22:14 -05:00
David Amrhein e70842a38c Better fix for finding protobuf namespace 2016-08-15 23:09:46 -04:00
David Amrhein 2af98d7d42 Add loggly and request futures to includes 2016-08-15 20:48:27 -04:00
David Amrhein f28eee34e8 Merge remote-tracking branch 'origin/master' 2016-08-15 20:31:59 -04:00
Dave-A 208610b645 Merge pull request #2 from lbryio/master
Update from base
2016-08-15 20:31:31 -04:00
David Amrhein e38f8076bc Create site-package protobuf __init__ if needed 2016-08-15 19:40:32 -04:00
David Amrhein 6180e1a48b Update to build and distribute >v0.3.12 2016-08-15 19:19:26 -04:00
Jack e8fe1cd14d more test fixes 2016-08-15 18:39:09 -04:00
Jack 75d1fa585c fix tests 2016-08-15 18:30:14 -04:00
Jack 072ff4b02e fix tests 2016-08-15 18:13:36 -04:00
Jack d8c4e2a72e whoops 2016-08-15 17:54:43 -04:00
Jack 66396de6a3 remove as_json and serialize 2016-08-15 17:41:38 -04:00
Jack 1ca9f575ef decorator prettiness 2016-08-15 17:07:50 -04:00
Jack 272e074a15 change content-type to content_type, make changing metadata easier 2016-08-14 01:00:49 -04:00
Job Evers 9a738c3783 Add basic analytics api and heartbeat event 2016-08-12 13:37:26 -05:00
Jack 6b4519e959 squelch very verbose dht error log 2016-08-12 10:46:05 -05:00
Job Evers-Meltzer 9b1d5213a6 improve logging 2016-08-12 10:44:37 -05:00
Job Evers-Meltzer f9ed9a4505 fixup logging some more 2016-08-12 10:42:31 -05:00
Job Evers-Meltzer 3ed7ce5630 Ensure settings are actually committed
Without committing or closing the db, settings were not being saved.

Also, adds a run_in_thread decorator to simplify the code.
2016-08-12 10:08:21 -05:00
Job Evers 63cd8343c4 replace callLater with deferLater 2016-08-11 13:41:42 -05:00
Jack 2d5f8aed24 whitespace 2016-08-11 12:38:10 -04:00
Jack b8d23d0965 add announce_all_blobs_to_dht 2016-08-11 12:36:13 -04:00
Job Evers-Meltzer f4ef92e653 fixup logging some more 2016-08-11 05:37:45 +00:00
Job Evers-Meltzer c7430f4ae9 better more logging on the server side 2016-08-11 05:25:45 +00:00
Job Evers-Meltzer 623fda3087 improve logging 2016-08-11 05:16:50 +00:00
Job Evers-Meltzer 80f27f2b29 Revert "more logging on the server side"
This reverts commit f83daa5a22.
2016-08-11 05:11:18 +00:00
Jack defbd73b4f squelch very verbose dht error log 2016-08-11 01:07:51 -04:00
Jack 5285982515 resolve reflector ip 2016-08-11 01:07:51 -04:00
Job Evers-Meltzer f83daa5a22 more logging on the server side 2016-08-11 04:45:25 +00:00
Job Evers-Meltzer 0a07c8f131 log on closed/lost connection 2016-08-10 19:39:28 -05:00
Job Evers-Meltzer 35481a92f5 actually cleanup patched time.time 2016-08-10 19:36:52 -05:00
Job Evers-Meltzer 0995d864e8 connectTCP wants an ip address, not a url 2016-08-10 19:09:20 -05:00
Job Evers-Meltzer 1a42e43573 log all the things 2016-08-10 19:06:26 -05:00
Jack 132aa569fe move run_reflector_server into settings file and add debug lines 2016-08-10 16:51:46 -04:00
Job Evers-Meltzer e93a787bd6 update protobuf out of beta 2016-08-10 09:28:13 -05:00
Job Evers-Meltzer d6f902653f put import in alphabetical order 2016-08-10 08:35:15 -05:00
Job Evers-Meltzer d172d43ddf add reflector functional test to travis 2016-08-10 08:29:44 -05:00
Job Evers-Meltzer 67909724e7 fix up import paths 2016-08-10 07:44:41 -05:00
Jack 1c88cbc5f6 Merge branch 'master' into reflector 2016-08-10 02:31:28 -04:00
Jack 3fb4831804 raise exception when curr_pos > 100 and json fails to decode 2016-08-10 02:30:41 -04:00
Jack b65570fb16 drop connection on response longer than 100 bytes that can't' be decoded 2016-08-09 19:53:13 -04:00
Jack 871e6e6f64 remove files that didn't fix test 2016-08-09 17:53:34 -04:00
Jack 0cd92a96c0 add reflector files to tests directory 2016-08-09 17:46:25 -04:00
Jack ff31ddd2d5 Bump version: 0.3.16 -> 0.3.17 2016-08-09 14:40:18 -04:00
Jack e9f5b43785 fix exceptions 2016-08-09 14:29:59 -04:00
Jack 36b41081ab Bump version: 0.3.15 -> 0.3.16 2016-08-09 12:41:11 -04:00
Jack Robison 1092313892 Merge pull request #118 from lbryio/add-LBRYDaemonRequest
add LBRYDaemonRequest to os x app
2016-08-09 12:35:08 -04:00
Jack Robison ce605cb8f3 Merge pull request #117 from lbryio/update-lbrycrdd
use most recent lbrycrdd release on github
2016-08-09 12:32:40 -04:00
Jack 0733d885fb start reflector upload in publish 2016-08-09 12:26:34 -04:00
Jack ef6fe3d1d9 add variable to enable running reflector server 2016-08-09 12:18:46 -04:00
Jack 82a4fea81a fix log statement 2016-08-09 12:12:40 -04:00
Jack 14a0252819 hooking up reflector plumbing 2016-08-09 12:07:26 -04:00
Job Evers-Meltzer 849aeb65f0 use most recent lbrycrdd release on github 2016-08-09 11:03:40 -05:00
Jack a99dc6e93d add LBRYDaemonRequest to os x app 2016-08-09 11:19:01 -04:00
Alex Liebowitz 1a5fcc1348 Add requests_futures dependency 2016-08-09 07:59:27 -04:00
Jack c9d88f5628 Bump version: 0.3.14 -> 0.3.15 2016-08-09 03:29:51 -04:00
Jack Robison 0910711aca Merge pull request #111 from lbryio/update-claim
claim updates
2016-08-09 03:29:12 -04:00
Jack 6a1a9ef6bc encode claim id to be shown in log 2016-08-09 03:25:20 -04:00
Jack ef1c059079 clean up log line 2016-08-09 03:18:44 -04:00
Jack a05ab37373 Merge branch 'master' into update-claim
# Conflicts:
#	lbrynet/lbrynet_daemon/LBRYDaemon.py
2016-08-09 03:09:06 -04:00
Jack 7ea88cfd22 crudely fix loggly import problem 2016-08-09 03:01:33 -04:00
Jack Robison 8d14fe6a90 Merge pull request #113 from lbryio/log-to-loggly
Log to loggly
2016-08-09 02:30:55 -04:00
Jack Robison 49a05b42f9 Merge pull request #114 from lbryio/no-unused-imports
Remove all unused imports; add check to pylint
2016-08-09 02:30:49 -04:00
Jack b6da1d7769 decode and reverse claim id for updateclaim in lbryum 2016-08-09 01:26:55 -04:00
Jimmy Kiselak 7e2ad58edd get reflector client and server working; add func test to prove it 2016-08-09 00:59:50 -04:00
Jack 7ad0d98404 Merge branch 'master' into update-claim 2016-08-08 21:39:41 -04:00
Jack b7052bba95 rename variable 2016-08-08 21:34:05 -04:00
Jack 4a5618bcc4 get update claim working with lbryumwallet 2016-08-08 21:32:39 -04:00
Job Evers-Meltzer c1850fe604 raise Exception on GetStream timeout 2016-08-08 16:26:33 -05:00
Job Evers-Meltzer fccdf32c9f Remove all unused imports; add check to pylint 2016-08-08 15:42:35 -05:00
Jack c474411e1b delete bad records that got into name_metadata 2016-08-08 16:35:55 -04:00
Job Evers-Meltzer 9033eac5b1 Remove commented code 2016-08-08 15:07:25 -05:00
Job Evers-Meltzer 0ba0426591 Refactor lbrycrdd path function for osx 2016-08-08 15:06:48 -05:00
Job Evers-Meltzer 9a9b540701 Move some ServerRequestHandling logging to debug level 2016-08-08 15:04:50 -05:00
Job Evers-Meltzer b8ddbb9a26 Add loggly logger
It configured twice, once right at startup without the lbry id and then
after the settings database is available it gets reconfigured with the
lbry id and a session id.
2016-08-08 15:02:36 -05:00
Job Evers-Meltzer bc3c2b96ed disable noisy loggers 2016-08-08 14:59:30 -05:00
Job Evers-Meltzer 622dc87d84 Remove log handlers with the same name
Also renames functions to follow underscore convention
2016-08-08 14:57:49 -05:00
Jack 18edbdf404 squelch resolve_name logging 2016-08-08 14:58:31 -04:00
Job Evers-Meltzer 02a3eab693 add loggly dependency 2016-08-08 11:39:11 -05:00
Job Evers-Meltzer dded868a80 remove leveldb requirement 2016-08-08 11:37:01 -05:00
Jack 6fe878bdb9 make load_from_hex a class method 2016-08-08 03:18:32 -04:00
Jack 505ece9e36 add txid param to get_claim_info and update todo note 2016-08-08 02:37:08 -04:00
Jack 72acfa1e0c add support_claim 2016-08-08 02:32:56 -04:00
Jack 02cd8b9a44 fix callback 2016-08-08 02:08:09 -04:00
Jack f32250f431 whoops 2016-08-08 01:54:41 -04:00
Jack 1523cad044 refactor get_claim_info 2016-08-08 01:46:19 -04:00
Jack ed55353700 bug fix 2016-08-08 01:43:28 -04:00
Jack 8d3bd45102 get_claims_for_name daemon function 2016-08-08 01:43:10 -04:00
Jack f69753f6a0 add get_claims_for_name 2016-08-08 01:42:37 -04:00
Jimmy Kiselak b7e2e87ac1 fill in much of the skeleton for the reflector protocol 2016-08-07 22:33:40 -04:00
Jack 3b98508986 clean up claim_name function 2016-08-07 16:13:47 -04:00
Jack 36ebfc42d9 update from master 2016-08-06 21:44:14 -04:00
Jack ae5f55ff65 Bump version: 0.3.13 -> 0.3.14 2016-08-06 20:07:28 -04:00
Jack Robison 01131da5b7 Merge pull request #99 from lbryio/refactor-refresh
Add DownloadNameHelper and ResolveNameHelper
2016-08-06 20:06:43 -04:00
Jack 66ae865de0 don't make new lbry file if publish is given a full metadata dict, remove update_claim() 2016-08-06 20:02:51 -04:00
Job Evers-Meltzer 8c50f08fec refactor _start_download 2016-08-05 11:37:24 -05:00
Job Evers-Meltzer e69de47daf refactor wait_on_write stopping condition 2016-08-05 11:37:24 -05:00
Job Evers-Meltzer acef10e848 fix merge oversight 2016-08-05 11:37:24 -05:00
Job Evers edb9d50d9e fix typo in docstring 2016-08-05 11:37:24 -05:00
Job Evers b989d4f6be Bug fix: correct the check on wait_or_get_stream
I reversed the check on lbry_file. Compare to the original code:
https://github.com/lbryio/lbry/blob/e67f55bd7447cbee730d895b7f35cf53cf69dba5/lbrynet/lbrynet_daemon/LBRYDaemon.py#L1119
2016-08-05 11:37:24 -05:00
Job Evers 84dd5c0eca Revert "revert get() refactor"
This reverts commit 5eb7c64ec3.
2016-08-05 11:37:24 -05:00
Job Evers-Meltzer db8daf20b7 quiet noisy log statement 2016-08-05 05:50:24 -05:00
Jack cb985b5a03 log conditions of lbry_file failing to start 2016-08-04 23:27:44 -04:00
Jack 28c4e38272 make line neater 2016-08-04 23:27:25 -04:00
Jack b29377dc2b keep claim id history 2016-08-04 23:27:10 -04:00
Jack ca09592a72 make logs easier to scroll through 2016-08-04 23:10:15 -04:00
Jack b0e14fae43 update over existing claim in publish() 2016-08-04 23:08:54 -04:00
Jack dfa68f126b get update_name in lbrycrdwallet working 2016-08-04 20:43:39 -04:00
Jack 4570f68727 add claim_id to lbry_file and to get_claim_info 2016-08-04 18:44:12 -04:00
Jack 4705acba55 use lbryum updateclaim 2016-08-04 02:22:10 -04:00
Jimmy Kiselak 1dea20a358 include sd blob hashes in list of blob hashes to send via reflector 2016-08-03 23:11:29 -04:00
Jimmy Kiselak 191f661b35 skeleton for reflector protocol 2016-08-03 23:03:14 -04:00
Jack f3ab38ba8f Bump version: 0.3.12 -> 0.3.13 2016-08-03 18:01:18 -04:00
Jack Robison 2d0a892e70 Merge pull request #110 from lbryio/lighthouse-client
Lighthouse client
2016-08-03 18:00:04 -04:00
Jack Robison 00eefe87d7 Merge pull request #109 from lbryio/download-descriptor
add download_descriptor
2016-08-03 17:59:52 -04:00
Jack f68fd96555 break out sd timeout into a variable 2016-08-03 17:57:26 -04:00
Jack fc50a3242f add note about request.notifyFinish 2016-08-03 17:49:13 -04:00
Jack 64e9ce2bfa comments about the upnp redirects 2016-08-03 17:44:41 -04:00
Jack e8d04b1921 specify a lighthouse server 2016-08-03 17:44:32 -04:00
Jack 9fedf14e55 request.notifyFinish 2016-08-03 12:46:46 -04:00
David Amrhein 7d535ef7d1 Make ca_path checks for frozen windows only 2016-08-03 10:16:14 -04:00
Jack 85d610bcdf add get_peers_for_hash 2016-08-03 03:16:06 -04:00
Jack 3af8b7bd0c use upnp redirects if they're already set 2016-08-03 01:27:40 -04:00
Jack 6215d85581 add LighthouseClient, announce sd hash after publishing 2016-08-02 18:34:48 -04:00
Jack 308d9f5abd add todo 2016-08-02 17:33:57 -04:00
Jack bcfabba038 fast search
use cost from lighthouse
2016-08-02 16:45:06 -04:00
Jack 69139b1987 already called error 2016-08-02 16:03:47 -04:00
Jack 3f8f9d9d73 add timeout to download_sd_blob 2016-08-02 02:54:04 -04:00
Jack 2283579109 reorganize download_descriptor 2016-08-01 23:15:32 -04:00
Jack 1e0af94ba2 add download_descriptor 2016-08-01 22:31:49 -04:00
David Amrhein dd631328e0 Update windows distribution setup 2016-07-30 22:54:51 -04:00
David Amrhein cca2a57c69 Set cacert environ path for windows distribution 2016-07-30 22:52:49 -04:00
David Amrhein bbfbcacc6a Add windows icons for packaging 2016-07-30 22:10:30 -04:00
David Amrhein 3f95c1a9d5 Skip db migration in windows 2016-07-30 17:09:38 -04:00
David Amrhein 7bd05e9b16 Handle creation of settings directory in windows 2016-07-30 17:09:15 -04:00
Dave-A 10742d7c51 Merge pull request #1 from lbryio/master
Update from original
2016-07-30 16:48:25 -04:00
Jack bbf7940e45 Bump version: 0.3.11 -> 0.3.12 2016-07-29 23:44:04 -04:00
Jack Robison f5af71f4e6 Merge pull request #107 from lbryio/metadata-version
Metadata versioning, publishing things, and USD denominated key fees
2016-07-29 23:43:11 -04:00
Jack 1ffcd67c9d specify exception 2016-07-29 23:05:01 -04:00
Jack cf8592ba12 docstring and todo 2016-07-29 22:49:50 -04:00
Jack 1e1d036590 clean log line 2016-07-29 22:44:38 -04:00
Jack 64afb6d305 clean up get_est_costs in search 2016-07-29 22:43:50 -04:00
Jack 20a9e018f7 revert updates to git 2016-07-29 22:36:30 -04:00
Jack a574c33ac6 multiple search servers 2016-07-29 21:37:44 -04:00
Jack d21e458fe1 remove debug line 2016-07-29 02:42:58 -04:00
Jack bb3ba53c6e fix search results 2016-07-28 22:39:34 -04:00
Jack ba2e4df76b remove debug stuff 2016-07-28 21:31:19 -04:00
Jack 33e7e4bee3 fancy search 2016-07-28 21:25:37 -04:00
Jack b83dce2cb3 no tricky characters 2016-07-28 18:48:29 -04:00
Jack 6821676853 handle decimals in jsonrpc return 2016-07-28 18:12:54 -04:00
Jack 52024986ee derp 2016-07-28 16:32:59 -04:00
Jack 2e3342d20d fix test 2016-07-28 16:27:16 -04:00
Jack 419aa1d78f fix est data cost / search 2016-07-28 16:12:20 -04:00
Jack de4ddd578f improve readability of metadata and fee requirements 2016-07-28 15:24:20 -04:00
Jack 5dd68a7ed4 add get_claim_info, clean up _get_stream_info_from_value 2016-07-28 14:55:17 -04:00
Jack 881168dc7a fix too many args 2016-07-28 13:16:33 -04:00
Job Evers-Meltzer 295e427abe bug fix: check if fee is in metadata before loading 2016-07-28 12:04:25 -05:00
Job Evers 67c5d15f51 stupid typo 2016-07-28 11:46:33 -05:00
Job Evers 39a7f37f35 muck with pending_claims... still not sure this is correct 2016-07-28 11:43:47 -05:00
Job Evers 15d276b0bc fix case where to and from currencies are the same 2016-07-28 11:43:20 -05:00
Jack 4387025c48 another still 2016-07-28 06:07:33 -04:00
Jack 52c20f02c7 one more 2016-07-28 06:03:47 -04:00
Jack 413dab8094 whoops 2016-07-28 05:59:10 -04:00
Jack 6b1d11a04d fix rate in test 2016-07-28 05:53:31 -04:00
Jack 5441379f38 fix LBRYExchangeRateManager test 2016-07-28 05:49:31 -04:00
Jack 52d954c64e don't spam the market apis 2016-07-28 05:34:20 -04:00
Jack 415495fc16 LBRYExchangeRateManager 2016-07-28 05:30:13 -04:00
Jack 4223298634 test wrong metadata version 2016-07-28 02:49:35 -04:00
Jack e058c71019 test data 2016-07-28 02:46:46 -04:00
Jack 12b2bbfa26 make sure claimed ver is true 2016-07-28 02:36:07 -04:00
Jack 7d22bfffa5 fee tests 2016-07-28 02:30:37 -04:00
Jack 4ade80c8a9 clean up metadata and fee 2016-07-28 02:19:45 -04:00
Jack 9674381fc2 Merge remote-tracking branch 'origin/metadata-version-avec-tests' into metadata-version 2016-07-27 20:18:00 -04:00
Jack f6d91280d7 remove debug print line 2016-07-27 15:03:03 -04:00
Jack e4ebbd8f69 neater force param in resolve_name 2016-07-27 15:02:54 -04:00
Jack 7f5560de6d comment spacing and removing setLevel 2016-07-27 15:02:19 -04:00
Job Evers-Meltzer 0925171e07 bug fix: use txid attribute, not key 2016-07-27 13:59:26 -05:00
Job Evers-Meltzer 900d3ad01d Fixes errback not being callable
Small code refactoring to make it more obvious what
both the callback and errback are doing
2016-07-27 13:12:20 -05:00
Job Evers-Meltzer 6a1efedc1f some example tests. please expand on these 2016-07-27 12:05:29 -05:00
Job Evers-Meltzer 0f602e0e62 allow bittrex fee to be changed 2016-07-27 11:59:57 -05:00
Jack 3a425fc47d Merge branch 'master' into metadata-version 2016-07-27 05:07:23 -04:00
Jack 36722cbbd8 Bump version: 0.3.10 -> 0.3.11 2016-07-27 03:58:25 -04:00
Jack 9572336e96 Merge branch 'master' into metadata-version
# Conflicts:
#	lbrynet/core/utils.py
#	lbrynet/lbrynet_daemon/LBRYDaemon.py
2016-07-27 03:54:10 -04:00
Jack 4895cde474 fix conflicts 2016-07-27 03:48:32 -04:00
Jack Robison 21ca1a73cf Merge pull request #100 from lbryio/change-ui-location
web-ui files are on S3 now
2016-07-27 03:44:28 -04:00
Jack Robison 457c1c6ae6 Merge pull request #101 from lbryio/version-cmp
Properly Compare Version Strings
2016-07-27 03:43:13 -04:00
Jack Robison c1ff127101 Merge pull request #102 from lbryio/log-configure
Fix: Log configuration should not happen when a module is imported
2016-07-27 03:42:51 -04:00
Jack 5e815a5832 merge master 2016-07-27 03:22:03 -04:00
Jack 4604e9cd54 check pending claims after one is made 2016-07-27 03:00:44 -04:00
Jack ef580a7680 errback for pending of date lbry_file 2016-07-27 01:51:09 -04:00
Jack 2102776be8 another errback 2016-07-27 01:44:01 -04:00
Jack f3af7a6b77 add errback for unknown name 2016-07-27 01:39:23 -04:00
Jack 5abeceac1f abandon previous claim in update 2016-07-27 01:13:41 -04:00
Jack 22f73a0817 add force parameter to resolve_name 2016-07-26 21:46:04 -04:00
Jack 29b5aef73a call restore() after claiming name 2016-07-26 21:24:58 -04:00
Jack 3e602bce52 fix publish callback 2016-07-26 20:58:37 -04:00
Jack fe39901885 update claim when publishing to an already claimed name
-also save name_metadata for each unique claim rather than for each name
2016-07-26 20:52:05 -04:00
Jack ee9e8b365c add debug log line 2016-07-26 18:42:51 -04:00
Jack bd6fa35d4a disable verbose dht error 2016-07-26 18:19:40 -04:00
Jack 5e1fdf66b0 fix download problem 2016-07-26 18:18:34 -04:00
Jack d86e709b90 reduce min blob prices 2016-07-26 17:24:59 -04:00
Jack f82cffe882 verbose logging 2016-07-26 17:21:41 -04:00
Jack 3d88eb92c1 change default max fee to $25 2016-07-26 17:21:03 -04:00
Jack 0811ebb52d fix key payment problems 2016-07-26 17:20:51 -04:00
Jack 491d431ea5 remove price updater from daemon 2016-07-26 17:19:26 -04:00
Job Evers‐Meltzer ceeebebcad Merge pull request #106 from lbryio/no-blobs-in-logs
Have TimeoutError hexlify blobs
2016-07-26 14:57:30 -05:00
Job Evers‐Meltzer 04d766aba7 Merge pull request #105 from lbryio/bug-fixes
misc bug fixes and code cleanup
2016-07-26 14:56:50 -05:00
Job Evers‐Meltzer 3b431e180e Merge pull request #98 from lbryio/log-cleanup
Remove datetime.now() from log statements
2016-07-26 14:54:36 -05:00
Job Evers a2eab1577d Have TimeoutError hexlify blobs 2016-07-26 13:54:46 -05:00
Job Evers-Meltzer f8dd3d05dc misc bug fixes and code cleanup 2016-07-26 12:24:25 -05:00
Job Evers-Meltzer 93993e62d6 Fix: Log configuration should not happen when a module is imported
Instead, move the responsibility to the main program. Also,
each module had the same, redundant setup.
2016-07-26 12:01:03 -05:00
Job Evers‐Meltzer 483c88b958 Merge pull request #104 from lbryio/no-print
Remove print line
2016-07-26 11:36:00 -05:00
Job Evers 4a1e846958 Remove print line
This line is responsible for flooding the console with messages like
<_io.BytesIO object at 0x7f9e286e52f0>
2016-07-26 11:34:13 -05:00
Job Evers-Meltzer 927b9afe7c forgot to add the test file 2016-07-26 09:34:00 -05:00
Jack 9e8827f015 resolve name bug 2016-07-25 23:46:18 -04:00
Jack ca45f461ae spelling 2016-07-25 23:42:03 -04:00
Jack 7e5af11c2d fix key fee payment problem 2016-07-25 23:41:26 -04:00
Jack 102436274f USD denominated max_key_fee in settings 2016-07-25 22:46:04 -04:00
Jack 49c26a76b4 remove fee checking from autofetcher script 2016-07-25 22:28:01 -04:00
Jack d469ef7bf2 add googlefinance to requirements 2016-07-25 22:21:38 -04:00
Jack a5374cb876 fix currencies and LBRYFeeFormat 2016-07-25 22:17:31 -04:00
Jack a53e911a0c stop looping call when stop() is called 2016-07-25 21:48:39 -04:00
Jack c4a78a149b LBRYFee things
-move exchange rate updates to wallet, do them every half hour
-add convention checker for fees
-pay BTC or USD denominated key fees in converted LBC amount
2016-07-25 21:45:42 -04:00
Job Evers-Meltzer 3814912adf Move to core.utils and expand to check lbryum too 2016-07-25 16:09:13 -05:00
Jack 75ef652cb3 add googlefinance to setup.py 2016-07-25 17:08:56 -04:00
Job Evers-Meltzer 1eae3fe5dc pylint doesn't like distutils 2016-07-25 14:53:07 -05:00
Job Evers-Meltzer d0bc383a79 bug fix: version comparison is not lexographic.
Use distutils.version to compare version strings.
2016-07-25 12:25:10 -05:00
Job Evers-Meltzer ea5d31b530 OCD: alphabetize and group imports
I'm not the only one:
https://google.github.io/styleguide/pyguide.html?showone=Imports_formatting#Imports_formatting
2016-07-25 12:19:19 -05:00
Job Evers‐Meltzer e56ad19e81 Merge pull request #95 from lbryio/deployment-update
Updates the deployment process and the version check associated with it
2016-07-25 12:10:29 -05:00
Job Evers ed393eb75c Updates the deployment process and the version check associated with it
This commit supports steps 1 and 2 in the new workflow:
1. Change the logic in the daemon to check the github api for the latest release that is not a pre release
2. Change travis to mark all releases as pre release
3. When we are ready to stage a release we push a tag to master. Travis builds the packages and releases them
4. We manually check them
5. Remove the pre release mark when we are happy
2016-07-25 11:13:47 -05:00
Jack 2e2d309d38 BTC/USD denominated fees, metadata revisions 2016-07-25 01:40:26 -04:00
Jack 6bfb33adb2 fix version comparison 2016-07-24 22:03:32 -04:00
Job Evers-Meltzer 05138e1db1 web-ui files are on S3 now 2016-07-22 10:58:37 -05:00
Jack b65402db41 debug line 2016-07-21 16:47:47 -04:00
Jack fbef187400 Merge branch 'master' into metadata-version
# Conflicts:
#	lbrynet/conf.py
#	lbrynet/lbrynet_daemon/LBRYDaemon.py
2016-07-21 16:45:41 -04:00
Jack 25d1b8b9e5 move towards better fees and metadata 2016-07-21 16:11:14 -04:00
Job Evers ec91594083 Remove datetime.now() from log statements 2016-07-21 10:41:26 -05:00
Jack e67f55bd74 disable debug logging 2016-07-20 22:40:55 -04:00
Jack Robison 276a7f9d2a Merge pull request #92 from lbryio/file-uploads
Add support for file uploads (for Publish page)
2016-07-20 22:37:08 -04:00
Jack 4888d7a567 Bump version: 0.3.9 -> 0.3.10 2016-07-20 22:34:16 -04:00
Jack Robison 767f78315b Merge pull request #97 from lbryio/lbryum-catchup
lbryum fixes
2016-07-20 22:33:16 -04:00
Jack 4311b218fb fix auto_connect 2016-07-20 22:13:22 -04:00
Jack 89892042dd remove unused line 2016-07-20 20:57:05 -04:00
Jack a22dfb3864 cleaner logging
from https://github.com/lbryio/lbry/pull/94
2016-07-20 20:56:56 -04:00
Jack f40c42dcf0 Merge branch 'master' into lbryum-catchup 2016-07-20 20:38:42 -04:00
Jack 1d31aa9da3 Bump version: 0.3.8 -> 0.3.9 2016-07-20 20:34:41 -04:00
Jack f999073fb4 revert download refactor
to be re-merged after fixes
2016-07-20 20:34:02 -04:00
Jack 5eb7c64ec3 revert get() refactor 2016-07-20 20:30:57 -04:00
Jack 7e79818555 Revert "Merge branch 'master' into lbryum-catchup"
This reverts commit a51576b250, reversing
changes made to 0bee2689d1.
2016-07-20 20:24:49 -04:00
Jack a51576b250 Merge branch 'master' into lbryum-catchup 2016-07-20 20:17:08 -04:00
Jack 0bee2689d1 download fixes 2016-07-20 20:17:01 -04:00
Jack c232743963 fix LBRYumWallet._do_send_many 2016-07-20 20:13:44 -04:00
Job Evers‐Meltzer c2d5f092b3 Merge pull request #94 from lbryio/logging-reformat-2
use asctime in logging format
2016-07-20 18:41:54 -05:00
Jack 8e8e186de9 Merge branch 'master' into lbryum-catchup 2016-07-20 19:29:11 -04:00
Jack 55f47a2b1b lbryum catchup 2016-07-20 17:32:15 -04:00
Job Evers-Meltzer 5c27b9eb90 use asctime in logging format
Instead of manually adding datetime.now() use
asctime formatter to do it for us.
2016-07-20 07:21:12 -05:00
Job Evers‐Meltzer 1d018533d1 Merge pull request #81 from lbryio/deprecate-lbry-console
deprecate lbry-console script
2016-07-20 07:07:16 -05:00
Job Evers‐Meltzer 34b8841f5c Merge pull request #73 from lbryio/refactor-dl-name
Refactor jsonrpc_get, _download_name, _resolve_name
2016-07-20 07:07:02 -05:00
Alex Liebowitz a54166a27c Add support for file uploads (for Publish page) 2016-07-20 02:36:55 -04:00
Job Evers 4adec39dce Bump version: 0.3.7 -> 0.3.8 2016-07-18 16:00:52 -05:00
Job Evers‐Meltzer e63ae08638 Merge pull request #86 from lbryio/back-to-lbryum
Revert default wallet back to lbryum
2016-07-18 15:33:03 -05:00
Job Evers‐Meltzer f1b4c6a1ec Cache pyobjc (#87)
* cache pyobjc modules as wheels
2016-07-18 14:50:05 -05:00
Job Evers-Meltzer 78b4b3ffa8 revert default wallet back to lbryum 2016-07-18 11:30:21 -05:00
Job Evers‐Meltzer f51fd48cdb Merge pull request #85 from lbryio/update-protobuf
Update protobuf library
2016-07-18 11:26:47 -05:00
Job Evers-Meltzer 9127a816e3 Update protobuf library
Updating to protobuf-v3.0.0b3 because it
fixes a bug here https://github.com/google/protobuf/blob/e841bac4fcf47f809e089a70d5f84ac37b3883df/python/google/protobuf/internal/python_message.py#L59
where six.moves is not always available.
In particular, the system python on OSX has an old version of six
which is without six.moves.
2016-07-18 10:12:49 -05:00
Job Evers-Meltzer 1a5cd9b062 Forget about trying to set a label.
Setting a label also sets the account, but the LBRY app
only looks at the default "" account.  Marking the imported
keys would have been nice, but it doesn't work.
2016-07-18 09:14:50 -05:00
Job Evers-Meltzer a86b4c4e58 bug fix: use sys.exit() not exit() 2016-07-18 08:52:56 -05:00
Job Evers-Meltzer a384960a7b deprecate lbry-console script 2016-07-18 08:45:28 -05:00
Job Evers‐Meltzer 5817b80c94 script to migrate private keys to lbrycrd (#79)
* script to migrate private keys to lbrycrd
* handle compressed keys too
* validate private key actually gets added
* add lbrycrdd and lbrycrd-cli checks
* exit if no wallet path
* move each imported address into the default account
2016-07-17 20:17:42 -05:00
Job Evers-Meltzer 97efd63c99 deprecate lbry-console script 2016-07-17 19:19:00 -05:00
Job Evers-Meltzer 5ebcc01bcc Bump version: 0.3.6 -> 0.3.7 2016-07-17 14:10:11 -05:00
Job Evers‐Meltzer ddcc008ea6 Merge pull request #78 from lbryio/force-wallet
emergency fix: force lbrycrd to be the default wallet
2016-07-17 14:08:41 -05:00
Job Evers-Meltzer 8ec10e2304 emergency fix: force lbrycrd to be the default wallet
Ignore save settings for wallet type and use the default wallet (lbrycrd)
instead.  lbryum can be used but only if specified on the command line.
2016-07-17 13:45:26 -05:00
Job Evers-Meltzer 172f275bc7 Refactor _resolve_name.
Continue using the delegation/helper pattern for the daemon.
2016-07-16 09:24:27 -05:00
Job Evers‐Meltzer 0dac5943bb Merge pull request #74 from llllIHARWINDERIllll/patch-3
Need to have git installed
2016-07-15 13:42:21 -05:00
Jack 2dcd2b13be add LBRYMetadata.py 2016-07-15 14:09:43 -04:00
Harwinder 8743decd17 Need to have git installed.
You cant execute the code that follows after if you havent installed git already.
2016-07-15 20:01:25 +02:00
Job Evers-Meltzer a15d7ca543 Refactor _download_name
Nested functions are the devil, especially ones that
use variables from the outer scope. Refactoring
_download_name to use a helper class helps make
the scoping more explicit and will undoubtably
prevent bugs in the future.

I think this makes _download_name drastically more readable.

Also cleaned up some duplicated code and
made download_directory respect the passed in parameter
instead of being the default.
2016-07-15 12:42:26 -05:00
Job Evers-Meltzer a90029ec50 update doc string 2016-07-15 11:37:04 -05:00
Job Evers-Meltzer 563896b126 fix bug in reveal code 2016-07-15 11:33:38 -05:00
Job Evers-Meltzer 5aecd02668 Refactor jsonrpc_get.
Move parameter handling into its own function and
better use the `.get()` function for dictionaries.

Early return on the failed checks is more readable.

The lambda function in the callback was long and
hard to read so moved it out.
2016-07-15 11:32:46 -05:00
Jeremy Kauffman eef6312a17 Merge pull request #71 from llllIHARWINDERIllll/patch-2
Cant use git if its not installed
2016-07-14 16:26:23 -04:00
Harwinder 1e48f5c8f4 Cant use git if its not installed
First install needed packages then execute the task. Cant run the whole code if git isnt installed :)
2016-07-14 22:25:32 +02:00
Jeremy Kauffman 7908fa2814 Merge pull request #70 from llllIHARWINDERIllll/patch-1
Adding git to linux install command
2016-07-14 16:16:51 -04:00
Harwinder 7ffb3ea042 Added git to linux install command
Some people dont have git installed so adding it to it solves confusion for people new to linux.
2016-07-14 18:41:23 +02:00
Job Evers‐Meltzer 842dd90780 Merge pull request #66 from lbryio/add-tests-blob-handler
add tests for BlobRequestHandler and run on travis
2016-07-14 09:33:06 -05:00
kimihiro64 ee71a03f96 Revert to 2 params as isinstance cannot support 3+ (#69)
* Revert to 2 params as isinstance cannot support 3+

* Use basestring for maximum efficiency
2016-07-13 22:44:02 -05:00
Jack 5221631b40 Bump version: 0.3.5 -> 0.3.6 2016-07-12 17:30:58 -04:00
Job Evers‐Meltzer ade2b4ac0d Merge pull request #68 from lbryio/switch-slack
switch slack notification token
2016-07-12 15:25:21 -05:00
Job Evers-Meltzer 643b95c0e4 switch slack notification token 2016-07-12 14:48:13 -05:00
Jack Robison ed0f9d4fb5 Merge pull request #67 from lbryio/real-lbryum
Real lbryum
2016-07-12 15:35:54 -04:00
Jack 6f353c31cb Merge branch 'master' into real-lbryum 2016-07-11 22:04:32 -04:00
Jack 404412a950 return publish error message 2016-07-11 21:57:34 -04:00
Job Evers‐Meltzer 0e1778d8da Merge pull request #65 from lbryio/add-slack-notifications
add slack notifications to travis
2016-07-11 13:28:56 -05:00
Job Evers-Meltzer dfc0ca9525 change slack key and encrypt it 2016-07-11 12:05:27 -05:00
Job Evers-Meltzer 53bf1fe4fd add send_blob tests 2016-07-10 21:56:00 -05:00
Jack 5c05daa007 update import to new file name 2016-07-10 22:21:50 -04:00
Job Evers-Meltzer f74f075b4e add tests for BlobRequestHandler and run on travis 2016-07-10 18:48:14 -05:00
Jack 1b53e8e98c re-enable lbryum 2016-07-09 13:31:07 -04:00
Job Evers-Meltzer 4caee284bc add slack notifications to travis 2016-07-07 12:06:07 -05:00
Alex Grintsvayg 5368c91399 lbry replaces old lbrynet 2016-07-07 00:18:29 -04:00
Alex Grintsvayg 00b1881f20 dont forget to run bumpversion instead of manually bumping 2016-07-06 22:56:23 -04:00
Jack b727bd20c8 version bump 2016-07-06 22:48:38 -04:00
Jack 5a703c116f linux lbrycrdd path 2016-07-06 22:46:59 -04:00
Alex Grintsvayg 57f728f40e desc update 2016-07-06 22:29:12 -04:00
Alex Grintsvayg 74bbde0c34 fix "launch as root" bug, update package name and maintainer 2016-07-06 21:54:55 -04:00
Alex Liebowitz c58fc0781c Call xdg-open properly in jsonrpc_reveal() 2016-07-06 15:57:00 -04:00
Alex Grintsvayg 7a266d49c1 fix 2016-07-06 15:33:06 -04:00
Alex Grintsvayg 344eeeb8c0 typo 2016-07-06 15:04:41 -04:00
Alex Grintsvayg 08d50ddfc5 bundle lbrycrdd bins instead of downloading them 2016-07-06 14:58:06 -04:00
Alex Grintsvayg f83c892b13 fix lbry symlink, fix icon path, add .desktop file to bumpversion 2016-07-06 14:13:11 -04:00
Alex Grintsvayg 7dbec9d395 typo 2016-07-06 13:41:47 -04:00
Alex Grintsvayg 5171c801d9 add lbry icons, symlink into user path 2016-07-06 13:34:17 -04:00
Alex Grintsvayg 72b4a778a6 dont forget bumpversion 2016-07-06 10:09:40 -04:00
Jack Robison 0254df63f9 Merge pull request #64 from lbryio/check-for-new-ui
Check for new ui periodically
2016-07-06 04:35:06 -04:00
Jack 03c02ff74f lbrycrdd path wierdness 2016-07-06 03:37:31 -04:00
Jack 9277c3c674 add help for when things go wrong 2016-07-06 03:02:55 -04:00
Jack 34b1259dc6 move check for if daemon is running to inside of function 2016-07-06 02:20:18 -04:00
Jack 257e38de12 add command line wrapper for lbrynet-daemon calls 2016-07-06 02:17:38 -04:00
Jack 1984132eae add update_available keys to version()
as to not require making the version string comparison in whatever is
making the daemon call
2016-07-06 01:46:49 -04:00
Jack 8b1d75ea98 check every 30 minutes for a new ui version
-previously the check for a new ui version was only at startup, which
resulted in bugs persisting after they’d been fixed

-add option to skip requirements check

-try to load an existing ui if it can’t be obtained from github
2016-07-06 01:27:25 -04:00
Job Evers‐Meltzer a79af11371 Merge pull request #60 from lbryio/change-make-deb
Use patched version of make-deb
2016-07-05 15:08:42 -05:00
Job Evers 087a9b70b4 Use patched version of make-deb
Ran into a bug in make-deb that fails when there is utf-8 characters
in the git commit message. https://github.com/nylas/make-deb/issues/13.

I wrote a patch to fix the bug and am installing that version until the
make-deb maintainers incorporate it
2016-07-05 14:57:48 -05:00
Alex Grintsvayg 8b37952128 make-deb doesn't like utf8 arrow in commit message 2016-07-05 15:53:51 -04:00
Alex Grintsvayg 8336930091 Bump version: 0.3.2 → 0.3.3 2016-07-05 15:20:35 -04:00
Alex Grintsvayg d875325cee better non-root fix, restore version var 2016-07-05 15:20:30 -04:00
Alex Grintsvayg f1c5d1cb23 Bump version: 0.3.1 → 0.3.2 2016-07-05 14:30:35 -04:00
Alex Grintsvayg b55752e715 add bumpversion script 2016-07-05 14:29:24 -04:00
Alex Grintsvayg 36a99e6ec8 run lbry as non-root user 2016-07-05 14:06:41 -04:00
Jack df3c5b9a77 open conf for write in app 2016-07-04 20:47:43 -04:00
Jack 4c2ab23c1f write to the file that's supposed to be written to 2016-07-04 20:19:04 -04:00
Jack 0a3f81e364 fix download directory not existing problem 2016-07-04 20:02:38 -04:00
Jack 69c5631b25 make lbrycrddpath.conf if it doesnt exist, point to binary in app 2016-07-04 19:53:01 -04:00
Jack cca4331ac4 create lbrycrddpath.conf if it doesnt exist 2016-07-04 19:34:51 -04:00
Alex Grintsvayg 5972dbb6a7 fix lbry init script 2016-07-04 19:18:22 -04:00
Job Evers-Meltzer 794f2d8576 version bump: 0.3.0.2 2016-07-04 16:51:29 -05:00
Alex Liebowitz e35dce530a Set default download dir to ~/Downloads on Linux 2016-07-04 17:49:48 -04:00
Job Evers-Meltzer 6034bd3cb2 version bump: 0.3.0.1 2016-07-04 15:47:12 -05:00
Job Evers‐Meltzer 42c77bbb67 Merge pull request #51 from lbryio/restart-lbrycrd
add a more useful exception if auth fails on lbrycrd
2016-07-04 15:45:44 -05:00
Job Evers‐Meltzer d504c8f4a3 Merge pull request #50 from lbryio/lbrycrd-in-bundle
Add lbrycrd to app bundle on macos
2016-07-04 15:42:24 -05:00
Job Evers-Meltzer 976c8b3ce0 add a more useful exception if auth fails on lbrycrd 2016-07-04 15:40:52 -05:00
Alex Liebowitz 905e7e41a6 Merge branch 'master' of https://github.com/lbryio/lbry 2016-07-04 16:26:35 -04:00
Job Evers-Meltzer 16f48d0400 Add lbrycrd to app bundle on macos 2016-07-04 15:18:08 -05:00
Alex Liebowitz 6d7608d851 Create lbrycrd.conf if needed 2016-07-04 16:16:34 -04:00
Jack 7cd30efbe9 download lbrycrd binaries and set up lbrycrddpath.conf 2016-07-04 08:41:44 -04:00
Jack Robison 8c3652e1ac Merge pull request #49 from lbryio/real-lbrycrd2
real blockchain
2016-07-04 05:48:49 -04:00
Jack 7b9e3aace9 use lbrycrd 2016-07-04 05:43:26 -04:00
Jack 568737e123 change lbryum version constant name 2016-07-04 05:15:53 -04:00
Jack 808e3ea6e3 rename LBRYcrdWallet.py to LBRYWallet.py and change default wallet to lbrycrd 2016-07-04 04:57:30 -04:00
Jack e4f14d871f update setup.py 2016-07-01 03:36:51 -04:00
Jack 1cedd8ee5b update name 2016-07-01 03:16:08 -04:00
Jack b80fe24179 tanstaafl 2016-07-01 02:55:20 -04:00
Jack 3cea41a854 remove lbrynet_gui 2016-07-01 02:42:34 -04:00
Jack 62b80c13cc version bump 2016-06-30 01:26:33 -04:00
Jack 08b612575c update_claim fix and clean up publish keys
-replace ‘value’ key with ‘metadata’

-update claim metadata in db when an update is published
2016-06-28 23:20:28 -04:00
Jack b3b804bf2d add update_name 2016-06-28 14:28:59 -04:00
Jack 09d8a86e30 rename variable 2016-06-28 02:06:04 -04:00
Jack cc5d917c72 download fix 2016-06-28 01:51:05 -04:00
Jack 7cc3e9d5ef publish updates
-adds a base set of metadata fields required for results to be rendered
in conf.py, including language and content-type

-dont support old style claims on the new blockchain
2016-06-27 17:07:59 -04:00
Job Evers‐Meltzer 87aa9fc6c4 Merge pull request #48 from lbryio/add-cache
add caching for travis
2016-06-27 11:50:23 -05:00
Job Evers 8d5c315817 add caching for travis 2016-06-27 11:21:30 -05:00
Jack f89486f5fe port and import name 2016-06-24 13:12:27 -04:00
126 changed files with 5324 additions and 2923 deletions

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
version: 1.0.{build}
notifications:
- provider: Slack
incoming_webhook:
secure: SyfpZAVQA8PEPdjqqc6Yav3i5wNOCFxNcoHx3oJPYSLs13PdDLpSPKPiYJgxTYogspCIFcskc8nMUkXC0s7P8AWCzTKtusjKchd8D+pJR2I=
branches:
only:
- master
- appveyor
clone_folder: c:\projects\lbry
init:
- ps: >-
$env:Path += ";C:\MinGW\bin\"
gcc --version
mingw32-make --version
mkdir C:\temp
Invoke-WebRequest "https://pypi.python.org/packages/55/90/e987e28ed29b571f315afea7d317b6bf4a551e37386b344190cffec60e72/miniupnpc-1.9.tar.gz" -OutFile "C:\temp\miniupnpc-1.9.tar.gz"
cd C:\temp
7z e miniupnpc-1.9.tar.gz
7z x miniupnpc-1.9.tar
cd C:\temp\miniupnpc-1.9
mingw32-make.exe -f Makefile.mingw
C:\Python27\python.exe C:\temp\miniupnpc-1.9\setupmingw32.py build --compiler=mingw32
C:\Python27\python.exe C:\temp\miniupnpc-1.9\setupmingw32.py install
Invoke-WebRequest "https://github.com/lbryio/lbry/raw/master/packaging/windows/libs/gmpy-1.17-cp27-none-win32.whl" -OutFile "C:\temp\gmpy-1.17-cp27-none-win32.whl"
C:\Python27\Scripts\pip.exe install "C:\temp\gmpy-1.17-cp27-none-win32.whl"
C:\Python27\Scripts\pip.exe install pypiwin32==219
C:\Python27\Scripts\pip.exe install six==1.9.0
C:\Python27\Scripts\pip.exe install requests==2.9.1
C:\Python27\Scripts\pip.exe install zope.interface==4.1.3
C:\Python27\Scripts\pip.exe install cx-freeze==4.3.3
C:\Python27\Scripts\pip.exe install cython==0.24.1
C:\Python27\Scripts\pip.exe install Twisted==16.0.0
C:\Python27\Scripts\pip.exe install Yapsy==1.11.223
C:\Python27\Scripts\pip.exe install appdirs==1.4.0
C:\Python27\Scripts\pip.exe install argparse==1.2.1
C:\Python27\Scripts\pip.exe install colorama==0.3.7
C:\Python27\Scripts\pip.exe install dnspython==1.12.0
C:\Python27\Scripts\pip.exe install ecdsa==0.13
C:\Python27\Scripts\pip.exe install jsonrpc==1.2
C:\Python27\Scripts\pip.exe install jsonrpclib==0.1.7
C:\Python27\Scripts\pip.exe install loggly-python-handler==1.0.0
C:\Python27\Scripts\pip.exe install pbkdf2==1.3
C:\Python27\Scripts\pip.exe install protobuf==3.0.0
C:\Python27\Scripts\pip.exe install pycrypto==2.6.1
C:\Python27\Scripts\pip.exe install python-bitcoinrpc==0.1
C:\Python27\Scripts\pip.exe install qrcode==5.2.2
C:\Python27\Scripts\pip.exe install requests_futures==0.9.7
C:\Python27\Scripts\pip.exe install seccure==0.3.1.3
C:\Python27\Scripts\pip.exe install simplejson==3.8.2
C:\Python27\Scripts\pip.exe install slowaes==0.1a1
C:\Python27\Scripts\pip.exe install txJSON-RPC==0.3.1
C:\Python27\Scripts\pip.exe install unqlite==0.5.3
C:\Python27\Scripts\pip.exe install wsgiref==0.1.2
C:\Python27\Scripts\pip.exe install base58==0.2.2
C:\Python27\Scripts\pip.exe install googlefinance==0.7
C:\Python27\Scripts\pip.exe install git+https://github.com/lbryio/lbryum.git
cd C:\projects\lbry
install:
- cmd: C:\Python27\python.exe setup_win32.py install
build_script:
- cmd: C:\Python27\python.exe setup_win32.py build bdist_msi
test_script:
- ps: >-
C:\Python27\Scripts\pip.exe install mock
C:\Python27\Scripts\pip.exe install pylint
C:\Python27\python.exe C:\Python27\Scripts\trial.py C:\projects\lbry\tests
artifacts:
- path: dist/*.msi
name: msi
- path: build/exe.win32-2.7/
name: lbry-portable
- path: packaging/windows/lbry-win32-app/LBRY-URI.reg
name: LBRY-URI
+9
View File
@@ -0,0 +1,9 @@
[bumpversion]
current_version = 0.4.2
commit = True
tag = True
[bumpversion:file:lbrynet/__init__.py]
[bumpversion:file:packaging/ubuntu/lbry.desktop]
+5
View File
@@ -25,3 +25,8 @@ lbrynet.egg-info/PKG-INFO
*.decTest
.coverage
# temporary files from the twisted.trial test runner
_trial_temp/
.DS_Store
+1 -1
View File
@@ -298,7 +298,7 @@ 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=
generated-members=lbrynet.lbrynet_daemon.LBRYDaemon.Parameters
[IMPORTS]
+12
View File
@@ -14,6 +14,16 @@ matrix:
language: generic
osx_image: xcode7.3
notifications:
slack:
secure: "Am13HPtpgCMljh0MDVuoFHvQXB8yhf4Kvf/qAeSp5N0vsHGL70CSF9Ahccw8dVPE6mbuak1OGtSUb6/UaErLHkpz3ztaRLkDa9x7CmBB3Kynnh8oO2VbB7b/2ROULqkhF4VZmAnNfwrQrbC3gs8Sybp261Nyc7y4ww15xDYBrk2fyq4ds2DCaJdRxfJUJFonrZ6KXr3fVaXosO6cjuyS8eRodcmrqsT4cCtinjNTD1hGWoH107E4ObSmpVelxQO193KhNJMRiLlEcVkvYUOqIWBtwdGHbNE/6Yeuq1TXgKJ0KeJWAmW3wTfUYNngGXNAsyCnrhul5TKNevNzfIAQZHvRsczYiWPJV6LtohHT0CcUiCXJtvEPOyahEBfwK3etY/xxFqny7N9OEmpdW2sgsEPNPX2LJynJti2rQA9SuAD1ogR3ZpDy/NXoaAZf8PTdPcuNUMULV9PGG7tVrLBecO/W1qO6hdFxwlLdgqGLxAENZgGp++v/DhPk/WvtmHj7iTbRq0nxaTWyX5uKOn2ADH+k/yfutjv6BsQU9xNyPeZEEtuEpc6X6waiYn/8G9vl9PecvKC5H0MgsZ6asAxmg7mZ3VSMFG7mo8ENeOhSZ0Oz6ZTBILL3wFccZA9uJIq7NWmqC9dRiGiuKXBB62No7sINoHg3114e2xYa9qvNmGg="
cache:
directories:
- $HOME/.cache/pip
- $HOME/Library/Caches/pip
- $TRAVIS_BUILD_DIR/cache/wheel
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./packaging/travis/setup_osx.sh; fi
@@ -35,6 +45,7 @@ deploy:
- provider: releases
file: "${TRAVIS_BUILD_DIR}/`python setup.py --name`_`python setup.py -V`_amd64.deb"
skip_cleanup: true
prerelease: true
on:
tags: true
condition: "$TRAVIS_OS_NAME = linux"
@@ -44,6 +55,7 @@ deploy:
- provider: releases
file: "${TRAVIS_BUILD_DIR}/packaging/osx/lbry-osx-app/`python setup.py --name`.`python setup.py -V`.dmg"
skip_cleanup: true
prerelease: true
on:
tags: true
condition: "$TRAVIS_OS_NAME = osx"
+1 -1
View File
@@ -12,7 +12,7 @@ You can install LBRY command line by running `curl -sL https://rawgit.com/lbryio
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
sudo apt-get install libgmp3-dev build-essential python2.7 python2.7-dev python-pip git
git clone https://github.com/lbryio/lbry.git
cd lbry
sudo python setup.py install
+4 -4
View File
@@ -1,10 +1,10 @@
#### Installing the LBRY app
--------------------------
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).
Installing LBRY is simple. You can get a dmg installer for OS X or a .deb for linux [here](https://github.com/lbryio/lbry/releases/latest).
##### 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.
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 and the browser will open to the UI.
##### 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.
@@ -17,13 +17,13 @@ On both systems you can also open the UI while the app is running by going to lb
--------------------------
##### 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.
You can install LBRY command line by running `curl -sL https://raw.githubusercontent.com/lbryio/lbry/master/packaging/osx/install_lbry_source.sh | sudo bash` in a terminal. This script will install lbrynet and its dependencies. You can start LBRY 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
sudo apt-get install libgmp3-dev build-essential python2.7 python2.7-dev python-pip git
git clone https://github.com/lbryio/lbry.git
cd lbry
sudo python setup.py install
-1
View File
@@ -1,2 +1 @@
include lbrynet/lbrynet_console/plugins/blindrepeater.yapsy-plugin
recursive-include lbrynet/lbrynet_gui *.gif *.ico *.xbm *.conf
+1 -1
View File
@@ -43,9 +43,9 @@ To stop lbrynet-console, enter the command 'exit'.
Note: this process takes upwards of an hour and is not necessary to use lbrynet.
```
sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev libboost-all-dev libdb-dev libdb++-dev libqt4-dev libprotobuf-dev protobuf-compiler git
git clone --depth=1 -b alpha https://github.com/lbryio/lbrycrd.git
cd lbrycrd
sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev libboost-all-dev libdb-dev libdb++-dev libqt4-dev libprotobuf-dev protobuf-compiler
./autogen.sh
./configure --with-incompatible-bdb --without-gui
+2 -8
View File
@@ -1,8 +1,2 @@
import logging
log = logging.getLogger(__name__)
logging.getLogger(__name__).addHandler(logging.NullHandler())
log.setLevel(logging.ERROR)
version = (0, 2, 5)
__version__ = ".".join([str(x) for x in version])
__version__ = "0.4.2"
version = tuple(__version__.split('.'))
+2
View File
@@ -0,0 +1,2 @@
from events import *
from api import AnalyticsApi as Api
+71
View File
@@ -0,0 +1,71 @@
import functools
import json
import logging
from requests import auth
from requests_futures import sessions
from lbrynet import conf
from lbrynet.analytics import utils
log = logging.getLogger(__name__)
def log_response(fn):
def _log(future):
if future.cancelled():
log.warning('Request was unexpectedly cancelled')
else:
response = future.result()
log.debug('Response (%s): %s', response.status_code, response.content)
@functools.wraps(fn)
def wrapper(*args, **kwargs):
future = fn(*args, **kwargs)
future.add_done_callback(_log)
return future
return wrapper
class AnalyticsApi(object):
def __init__(self, session, url, write_key):
self.session = session
self.url = url
self.write_key = write_key
@property
def auth(self):
return auth.HTTPBasicAuth(self.write_key, '')
@log_response
def batch(self, events):
"""Send multiple events in one request.
Each event needs to have its type specified.
"""
data = json.dumps({
'batch': events,
'sentAt': utils.now(),
})
log.debug('sending %s events', len(events))
log.debug('Data: %s', data)
return self.session.post(self.url + '/batch', json=data, auth=self.auth)
@log_response
def track(self, event):
"""Send a single tracking event"""
log.debug('Sending track event: %s', event)
import base64
return self.session.post(self.url + '/track', json=event, auth=self.auth)
@classmethod
def load(cls, session=None):
"""Initialize an instance using values from lbry.io."""
if not session:
session = sessions.FuturesSession()
return cls(
session,
conf.ANALYTICS_ENDPOINT,
utils.deobfuscate(conf.ANALYTICS_TOKEN)
)
+47
View File
@@ -0,0 +1,47 @@
from lbrynet.analytics import utils
class Events(object):
def __init__(self, context, lbry_id, session_id):
self.context = context
self.lbry_id = lbry_id
self.session_id = session_id
def heartbeat(self):
return {
'userId': 'lbry',
'event': 'Heartbeat',
'properties': {
'lbry_id': self.lbry_id,
'session_id': self.session_id
},
'context': self.context,
'timestamp': utils.now()
}
def make_context(platform, wallet, is_dev=False):
# TODO: distinguish between developer and release instances
return {
'is_dev': is_dev,
'app': {
'name': 'lbrynet',
'version': platform['lbrynet_version'],
'ui_version': platform['ui_version'],
'python_version': platform['python_version'],
'wallet': {
'name': wallet,
# TODO: add in version info for lbrycrdd
'version': platform['lbryum_version'] if wallet == 'lbryum' else None
},
},
# TODO: expand os info to give linux/osx specific info
'os': {
'name': platform['os_system'],
'version': platform['os_release']
},
'library': {
'name': 'lbrynet-analytics',
'version': '1.0.0'
},
}
+8
View File
@@ -0,0 +1,8 @@
import datetime
from lbrynet.core.utils import *
def now():
"""Return utc now in isoformat with timezone"""
return datetime.datetime.utcnow().isoformat() + 'Z'
+35 -6
View File
@@ -1,8 +1,11 @@
"""
Some network wide and also application specific parameters
"""
import os
IS_DEVELOPMENT_VERSION = False
MAX_HANDSHAKE_SIZE = 2**16
MAX_REQUEST_SIZE = 2**16
MAX_BLOB_REQUEST_SIZE = 2**16
@@ -10,6 +13,7 @@ MAX_RESPONSE_INFO_SIZE = 2**16
MAX_BLOB_INFOS_TO_REQUEST = 20
BLOBFILES_DIR = ".blobfiles"
BLOB_SIZE = 2**21
MIN_BLOB_DATA_PAYMENT_RATE = .005 # points/megabyte
MIN_BLOB_INFO_PAYMENT_RATE = .02 # points/1000 infos
MIN_VALUABLE_BLOB_INFO_PAYMENT_RATE = .05 # points/1000 infos
@@ -17,13 +21,22 @@ MIN_VALUABLE_BLOB_HASH_PAYMENT_RATE = .05 # points/1000 infos
MAX_CONNECTIONS_PER_STREAM = 5
KNOWN_DHT_NODES = [('104.236.42.182', 4000),
('lbryum1.lbry.io', 4444),
('lbryum2.lbry.io', 4444),
('lbryum3.lbry.io', 4444)]
('lbrynet1.lbry.io', 4444),
('lbrynet2.lbry.io', 4444),
('lbrynet3.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'
if IS_DEVELOPMENT_VERSION:
SEARCH_SERVERS = ["http://107.170.207.64:50005"]
else:
SEARCH_SERVERS = ["http://lighthouse1.lbry.io:50005",
"http://lighthouse2.lbry.io:50005",
"http://lighthouse3.lbry.io:50005"]
REFLECTOR_SERVERS = [("reflector.lbry.io", 5566)]
LOG_FILE_NAME = "lbrynet.log"
LOG_POST_URL = "https://lbry.io/log-upload"
@@ -32,17 +45,33 @@ CRYPTSD_FILE_EXTENSION = ".cryptsd"
API_INTERFACE = "localhost"
API_ADDRESS = "lbryapi"
API_PORT = 5279
ICON_PATH = "app.icns"
if os.name == "nt":
ICON_PATH = "icons"
else:
ICON_PATH = "app.icns"
APP_NAME = "LBRY"
API_CONNECTION_STRING = "http://%s:%i/%s" % (API_INTERFACE, API_PORT, API_ADDRESS)
UI_ADDRESS = "http://" + API_INTERFACE + ":" + str(API_PORT)
UI_ADDRESS = "http://%s:%i" % (API_INTERFACE, 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_MAX_KEY_FEE = {'USD': {'amount': 25.0, 'address': ''}}
DEFAULT_SEARCH_TIMEOUT = 3.0
DEFAULT_SD_DOWNLOAD_TIMEOUT = 3
DEFAULT_CACHE_TIME = 3600
DEFAULT_UI_BRANCH = "master"
SOURCE_TYPES = ['lbry_sd_hash', 'url', 'btih']
CURRENCIES = {
'BTC': {'type': 'crypto'},
'LBC': {'type': 'crypto'},
'USD': {'type': 'fiat'},
}
LOGGLY_TOKEN = 'LJEzATH4AzRgAwxjAP00LwZ2YGx3MwVgZTMuBQZ3MQuxLmOv'
ANALYTICS_ENDPOINT = 'https://api.segment.io/v1'
ANALYTICS_TOKEN = 'Ax5LZzR1o3q3Z3WjATASDwR5rKyHH0qOIRIbLmMXn2H='
+13 -1
View File
@@ -67,6 +67,9 @@ class BlobManager(DHTHashSupplier):
def blob_paid_for(self, blob_hash, amount):
pass
def get_all_verified_blobs(self):
pass
class DiskBlobManager(BlobManager):
"""This class stores blobs on the hard disk"""
@@ -78,7 +81,7 @@ class DiskBlobManager(BlobManager):
self.blob_type = BlobFile
self.blob_creator_type = BlobFileCreator
self.blobs = {}
self.blob_hashes_to_delete = {} # {blob_hash: being_deleted (True/False)}
self.blob_hashes_to_delete = {} # {blob_hash: being_deleted (True/False)}
self._next_manage_call = None
def setup(self):
@@ -177,6 +180,11 @@ class DiskBlobManager(BlobManager):
def check_consistency(self):
return self._check_consistency()
def get_all_verified_blobs(self):
d = self._get_all_verified_blob_hashes()
d.addCallback(self.completed_blobs)
return d
def _manage(self):
from twisted.internet import reactor
@@ -462,6 +470,10 @@ class TempBlobManager(BlobManager):
blobs = [b.blob_hash for b in self.blobs.itervalues() if b.blob_hash in blobs_to_check and b.is_validated()]
return defer.succeed(blobs)
def get_all_verified_blobs(self):
d = self.completed_blobs(self.blobs)
return d
def hashes_to_announce(self):
now = time.time()
blobs = [blob_hash for blob_hash, announce_time in self.blob_next_announces.iteritems() if announce_time < now]
+12
View File
@@ -22,6 +22,10 @@ class ConnectionClosedBeforeResponseError(Exception):
pass
class KeyFeeAboveMaxAllowed(Exception):
pass
class UnknownNameError(Exception):
def __init__(self, name):
self.name = name
@@ -30,6 +34,14 @@ class UnknownNameError(Exception):
return repr(self.name)
class InvalidNameError(Exception):
def __init__(self, name):
self.name = name
def __str__(self):
return repr(self.name)
class UnknownStreamTypeError(Exception):
def __init__(self, stream_type):
self.stream_type = stream_type
@@ -1,15 +1,11 @@
import sys
from lbrynet.interfaces import IRequestCreator, IQueryHandlerFactory, IQueryHandler, ILBRYWallet
from lbrynet.core.client.ClientRequest import ClientRequest
from lbrynet.core.Error import UnknownNameError, InvalidStreamInfoError, RequestCanceledError
from lbrynet.core.Error import InsufficientFundsError
from lbrynet.core.sqlite_helpers import rerun_if_locked
from lbryum import SimpleConfig, Network
from lbryum.bitcoin import COIN, TYPE_ADDRESS
from lbryum.wallet import WalletStorage, Wallet
from lbryum.commands import known_commands, Commands
from lbryum.transaction import Transaction
import datetime
import logging
import json
import subprocess
import socket
import time
import os
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from twisted.internet import threads, reactor, defer, task
@@ -18,13 +14,18 @@ from twisted.enterprise import adbapi
from collections import defaultdict, deque
from zope.interface import implements
from decimal import Decimal
import datetime
import logging
import json
import subprocess
import socket
import time
import os
from lbryum import SimpleConfig, Network
from lbryum.lbrycrd import COIN
from lbryum.wallet import WalletStorage, Wallet
from lbryum.commands import known_commands, Commands
from lbryum.transaction import Transaction
from lbrynet.interfaces import IRequestCreator, IQueryHandlerFactory, IQueryHandler, ILBRYWallet
from lbrynet.core.client.ClientRequest import ClientRequest
from lbrynet.core.Error import UnknownNameError, InvalidStreamInfoError, RequestCanceledError
from lbrynet.core.Error import InsufficientFundsError
from lbrynet.metadata.LBRYMetadata import Metadata
log = logging.getLogger(__name__)
alert = logging.getLogger("lbryalert." + __name__)
@@ -55,7 +56,6 @@ class LBRYWallet(object):
_FIRST_RUN_NO = 2
def __init__(self, db_dir):
self.db_dir = db_dir
self.db = None
self.next_manage_call = None
@@ -86,6 +86,7 @@ class LBRYWallet(object):
return True
d = self._open_db()
d.addCallback(lambda _: self._clean_bad_records())
d.addCallback(lambda _: self._start())
d.addCallback(lambda _: start_manage())
return d
@@ -97,6 +98,7 @@ class LBRYWallet(object):
def stop(self):
self.stopped = True
# If self.next_manage_call is None, then manage is currently running or else
# start has not been called, so set stopped and do nothing else.
if self.next_manage_call is not None:
@@ -287,7 +289,7 @@ class LBRYWallet(object):
d = self._do_send_many(payments_to_send)
d.addCallback(lambda txid: log.debug("Sent transaction %s", txid))
return d
log.info("There were no payments to send")
log.debug("There were no payments to send")
return defer.succeed(True)
def get_stream_info_for_name(self, name):
@@ -315,75 +317,135 @@ class LBRYWallet(object):
return d
def _get_stream_info_from_value(self, result, name):
r_dict = {}
if 'value' in result:
value = result['value']
try:
value_dict = json.loads(value)
except (ValueError, TypeError):
return Failure(InvalidStreamInfoError(name))
known_fields = ['stream_hash', 'name', 'description', 'key_fee', 'key_fee_address', 'thumbnail',
'content_license', 'sources', 'fee', 'author']
known_sources = ['lbry_sd_hash', 'btih', 'url']
known_fee_types = {'LBC': ['amount', 'address']}
for field in known_fields:
if field in value_dict:
if field == 'sources':
for source in known_sources:
if source in value_dict[field]:
if source == 'lbry_sd_hash':
r_dict['stream_hash'] = value_dict[field][source]
else:
r_dict[source] = value_dict[field][source]
elif field == 'fee':
fee = value_dict['fee']
if 'type' in fee:
if fee['type'] in known_fee_types:
fee_fields = known_fee_types[fee['type']]
if all([f in fee for f in fee_fields]):
r_dict['key_fee'] = fee['amount']
r_dict['key_fee_address'] = fee['address']
else:
for f in ['key_fee', 'key_fee_address']:
if f in r_dict:
del r_dict[f]
else:
r_dict[field] = value_dict[field]
if 'stream_hash' in r_dict and 'txid' in result:
d = self._save_name_metadata(name, r_dict['stream_hash'], str(result['txid']))
else:
d = defer.succeed(True)
d.addCallback(lambda _: r_dict)
return d
elif 'error' in result:
def _check_result_fields(r):
for k in ['value', 'txid', 'n', 'height', 'amount']:
assert k in r, "getvalueforname response missing field %s" % k
def _log_success(claim_id):
log.info("lbry://%s complies with %s, claimid: %s", name, metadata.version, claim_id)
return defer.succeed(None)
if 'error' in result:
log.warning("Got an error looking up a name: %s", result['error'])
return Failure(UnknownNameError(name))
return Failure(UnknownNameError(name))
def claim_name(self, name, sd_hash, amount, description=None, key_fee=None,
key_fee_address=None, thumbnail=None, content_license=None, author=None, sources=None):
value = {"sources": {'lbry_sd_hash': sd_hash}}
if description is not None:
value['description'] = description
if key_fee is not None and key_fee_address is not None:
value['fee'] = {'type': 'LBC', 'amount': key_fee, 'address': key_fee_address}
if thumbnail is not None:
value['thumbnail'] = thumbnail
if content_license is not None:
value['content_license'] = content_license
if author is not None:
value['author'] = author
if isinstance(sources, dict):
sources['lbry_sd_hash'] = sd_hash
value['sources'] = sources
_check_result_fields(result)
d = self._send_name_claim(name, json.dumps(value), amount)
try:
metadata = Metadata(json.loads(result['value']))
except (ValueError, TypeError):
return Failure(InvalidStreamInfoError(name))
def _save_metadata(txid):
d = self._save_name_metadata(name, sd_hash, txid)
txid = result['txid']
sd_hash = metadata['sources']['lbry_sd_hash']
d = self._save_name_metadata(name, txid, sd_hash)
d.addCallback(lambda _: self.get_claimid(name, txid))
d.addCallback(lambda cid: _log_success(cid))
d.addCallback(lambda _: metadata)
return d
def get_claim(self, name, claim_id):
d = self.get_claims_for_name(name)
d.addCallback(lambda claims: next(claim for claim in claims['claims'] if claim['claimId'] == claim_id))
return d
def get_claimid(self, name, txid):
def _get_id_for_return(claim_id):
if claim_id:
return defer.succeed(claim_id)
else:
d = self.get_claims_from_tx(txid)
d.addCallback(lambda claims: next(c['claimId'] for c in claims if c['name'] == name))
d.addCallback(lambda cid: self._update_claimid(cid, name, txid))
return d
d = self._get_claimid_for_tx(name, txid)
d.addCallback(_get_id_for_return)
return d
def get_claim_info(self, name, txid=None):
if not txid:
d = self._get_value_for_name(name)
d.addCallback(lambda r: self._get_claim_info(name, r['txid']))
else:
d = self._get_claim_info(name, txid)
d.addErrback(lambda _: False)
return d
def _get_claim_info(self, name, txid):
def _build_response(claim):
result = {}
try:
metadata = Metadata(json.loads(claim['value']))
meta_ver = metadata.version
sd_hash = metadata['sources']['lbry_sd_hash']
d = self._save_name_metadata(name, txid, sd_hash)
except AssertionError:
metadata = claim['value']
meta_ver = "Non-compliant"
d = defer.succeed(None)
claim_id = claim['claimId']
result['claim_id'] = claim_id
result['amount'] = claim['nEffectiveAmount']
result['height'] = claim['nHeight']
result['name'] = name
result['txid'] = txid
result['value'] = metadata
result['supports'] = [{'txid': support['txid'], 'n': support['n']} for support in claim['supports']]
result['meta_version'] = meta_ver
log.info("get claim info lbry://%s metadata: %s, claimid: %s", name, meta_ver, claim_id)
d.addCallback(lambda _: self.get_name_claims())
d.addCallback(lambda r: [c['txid'] for c in r])
d.addCallback(lambda my_claims: _add_is_mine(result, my_claims))
return d
def _add_is_mine(response, my_txs):
response['is_mine'] = response['txid'] in my_txs
return response
d = self.get_claimid(name, txid)
d.addCallback(lambda claim_id: self.get_claim(name, claim_id))
d.addCallback(_build_response)
return d
def get_claims_for_name(self, name):
d = self._get_claims_for_name(name)
return d
def update_metadata(self, new_metadata, old_metadata):
meta_for_return = old_metadata if isinstance(old_metadata, dict) else {}
for k in new_metadata:
meta_for_return[k] = new_metadata[k]
return defer.succeed(Metadata(meta_for_return))
def claim_name(self, name, bid, m):
def _save_metadata(txid, metadata):
log.info("Saving metadata for claim %s" % txid)
d = self._save_name_metadata(name, txid, metadata['sources']['lbry_sd_hash'])
d.addCallback(lambda _: txid)
return d
d.addCallback(_save_metadata)
def _claim_or_update(claim, metadata, _bid):
if not claim:
log.info("No claim yet, making a new one")
return self._send_name_claim(name, metadata, _bid)
if not claim['is_mine']:
log.info("Making a contesting claim")
return self._send_name_claim(name, metadata, _bid)
else:
log.info("Updating over own claim")
d = self.update_metadata(metadata, claim['value'])
d.addCallback(lambda new_metadata: self._send_name_claim_update(name, claim['claim_id'], claim['txid'], new_metadata, _bid))
return d
meta = Metadata(m)
d = self.get_claim_info(name)
d.addCallback(lambda claim: _claim_or_update(claim, meta, bid))
d.addCallback(lambda txid: _save_metadata(txid, meta))
return d
def abandon_name(self, txid):
@@ -409,7 +471,7 @@ class LBRYWallet(object):
def abandon(results):
if results[0][0] and results[1][0]:
address = results[0][1]
amount = results[1][1]
amount = float(results[1][1])
return self._send_abandon(txid, address, amount)
elif results[0][0] is False:
return defer.fail(Failure(ValueError("Couldn't get a new address")))
@@ -419,13 +481,40 @@ class LBRYWallet(object):
dl.addCallback(abandon)
return dl
def support_claim(self, name, claim_id, amount):
return self._support_claim(name, claim_id, amount)
def get_tx(self, txid):
d = self._get_raw_tx(txid)
d.addCallback(self._get_decoded_tx)
return d
# def update_name(self, name_value):
# return self._update_name(name_value)
def get_history(self):
d = self._get_history()
return d
def get_tx_json(self, txid):
def _decode(raw_tx):
tx = Transaction(raw_tx).deserialize()
decoded_tx = {}
for txkey in tx.keys():
if isinstance(tx[txkey], list):
decoded_tx[txkey] = []
for i in tx[txkey]:
tmp = {}
for k in i.keys():
if isinstance(i[k], Decimal):
tmp[k] = float(i[k] / 1e8)
else:
tmp[k] = i[k]
decoded_tx[txkey].append(tmp)
else:
decoded_tx[txkey] = tx[txkey]
return decoded_tx
d = self._get_raw_tx(txid)
d.addCallback(_decode)
return d
def get_name_and_validity_for_sd_hash(self, sd_hash):
d = self._get_claim_metadata_for_sd_hash(sd_hash)
@@ -529,21 +618,45 @@ class LBRYWallet(object):
def _open_db(self):
self.db = adbapi.ConnectionPool('sqlite3', os.path.join(self.db_dir, "blockchainname.db"),
check_same_thread=False)
return self.db.runQuery("create table if not exists name_metadata (" +
def create_tables(transaction):
transaction.execute("create table if not exists name_metadata (" +
" name text, " +
" txid text, " +
" sd_hash text)")
transaction.execute("create table if not exists claim_ids (" +
" claimId text, " +
" name text, " +
" txid text)")
def _save_name_metadata(self, name, sd_hash, txid):
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 self.db.runInteraction(create_tables)
def _clean_bad_records(self):
d = self.db.runQuery("delete from name_metadata where length(txid) > 64 or txid is null")
return d
def _save_name_metadata(self, name, txid, sd_hash):
assert len(txid) == 64, "That's not a txid: %s" % str(txid)
d = self.db.runQuery("delete from name_metadata where name=? and txid=? and sd_hash=?", (name, txid, sd_hash))
d.addCallback(lambda _: self.db.runQuery("insert into name_metadata values (?, ?, ?)", (name, txid, sd_hash)))
return d
def _get_claim_metadata_for_sd_hash(self, sd_hash):
d = self.db.runQuery("select name, txid from name_metadata where sd_hash=?", (sd_hash,))
d.addCallback(lambda r: r[0] if len(r) else None)
d.addCallback(lambda r: r[0] if r else None)
return d
def _update_claimid(self, claim_id, name, txid):
assert len(txid) == 64, "That's not a txid: %s" % str(txid)
d = self.db.runQuery("delete from claim_ids where claimId=? and name=? and txid=?", (claim_id, name, txid))
d.addCallback(lambda r: self.db.runQuery("insert into claim_ids values (?, ?, ?)", (claim_id, name, txid)))
d.addCallback(lambda _: claim_id)
return d
def _get_claimid_for_tx(self, name, txid):
assert len(txid) == 64, "That's not a txid: %s" % str(txid)
d = self.db.runQuery("select claimId from claim_ids where name=? and txid=?", (name, txid))
d.addCallback(lambda r: r[0][0] if r else None)
return d
######### Must be overridden #########
@@ -566,6 +679,9 @@ class LBRYWallet(object):
def get_name_claims(self):
return defer.fail(NotImplementedError())
def _get_claims_for_name(self, name):
return defer.fail(NotImplementedError())
def _check_first_run(self):
return defer.fail(NotImplementedError())
@@ -581,6 +697,12 @@ class LBRYWallet(object):
def _send_abandon(self, txid, address, amount):
return defer.fail(NotImplementedError())
def _send_name_claim_update(self, name, claim_id, txid, value, amount):
return defer.fail(NotImplementedError())
def _support_claim(self, name, claim_id, amount):
return defer.fail(NotImplementedError())
def _do_send_many(self, payments_to_send):
return defer.fail(NotImplementedError())
@@ -593,6 +715,9 @@ class LBRYWallet(object):
def _get_balance_for_address(self, address):
return defer.fail(NotImplementedError())
def _get_history(self):
return defer.fail(NotImplementedError())
def _start(self):
pass
@@ -634,8 +759,8 @@ class LBRYcrdWallet(LBRYWallet):
def _get_rpc_conf(self):
settings = {"username": "rpcuser",
"password": "rpcpassword",
"rpc_port": 8332}
if os.path.exists(self.wallet_conf):
"rpc_port": 9245}
if self.wallet_conf and os.path.exists(self.wallet_conf):
conf = open(self.wallet_conf)
for l in conf:
if l.startswith("rpcuser="):
@@ -713,12 +838,24 @@ class LBRYcrdWallet(LBRYWallet):
def _send_abandon(self, txid, address, amount):
return threads.deferToThread(self._send_abandon_rpc, txid, address, amount)
def _send_name_claim_update(self, name, claim_id, txid, value, amount):
return threads.deferToThread(self._update_name_rpc, txid, value, amount)
def _support_claim(self, name, claim_id, amount):
return threads.deferToThread(self._support_claim_rpc, name, claim_id, amount)
def _get_claims_for_name(self, name):
return threads.deferToThread(self._get_claims_for_name_rpc, name)
def get_claims_from_tx(self, txid):
return threads.deferToThread(self._get_claims_from_tx_rpc, txid)
def _get_value_for_name(self, name):
return threads.deferToThread(self._get_value_for_name_rpc, name)
def _get_history(self):
return threads.deferToThread(self._list_transactions_rpc)
def _get_rpc_conn(self):
return AuthServiceProxy(self.rpc_conn_string)
@@ -727,7 +864,11 @@ class LBRYcrdWallet(LBRYWallet):
tries = 0
try:
rpc_conn = self._get_rpc_conn()
rpc_conn.getinfo()
try:
rpc_conn.getinfo()
except ValueError:
log.exception('Failed to get rpc info. Rethrowing with a hopefully more useful error message')
raise Exception('Failed to get rpc info from lbrycrdd. Try restarting lbrycrdd')
log.info("lbrycrdd was already running when LBRYcrdWallet was started.")
return
except (socket.error, JSONRPCException):
@@ -826,7 +967,7 @@ class LBRYcrdWallet(LBRYWallet):
@_catch_connection_error
def _send_abandon_rpc(self, txid, address, amount):
rpc_conn = self._get_rpc_conn()
return rpc_conn.abandonname(txid, address, amount)
return rpc_conn.abandonclaim(txid, address, amount)
@_catch_connection_error
def _get_blockchain_info_rpc(self):
@@ -843,10 +984,15 @@ class LBRYcrdWallet(LBRYWallet):
rpc_conn = self._get_rpc_conn()
return rpc_conn.getclaimsfortx(txid)
@_catch_connection_error
def _get_claims_for_name_rpc(self, name):
rpc_conn = self._get_rpc_conn()
return rpc_conn.getclaimsforname(name)
@_catch_connection_error
def _get_nametrie_rpc(self):
rpc_conn = self._get_rpc_conn()
return rpc_conn.getnametrie()
return rpc_conn.getclaimtrie()
@_catch_connection_error
def _get_wallet_balance_rpc(self):
@@ -863,21 +1009,27 @@ class LBRYcrdWallet(LBRYWallet):
rpc_conn = self._get_rpc_conn()
return rpc_conn.getvalueforname(name)
# def _update_name_rpc(self, name_value):
# rpc_conn = self._get_rpc_conn()
# return rpc_conn.updatename(name_value)
@_catch_connection_error
def _update_name_rpc(self, txid, value, amount):
rpc_conn = self._get_rpc_conn()
return rpc_conn.updateclaim(txid, json.dumps(value), amount)
@_catch_connection_error
def _send_name_claim_rpc(self, name, value, amount):
rpc_conn = self._get_rpc_conn()
try:
return str(rpc_conn.claimname(name, value, amount))
return str(rpc_conn.claimname(name, json.dumps(value), amount))
except JSONRPCException as e:
if 'message' in e.error and e.error['message'] == "Insufficient funds":
raise InsufficientFundsError()
elif 'message' in e.error:
raise ValueError(e.error['message'])
@_catch_connection_error
def _support_claim_rpc(self, name, claim_id, amount):
rpc_conn = self._get_rpc_conn()
return rpc_conn.supportclaim(name, claim_id, amount)
@_catch_connection_error
def _get_num_addresses_rpc(self):
rpc_conn = self._get_rpc_conn()
@@ -888,6 +1040,11 @@ class LBRYcrdWallet(LBRYWallet):
rpc_conn = self._get_rpc_conn()
return rpc_conn.getbestblockhash()
@_catch_connection_error
def _list_transactions_rpc(self):
rpc_conn = self._get_rpc_conn()
return rpc_conn.listtransactions()
@_catch_connection_error
def _stop_rpc(self):
# check if our lbrycrdd is actually running, or if we connected to one that was already
@@ -921,7 +1078,7 @@ class LBRYumWallet(LBRYWallet):
network_start_d = defer.Deferred()
def setup_network():
self.config = SimpleConfig()
self.config = SimpleConfig({'auto_connect': True})
self.network = Network(self.config)
alert.info("Loading the wallet...")
return defer.succeed(self.network.start())
@@ -993,7 +1150,7 @@ class LBRYumWallet(LBRYWallet):
blockchain_caught_d = defer.Deferred()
def check_caught_up():
local_height = self.network.get_local_height()
local_height = self.network.get_catchup_progress()
remote_height = self.network.get_server_height()
if remote_height != 0 and remote_height - local_height <= 5:
@@ -1085,12 +1242,31 @@ class LBRYumWallet(LBRYWallet):
def send_claim(address):
cmd = known_commands['claimname']
func = getattr(self.cmd_runner, cmd.name)
return threads.deferToThread(func, address, amount, name, val)
return threads.deferToThread(func, address, amount, name, json.dumps(val))
d = self.get_new_address()
d.addCallback(send_claim)
d.addCallback(self._broadcast_transaction)
return d
def _get_claims_for_name(self, name):
cmd = known_commands['getclaimsforname']
func = getattr(self.cmd_runner, cmd.name)
return threads.deferToThread(func, name)
def _send_name_claim_update(self, name, claim_id, txid, value, amount):
def send_claim_update(address):
decoded_claim_id = claim_id.decode('hex')[::-1]
metadata = json.dumps(value)
log.info("updateclaim %s %s %f %s %s '%s'", txid, address, amount, name, decoded_claim_id.encode('hex'), metadata)
cmd = known_commands['updateclaim']
func = getattr(self.cmd_runner, cmd.name)
return threads.deferToThread(func, txid, address, amount, name, decoded_claim_id, metadata)
d = self.get_new_address()
d.addCallback(send_claim_update)
d.addCallback(self._broadcast_transaction)
return d
def _get_decoded_tx(self, raw_tx):
tx = Transaction(raw_tx)
decoded_tx = {}
@@ -1102,28 +1278,41 @@ class LBRYumWallet(LBRYWallet):
return decoded_tx
def _send_abandon(self, txid, address, amount):
log.info("Abandon " + str(txid) + " " + str(address) + " " + str(amount))
log.info("Abandon %s %s %f" % (txid, address, amount))
cmd = known_commands['abandonclaim']
func = getattr(self.cmd_runner, cmd.name)
d = threads.deferToThread(func, txid, address, amount)
d.addCallback(self._broadcast_transaction)
return d
def _support_claim(self, name, claim_id, amount):
def _send_support(d, a, n, c):
cmd = known_commands['supportclaim']
func = getattr(self.cmd_runner, cmd.name)
d = threads.deferToThread(func, d, a, n, c)
return d
d = self.get_new_address()
d.addCallback(lambda address: _send_support(address, amount, name, claim_id))
d.addCallback(self._broadcast_transaction)
return d
def _broadcast_transaction(self, raw_tx):
log.info("Broadcast: " + str(raw_tx))
def _log_tx(r):
log.info("Broadcast tx: %s", r)
return r
cmd = known_commands['broadcast']
func = getattr(self.cmd_runner, cmd.name)
d = threads.deferToThread(func, raw_tx)
d.addCallback(_log_tx)
d.addCallback(lambda r: r if len(r) == 64 else defer.fail(Exception("Transaction rejected")))
d.addCallback(self._save_wallet)
return d
def _do_send_many(self, payments_to_send):
log.warning("Doing send many. payments to send: %s", str(payments_to_send))
outputs = [(TYPE_ADDRESS, address, int(amount*COIN)) for address, amount in payments_to_send.iteritems()]
d = threads.deferToThread(self.wallet.mktx, outputs, None, self.config)
d.addCallback(lambda tx: threads.deferToThread(self.wallet.sendtx, tx))
d.addCallback(self._save_wallet)
return d
cmd = known_commands['paytomanyandsend']
func = getattr(self.cmd_runner, cmd.name)
return threads.deferToThread(func, payments_to_send.iteritems())
def _get_value_for_name(self, name):
cmd = known_commands['getvalueforname']
@@ -1143,34 +1332,11 @@ class LBRYumWallet(LBRYWallet):
func = getattr(self.cmd_runner, cmd.name)
return threads.deferToThread(func)
def get_history(self):
def _get_history(self):
cmd = known_commands['history']
func = getattr(self.cmd_runner, cmd.name)
return threads.deferToThread(func)
def get_tx_json(self, txid):
def _decode(raw_tx):
tx = Transaction(raw_tx).deserialize()
decoded_tx = {}
for txkey in tx.keys():
if isinstance(tx[txkey], list):
decoded_tx[txkey] = []
for i in tx[txkey]:
tmp = {}
for k in i.keys():
if isinstance(i[k], Decimal):
tmp[k] = float(i[k] / 1e8)
else:
tmp[k] = i[k]
decoded_tx[txkey].append(tmp)
else:
decoded_tx[txkey] = tx[txkey]
return decoded_tx
d = self._get_raw_tx(txid)
d.addCallback(_decode)
return d
def get_pub_keys(self, wallet):
cmd = known_commands['getpubkeys']
func = getattr(self.cmd_runner, cmd.name)
@@ -1268,4 +1434,4 @@ class LBRYcrdAddressQueryHandler(object):
log.warning("Expected a request for an address, but did not receive one")
return defer.fail(Failure(ValueError("Expected but did not receive an address request")))
else:
return defer.succeed({})
return defer.succeed({})
+1 -1
View File
@@ -12,7 +12,7 @@ from lbrynet.pointtraderclient import pointtraderclient
from twisted.internet import defer, threads
from zope.interface import implements
from twisted.python.failure import Failure
from lbrynet.core.LBRYcrdWallet import ReservedPoints
from lbrynet.core.LBRYWallet import ReservedPoints
log = logging.getLogger(__name__)
+9
View File
@@ -173,14 +173,23 @@ class LBRYSession(object):
self.upnp_redirects.append((self.peer_port, 'TCP'))
log.info("Set UPnP redirect for TCP port %d", self.peer_port)
else:
# see comment below
log.warning("UPnP redirect already set for TCP port %d", self.peer_port)
self.upnp_redirects.append((self.peer_port, 'TCP'))
if self.dht_node_port is not None:
if u.getspecificportmapping(self.dht_node_port, 'UDP') is None:
u.addportmapping(self.dht_node_port, 'UDP', u.lanaddr, self.dht_node_port, 'LBRY DHT port', '')
self.upnp_redirects.append((self.dht_node_port, 'UDP'))
log.info("Set UPnP redirect for UPD port %d", self.dht_node_port)
else:
# TODO: check that the existing redirect was put up by an old lbrynet session before grabbing it
# if such a disconnected redirect exists, then upnp won't work unless the redirect is appended
# or is torn down and set back up. a bad shutdown of lbrynet could leave such a redirect up
# and cause problems on the next start.
# this could be problematic if a previous lbrynet session didn't make the redirect, and it was
# made by another application
log.warning("UPnP redirect already set for UDP port %d", self.dht_node_port)
self.upnp_redirects.append((self.dht_node_port, 'UDP'))
return True
return False
+2 -2
View File
@@ -198,7 +198,7 @@ class StreamDescriptorIdentifier(object):
return self._stream_downloader_factories[stream_type]
def _get_validator(self, stream_type):
if not stream_type in self._stream_downloader_factories:
if not stream_type in self._sd_info_validators:
raise UnknownStreamTypeError(stream_type)
return self._sd_info_validators[stream_type]
@@ -238,4 +238,4 @@ def download_sd_blob(session, blob_hash, payment_rate_manager):
"""
downloader = StandaloneBlobDownloader(blob_hash, session.blob_manager, session.peer_finder,
session.rate_limiter, payment_rate_manager, session.wallet)
return downloader.download()
return downloader.download()
+1 -1
View File
@@ -73,7 +73,7 @@ class ClientProtocol(Protocol):
return defer.fail(failure.Failure(ValueError("There is already a request for that response active")))
self._next_request.update(request.request_dict)
d = defer.Deferred()
log.debug("Adding a request. Request: %s", str(request))
log.debug("Adding a request. Request: %s", str(request.request_dict))
self._response_deferreds[request.response_identifier] = d
return d
+1
View File
@@ -172,6 +172,7 @@ class ConnectionManager(object):
def pick_best_peer(peers):
# TODO: Eventually rank them based on past performance/reputation. For now
# TODO: just pick the first to which we don't have an open connection
log.debug("Got a list of peers to choose from: %s", str(peers))
if peers is None:
return None
+1 -1
View File
@@ -66,7 +66,7 @@ class DownloadManager(object):
def add_blobs_to_download(self, blob_infos):
log.debug("Adding %s to blobs", str(blob_infos))
log.debug("Adding %s blobs to blobs", len(blob_infos))
def add_blob_to_list(blob, blob_num):
self.blobs[blob_num] = blob
+132
View File
@@ -0,0 +1,132 @@
import json
import logging
import logging.handlers
import sys
import traceback
from requests_futures.sessions import FuturesSession
import lbrynet
from lbrynet import conf
from lbrynet.core import utils
session = FuturesSession()
def bg_cb(sess, resp):
""" Don't do anything with the response """
pass
class HTTPSHandler(logging.Handler):
def __init__(self, url, fqdn=False, localname=None, facility=None):
logging.Handler.__init__(self)
self.url = url
self.fqdn = fqdn
self.localname = localname
self.facility = facility
def get_full_message(self, record):
if record.exc_info:
return '\n'.join(traceback.format_exception(*record.exc_info))
else:
return record.getMessage()
def emit(self, record):
try:
payload = self.format(record)
session.post(self.url, data=payload, background_callback=bg_cb)
except (KeyboardInterrupt, SystemExit):
raise
except:
self.handleError(record)
DEFAULT_FORMAT = "%(asctime)s %(levelname)-8s %(name)s:%(lineno)d: %(message)s"
DEFAULT_FORMATTER = logging.Formatter(DEFAULT_FORMAT)
LOGGLY_URL = "https://logs-01.loggly.com/inputs/{token}/tag/{tag}"
def remove_handlers(log, handler_name):
for handler in log.handlers:
if handler.name == handler_name:
log.removeHandler(handler)
def _log_decorator(fn):
def helper(*args, **kwargs):
log = kwargs.pop('log', logging.getLogger())
level = kwargs.pop('level', logging.INFO)
if not isinstance(level, int):
# despite the name, getLevelName returns
# the numeric level when passed a text level
level = logging.getLevelName(level)
handler = fn(*args, **kwargs)
if handler.name:
remove_handlers(log, handler.name)
handler.setLevel(level)
log.addHandler(handler)
if log.level > level:
log.setLevel(level)
return helper
def disable_third_party_loggers():
logging.getLogger('requests').setLevel(logging.WARNING)
def disable_noisy_loggers():
logging.getLogger('BitcoinRPC').setLevel(logging.INFO)
logging.getLogger('lbrynet.analytics.api').setLevel(logging.INFO)
logging.getLogger('lbrynet.core.client.ConnectionManager').setLevel(logging.INFO)
logging.getLogger('lbrynet.core.client.BlobRequester').setLevel(logging.INFO)
logging.getLogger('lbrynet.core.client.ClientProtocol').setLevel(logging.INFO)
logging.getLogger('lbrynet.core.server.ServerRequestHandler').setLevel(logging.INFO)
logging.getLogger('lbrynet.core.server.ServerProtocol').setLevel(logging.INFO)
logging.getLogger('lbrynet.core.server.BlobAvailabilityHandler').setLevel(logging.INFO)
logging.getLogger('lbrynet.dht').setLevel(logging.INFO)
logging.getLogger('lbrynet.lbrynet_daemon.LBRYExchangeRateManager').setLevel(logging.INFO)
@_log_decorator
def configure_console(**kwargs):
"""Convenience function to configure a logger that outputs to stdout"""
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(DEFAULT_FORMATTER)
handler.name = 'console'
return handler
@_log_decorator
def configure_file_handler(file_name, **kwargs):
handler = logging.handlers.RotatingFileHandler(file_name, maxBytes=2097152, backupCount=5)
handler.setFormatter(DEFAULT_FORMATTER)
handler.name = 'file'
return handler
def get_loggly_url(token=None, version=None):
token = token or utils.deobfuscate(conf.LOGGLY_TOKEN)
version = version or lbrynet.__version__
return LOGGLY_URL.format(token=token, tag='lbrynet-' + version)
@_log_decorator
def configure_loggly_handler(url=None, **kwargs):
url = url or get_loggly_url()
json_format = {
"loggerName": "%(name)s",
"asciTime": "%(asctime)s",
"fileName": "%(filename)s",
"functionName": "%(funcName)s",
"levelNo": "%(levelno)s",
"lineNo": "%(lineno)d",
"levelName": "%(levelname)s",
"message": "%(message)s",
}
json_format.update(kwargs)
formatter = logging.Formatter(json.dumps(json_format))
handler = HTTPSHandler(url)
handler.setFormatter(formatter)
handler.name = 'loggly'
return handler
@@ -44,6 +44,7 @@ class BlobAvailabilityHandler(object):
d = self._get_available_blobs(queries[self.query_identifiers[0]])
def set_field(available_blobs):
log.debug("available blobs: %s", str(available_blobs))
return {'available_blobs': available_blobs}
d.addCallback(set_field)
+2 -1
View File
@@ -140,6 +140,7 @@ class BlobRequestHandler(object):
def set_expected_payment():
log.info("Setting expected payment")
if self.blob_bytes_uploaded != 0 and self.blob_data_payment_rate is not None:
# TODO: explain why 2**20
self.wallet.add_expected_payment(self.peer,
self.currently_uploading.length * 1.0 *
self.blob_data_payment_rate / 2**20)
@@ -156,4 +157,4 @@ class BlobRequestHandler(object):
if reason is not None and isinstance(reason, Failure):
log.info("Upload has failed. Reason: %s", reason.getErrorMessage())
return _send_file()
return _send_file()
+2 -2
View File
@@ -1,5 +1,5 @@
import binascii
from twisted.internet import defer, task, reactor
from twisted.internet import defer, reactor
import collections
@@ -78,4 +78,4 @@ class DHTHashSupplier(object):
self.hash_reannounce_time = 60 * 60 # 1 hour
def hashes_to_announce(self):
pass
pass
+4 -4
View File
@@ -99,8 +99,8 @@ class ServerRequestHandler(object):
d.addCallback(lambda _: self.blob_sender.send_blob_if_requested(self))
d.addCallbacks(lambda _: self.finished_response(), self.request_failure_handler)
else:
log.info("Request buff not a valid json message")
log.info("Request buff: %s", str(self.request_buff))
log.debug("Request buff not a valid json message")
log.debug("Request buff: %s", str(self.request_buff))
else:
log.warning("The client sent data when we were uploading a file. This should not happen")
@@ -125,7 +125,7 @@ class ServerRequestHandler(object):
def send_response(self, msg):
m = json.dumps(msg)
log.info("Sending a response of length %s", str(len(m)))
log.debug("Sending a response of length %s", str(len(m)))
log.debug("Response: %s", str(m))
self.response_buff = self.response_buff + m
self._produce_more()
@@ -171,4 +171,4 @@ class ServerRequestHandler(object):
msg = json.loads(request_buff)
return msg
except ValueError:
return None
return None
+22 -2
View File
@@ -1,6 +1,10 @@
from lbrynet.core.cryptoutils import get_lbry_hash_obj
import base64
import distutils.version
import random
from lbrynet.core.cryptoutils import get_lbry_hash_obj
blobhash_length = get_lbry_hash_obj().digest_size * 2 # digest_size is in bytes, and blob hashes are hex encoded
@@ -25,4 +29,20 @@ def is_valid_blobhash(blobhash):
for l in blobhash:
if l not in "0123456789abcdef":
return False
return True
return True
def version_is_greater_than(a, b):
"""Returns True if version a is more recent than version b"""
try:
return distutils.version.StrictVersion(a) > distutils.version.StrictVersion(b)
except ValueError:
return distutils.version.LooseVersion(a) > distutils.version.LooseVersion(b)
def deobfuscate(obfustacated):
return base64.b64decode(obfustacated.decode('rot13'))
def obfuscate(plain):
return base64.b64encode(plain).encode('rot13')
+3
View File
@@ -1,9 +1,12 @@
import logging
import os
def migrate_db(db_dir, start, end):
current = start
old_dirs = []
if os.name == "nt":
return old_dirs
while current < end:
if current == 0:
from lbrynet.db_migrator.migrate0to1 import do_migration
-3
View File
@@ -8,10 +8,7 @@
# may be created by processing this file with epydoc: http://epydoc.sf.net
import UserDict
#import sqlite3
import cPickle as pickle
import time
import os
import constants
+5 -5
View File
@@ -7,7 +7,7 @@
# The docstrings in this module contain epytext markup; API documentation
# may be created by processing this file with epydoc: http://epydoc.sf.net
import hashlib, random, struct, time, math, binascii
import hashlib, random, struct, time, binascii
import argparse
from twisted.internet import defer, error
import constants
@@ -240,9 +240,9 @@ class Node(object):
known_nodes = {}
def log_error(err, n):
log.error("error storing blob_hash %s at %s", binascii.hexlify(blob_hash), str(n))
log.error(binascii.hexlify(err.getErrorMessage()))
log.error(err.getTraceback())
log.debug("error storing blob_hash %s at %s", binascii.hexlify(blob_hash), str(n))
log.debug(err.getErrorMessage())
log.debug(err.getTraceback())
def log_success(res):
log.debug("Response to store request: %s", str(res))
@@ -1017,4 +1017,4 @@ def main():
twisted.internet.reactor.run()
if __name__ == '__main__':
main()
main()
+8
View File
@@ -7,6 +7,7 @@
# The docstrings in this module contain epytext markup; API documentation
# may be created by processing this file with epydoc: http://epydoc.sf.net
import binascii
import time
from twisted.internet import protocol, defer
@@ -23,6 +24,13 @@ reactor = twisted.internet.reactor
class TimeoutError(Exception):
""" Raised when a RPC times out """
def __init__(self, remote_contact_id):
# remote_contact_id is a binary blob so we need to convert it
# into something more readable
msg = 'Timeout connecting to {}'.format(binascii.hexlify(remote_contact_id))
Exception.__init__(self, msg)
self.remote_contact_id = remote_contact_id
class KademliaProtocol(protocol.DatagramProtocol):
""" Implements all low-level network-related functions of a Kademlia node """
+2 -2
View File
@@ -20,7 +20,7 @@
import os, sys, time, signal, hashlib, random
import sys, hashlib, random
import twisted.internet.reactor
from lbrynet.dht.node import Node
#from entangled.kademlia.datastore import SQLiteDataStore
@@ -106,7 +106,7 @@ def stop():
if __name__ == '__main__':
import sys, os
import sys
if len(sys.argv) < 2:
print 'Usage:\n%s UDP_PORT [KNOWN_NODE_IP KNOWN_NODE_PORT]' % sys.argv[0]
print 'or:\n%s UDP_PORT [FILE_WITH_KNOWN_NODES]' % sys.argv[0]
+1 -1
View File
@@ -48,7 +48,7 @@ class DBLBRYFileMetadataManager(object):
return self._add_blobs_to_stream(stream_hash, blobs, ignore_duplicate_error=True)
def get_blobs_for_stream(self, stream_hash, start_blob=None, end_blob=None, count=None, reverse=False):
log.info("Getting blobs for a stream. Count is %s", str(count))
log.debug("Getting blobs for a stream. Count is %s", str(count))
def get_positions_of_start_and_end():
if start_blob is not None:
+2
View File
@@ -0,0 +1,2 @@
from lbrynet.lbryfile.StreamDescriptor import get_sd_info
from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob
+1 -2
View File
@@ -11,7 +11,6 @@ from lbrynet import conf
from lbrynet.lbryfile.StreamDescriptor import get_sd_info
from lbrynet.core.cryptoutils import get_lbry_hash_obj
from twisted.protocols.basic import FileSender
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader
log = logging.getLogger(__name__)
@@ -155,4 +154,4 @@ def create_lbry_file(session, lbry_file_manager, file_name, file_handle, key=Non
d = lbry_file_creator.setup()
d.addCallback(lambda _: start_stream())
return d
return d
@@ -27,6 +27,7 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
self.sd_hash = None
self.txid = None
self.uri = None
self.claim_id = None
self.rowid = rowid
self.lbry_file_manager = lbry_file_manager
self.saving_status = False
@@ -43,10 +44,16 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
return d
def _save_claim_id(claim_id):
self.claim_id = claim_id
return defer.succeed(None)
def _save_claim(name, txid):
self.uri = name
self.txid = txid
return defer.succeed(None)
d = self.wallet.get_claimid(name, txid)
d.addCallback(_save_claim_id)
return d
d.addCallback(_save_sd_hash)
d.addCallback(lambda r: _save_claim(r[0], r[1]) if r else None)
+5 -2
View File
@@ -80,13 +80,16 @@ class LBRYFileManager(object):
d.addCallback(lambda downloader: downloader.restore())
return d
def log_error(err):
def log_error(err, rowid, stream_hash, options):
log.error("An error occurred while starting a lbry file: %s", err.getErrorMessage())
log.error(rowid)
log.error(stream_hash)
log.error(options)
def start_lbry_files(lbry_files_and_options):
for rowid, stream_hash, options in lbry_files_and_options:
d = set_options_and_restore(rowid, stream_hash, options)
d.addErrback(log_error)
d.addErrback(lambda err: log_error(err, rowid, stream_hash, options))
return True
d = self._get_all_lbry_files()
+1 -7
View File
@@ -1,18 +1,12 @@
import json
import logging
from time import sleep
from bitcoinrpc.authproxy import AuthServiceProxy
from twisted.internet.task import LoopingCall
from zope.interface import implements
#from lbrynet.core.StreamDescriptor import PlainStreamDescriptorWriter, BlobStreamDescriptorWriter
from lbrynet.core.PaymentRateManager import PaymentRateManager
from lbrynet.lbryfilemanager.LBRYFileCreator import create_lbry_file
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader
# from lbrynet.lbryfile.StreamDescriptor import get_sd_info
from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob, create_plain_sd
from lbrynet.lbrynet_console.interfaces import ICommandHandler, ICommandHandlerFactory
from lbrynet.core.StreamDescriptor import download_sd_blob#, BlobStreamDescriptorReader
from lbrynet.core.StreamDescriptor import download_sd_blob
from lbrynet.core.Error import UnknownNameError, InvalidBlobHashError, InsufficientFundsError
from lbrynet.core.Error import InvalidStreamInfoError
from lbrynet.core.utils import is_valid_blobhash
+1 -1
View File
@@ -43,7 +43,7 @@ from lbrynet.lbrynet_console.ControlHandlers import ShowServerStatusFactory, Mod
from lbrynet.lbrynet_console.ControlHandlers import ModifyLBRYFileOptionsChooserFactory, StatusFactory
from lbrynet.lbrynet_console.ControlHandlers import PeerStatsAndSettingsChooserFactory, PublishFactory
from lbrynet.lbrynet_console.ControlHandlers import BlockchainStatusFactory
from lbrynet.core.LBRYcrdWallet import LBRYcrdWallet, LBRYumWallet
from lbrynet.core.LBRYWallet import LBRYcrdWallet, LBRYumWallet
log = logging.getLogger(__name__)
+50 -56
View File
@@ -1,15 +1,25 @@
import binascii
import functools
import json
import unqlite
import logging
import os
from twisted.internet import threads, defer
import unqlite
log = logging.getLogger(__name__)
def run_in_thread(fn):
@functools.wraps(fn)
def wrapped(*args, **kwargs):
return threads.deferToThread(fn, *args, **kwargs)
return wrapped
class LBRYSettings(object):
NAME = "settings.db"
def __init__(self, db_dir):
self.db_dir = db_dir
self.db = None
@@ -18,47 +28,39 @@ class LBRYSettings(object):
return self._open_db()
def stop(self):
self.db.close()
self.db = None
return defer.succeed(True)
def _open_db(self):
log.debug("Opening %s as the settings database", str(os.path.join(self.db_dir, "settings.db")))
self.db = unqlite.UnQLite(os.path.join(self.db_dir, "settings.db"))
filename = os.path.join(self.db_dir, self.NAME)
log.debug("Opening %s as the settings database", filename)
self.db = unqlite.UnQLite(filename)
return defer.succeed(True)
@run_in_thread
def save_lbryid(self, lbryid):
self.db['lbryid'] = binascii.hexlify(lbryid)
self.db.commit()
def save_lbryid():
self.db['lbryid'] = binascii.hexlify(lbryid)
return threads.deferToThread(save_lbryid)
@run_in_thread
def get_lbryid(self):
if 'lbryid' in self.db:
return binascii.unhexlify(self.db['lbryid'])
else:
return None
def get_lbryid():
if 'lbryid' in self.db:
return binascii.unhexlify(self.db['lbryid'])
else:
return None
return threads.deferToThread(get_lbryid)
@run_in_thread
def get_server_running_status(self):
if 'server_running' in self.db:
return json.loads(self.db['server_running'])
else:
return True
def get_status():
if 'server_running' in self.db:
return json.loads(self.db['server_running'])
else:
return True
return threads.deferToThread(get_status)
@run_in_thread
def save_server_running_status(self, running):
def save_status():
self.db['server_running'] = json.dumps(running)
return threads.deferToThread(save_status)
self.db['server_running'] = json.dumps(running)
self.db.commit()
def get_default_data_payment_rate(self):
return self._get_payment_rate("default_data_payment_rate")
@@ -78,35 +80,27 @@ class LBRYSettings(object):
def save_server_crypt_info_payment_rate(self, rate):
return self._save_payment_rate("server_crypt_info_payment_rate", rate)
@run_in_thread
def _get_payment_rate(self, rate_type):
if rate_type in self.db:
return json.loads(self.db[rate_type])
else:
return None
def get_rate():
if rate_type in self.db:
return json.loads(self.db[rate_type])
else:
return None
return threads.deferToThread(get_rate)
@run_in_thread
def _save_payment_rate(self, rate_type, rate):
if rate is not None:
self.db[rate_type] = json.dumps(rate)
elif rate_type in self.db:
del self.db[rate_type]
self.db.commit()
def save_rate():
if rate is not None:
self.db[rate_type] = json.dumps(rate)
elif rate_type in self.db:
del self.db[rate_type]
return threads.deferToThread(save_rate)
@run_in_thread
def get_query_handler_status(self, query_identifier):
def get_status():
if json.dumps(('q_h', query_identifier)) in self.db:
return json.loads(self.db[(json.dumps(('q_h', query_identifier)))])
else:
return True
return threads.deferToThread(get_status)
if json.dumps(('q_h', query_identifier)) in self.db:
return json.loads(self.db[(json.dumps(('q_h', query_identifier)))])
else:
return True
def enable_query_handler(self, query_identifier):
return self._set_query_handler_status(query_identifier, True)
@@ -114,7 +108,7 @@ class LBRYSettings(object):
def disable_query_handler(self, query_identifier):
return self._set_query_handler_status(query_identifier, False)
@run_in_thread
def _set_query_handler_status(self, query_identifier, status):
def set_status():
self.db[json.dumps(('q_h', query_identifier))] = json.dumps(status)
return threads.deferToThread(set_status)
self.db[json.dumps(('q_h', query_identifier))] = json.dumps(status)
self.db.commit()
File diff suppressed because it is too large. Load diff
+59
View File
@@ -0,0 +1,59 @@
import sys
import json
from lbrynet.conf import API_CONNECTION_STRING
from jsonrpc.proxy import JSONRPCProxy
help_msg = "Usage: lbrynet-cli method json-args\n" \
+ "Examples: " \
+ "lbrynet-cli resolve_name '{\"name\": \"what\"}'\n" \
+ "lbrynet-cli get_balance\n" \
+ "lbrynet-cli help '{\"function\": \"resolve_name\"}'\n" \
+ "\n******lbrynet-cli functions******\n"
def main():
api = JSONRPCProxy.from_url(API_CONNECTION_STRING)
try:
s = api.is_running()
except:
print "lbrynet-daemon isn't running"
sys.exit(1)
args = sys.argv[1:]
meth = args[0]
msg = help_msg
for f in api.help():
msg += f + "\n"
if meth in ['--help', '-h', 'help']:
print msg
sys.exit(1)
if len(args) > 1:
if isinstance(args[1], dict):
params = args[1]
elif isinstance(args[1], basestring):
params = json.loads(args[1])
else:
params = None
if meth in api.help():
try:
if params:
r = api.call(meth, params)
else:
r = api.call(meth)
print r
except:
print "Something went wrong, here's the usage for %s:" % meth
print api.help({'function': meth})
else:
print "Unknown function"
print msg
if __name__ == '__main__':
main()
+18 -12
View File
@@ -5,17 +5,18 @@ import os
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, DEFAULT_UI_BRANCH, LOG_FILE_NAME
from lbrynet.core import log_support
from lbrynet.lbrynet_daemon.LBRYDaemonServer import LBRYDaemonServer, LBRYDaemonRequest
from lbrynet.conf import API_CONNECTION_STRING, API_INTERFACE, API_PORT, \
UI_ADDRESS, DEFAULT_UI_BRANCH, LOG_FILE_NAME
# TODO: stop it!
if sys.platform != "darwin":
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
else:
@@ -26,12 +27,13 @@ if not os.path.isdir(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)
REMOTE_SERVER = "www.google.com"
if getattr(sys, 'frozen', False) and os.name == "nt":
os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(os.path.dirname(sys.executable), "cacert.pem")
def test_internet_connection():
try:
@@ -74,10 +76,12 @@ def start():
parser.set_defaults(branch=False, launchui=True, logtoconsole=False, quiet=False)
args = parser.parse_args()
log_support.configure_file_handler(lbrynet_log)
log_support.configure_loggly_handler()
if args.logtoconsole:
logging.basicConfig(level=logging.INFO)
args = parser.parse_args()
log_support.configure_console(level='DEBUG')
log_support.disable_third_party_loggers()
log_support.disable_noisy_loggers()
try:
JSONRPCProxy.from_url(API_CONNECTION_STRING).is_running()
@@ -109,7 +113,9 @@ def start():
if args.launchui:
d.addCallback(lambda _: webbrowser.open(UI_ADDRESS))
reactor.listenTCP(API_PORT, server.Site(lbry.root), interface=API_INTERFACE)
lbrynet_server = server.Site(lbry.root)
lbrynet_server.requestFactory = LBRYDaemonRequest
reactor.listenTCP(API_PORT, lbrynet_server, interface=API_INTERFACE)
reactor.run()
if not args.logtoconsole and not args.quiet:
@@ -121,4 +127,4 @@ def start():
return
if __name__ == "__main__":
start()
start()
+233 -11
View File
@@ -4,18 +4,22 @@ import shutil
import json
import sys
import mimetypes
import mimetools
import tempfile
import time
import cgi
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.internet import defer, interfaces, error, reactor, threads
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, DEFAULT_UI_BRANCH, LOG_FILE_NAME
from lbrynet.conf import API_ADDRESS, UI_ADDRESS, DEFAULT_UI_BRANCH, LOG_FILE_NAME
# TODO: omg, this code is essentially duplicated in LBRYDaemon
if sys.platform != "darwin":
data_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
else:
@@ -25,11 +29,186 @@ if not os.path.isdir(data_dir):
lbrynet_log = os.path.join(data_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 LBRYDaemonRequest(server.Request):
"""
For LBRY specific request functionality. Currently just provides
handling for large multipart POST requests, taken from here:
http://sammitch.ca/2013/07/handling-large-requests-in-twisted/
For multipart POST requests, this populates self.args with temp
file objects instead of strings. Note that these files don't auto-delete
on close because we want to be able to move and rename them.
"""
# max amount of memory to allow any ~single~ request argument [ie: POSTed file]
# note: this value seems to be taken with a grain of salt, memory usage may spike
# FAR above this value in some cases.
# eg: set the memory limit to 5 MB, write 2 blocks of 4MB, mem usage will
# have spiked to 8MB before the data is rolled to disk after the
# second write completes.
memorylimit = 1024*1024*100
# enable/disable debug logging
do_log = False
# re-defined only for debug/logging purposes
def gotLength(self, length):
if self.do_log:
print '%f Headers received, Content-Length: %d' % (time.time(), length)
server.Request.gotLength(self, length)
# re-definition of twisted.web.server.Request.requestreceived, the only difference
# is that self.parse_multipart() is used rather than cgi.parse_multipart()
def requestReceived(self, command, path, version):
from twisted.web.http import parse_qs
if self.do_log:
print '%f Request Received' % time.time()
self.content.seek(0,0)
self.args = {}
self.stack = []
self.method, self.uri = command, path
self.clientproto = version
x = self.uri.split(b'?', 1)
if len(x) == 1:
self.path = self.uri
else:
self.path, argstring = x
self.args = parse_qs(argstring, 1)
# cache the client and server information, we'll need this later to be
# serialized and sent with the request so CGIs will work remotely
self.client = self.channel.transport.getPeer()
self.host = self.channel.transport.getHost()
# Argument processing
args = self.args
ctype = self.requestHeaders.getRawHeaders(b'content-type')
if ctype is not None:
ctype = ctype[0]
if self.method == b"POST" and ctype:
mfd = b'multipart/form-data'
key, pdict = cgi.parse_header(ctype)
if key == b'application/x-www-form-urlencoded':
args.update(parse_qs(self.content.read(), 1))
elif key == mfd:
try:
self.content.seek(0,0)
args.update(self.parse_multipart(self.content, pdict))
#args.update(cgi.parse_multipart(self.content, pdict))
except KeyError as e:
if e.args[0] == b'content-disposition':
# Parse_multipart can't cope with missing
# content-dispostion headers in multipart/form-data
# parts, so we catch the exception and tell the client
# it was a bad request.
self.channel.transport.write(
b"HTTP/1.1 400 Bad Request\r\n\r\n")
self.channel.transport.loseConnection()
return
raise
self.content.seek(0, 0)
self.process()
# re-definition of cgi.parse_multipart that uses a single temporary file to store
# data rather than storing 2 to 3 copies in various lists.
def parse_multipart(self, fp, pdict):
if self.do_log:
print '%f Parsing Multipart data: ' % time.time()
rewind = fp.tell() #save cursor
fp.seek(0,0) #reset cursor
boundary = ""
if 'boundary' in pdict:
boundary = pdict['boundary']
if not cgi.valid_boundary(boundary):
raise ValueError, ('Invalid boundary in multipart form: %r'
% (boundary,))
nextpart = "--" + boundary
lastpart = "--" + boundary + "--"
partdict = {}
terminator = ""
while terminator != lastpart:
c_bytes = -1
data = tempfile.NamedTemporaryFile(delete=False)
if terminator:
# At start of next part. Read headers first.
headers = mimetools.Message(fp)
clength = headers.getheader('content-length')
if clength:
try:
c_bytes = int(clength)
except ValueError:
pass
if c_bytes > 0:
data.write(fp.read(c_bytes))
# Read lines until end of part.
while 1:
line = fp.readline()
if not line:
terminator = lastpart # End outer loop
break
if line[:2] == "--":
terminator = line.strip()
if terminator in (nextpart, lastpart):
break
data.write(line)
# Done with part.
if data.tell() == 0:
continue
if c_bytes < 0:
# if a Content-Length header was not supplied with the MIME part
# then the trailing line break must be removed.
# we have data, read the last 2 bytes
rewind = min(2, data.tell())
data.seek(-rewind, os.SEEK_END)
line = data.read(2)
if line[-2:] == "\r\n":
data.seek(-2, os.SEEK_END)
data.truncate()
elif line[-1:] == "\n":
data.seek(-1, os.SEEK_END)
data.truncate()
line = headers['content-disposition']
if not line:
continue
key, params = cgi.parse_header(line)
if key != 'form-data':
continue
if 'name' in params:
name = params['name']
# kludge in the filename
if 'filename' in params:
fname_index = name + '_filename'
if fname_index in partdict:
partdict[fname_index].append(params['filename'])
else:
partdict[fname_index] = [params['filename']]
else:
# Unnamed parts are not returned at all.
continue
data.seek(0,0)
if name in partdict:
partdict[name].append(data)
else:
partdict[name] = [data]
fp.seek(rewind) # Restore cursor
return partdict
class LBRYindex(resource.Resource):
def __init__(self, ui_dir):
resource.Resource.__init__(self)
@@ -47,6 +226,8 @@ class LBRYindex(resource.Resource):
return resource.Resource.getChild(self, name, request)
def render_GET(self, request):
request.setHeader('cache-control','no-cache, no-store, must-revalidate')
request.setHeader('expires', '0')
return static.File(os.path.join(self.ui_dir, "index.html")).render_GET(request)
@@ -74,12 +255,13 @@ class LBRYFileStreamer(object):
self._request.setResponseCode(206)
self._request.setHeader('accept-ranges', 'bytes')
self._request.setHeader('content-type', self._content_type)
self._request.setHeader("Content-Security-Policy", "sandbox")
self.resumeProducing()
def pauseProducing(self):
self._paused = True
log.info("[" + str(datetime.now()) + "] Pausing producer")
log.info("Pausing producer")
return defer.succeed(None)
def resumeProducing(self):
@@ -104,7 +286,7 @@ class LBRYFileStreamer(object):
self._request.write(data)
self._cursor += 1
log.info("[" + str(datetime.now()) + "] Wrote range %s-%s/%s, length: %s, readable: %s, depth: %s" %
log.info("Wrote range %s-%s/%s, length: %s, readable: %s, depth: %s" %
(start_cur, self._cursor, self._file_size, self._cursor - start_cur, readable_bytes, self._depth))
self._sent_bytes = True
@@ -117,12 +299,12 @@ class LBRYFileStreamer(object):
self._deferred.addCallback(lambda _: threads.deferToThread(reactor.callLater, self._delay, _check_for_new_data))
return defer.succeed(None)
log.info("[" + str(datetime.now()) + "] Resuming producer")
log.info("Resuming producer")
self._paused = False
self._deferred.addCallback(lambda _: _check_for_new_data())
def stopProducing(self):
log.info("[" + str(datetime.now()) + "] Stopping producer")
log.info("Stopping producer")
self._stopped = True
# self._fileObject.close()
self._deferred.addErrback(lambda err: err.trap(defer.CancelledError))
@@ -147,7 +329,7 @@ class HostedLBRYFile(resource.Resource):
#
# 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))
# log.info("GET range %s-%s" % (start, stop))
# path = os.path.join(self._api.download_directory, stream.file_name)
#
# d = stream.get_total_bytes()
@@ -158,6 +340,7 @@ class HostedLBRYFile(resource.Resource):
# return d
def render_GET(self, request):
request.setHeader("Content-Security-Policy", "sandbox")
if 'name' in request.args.keys():
if request.args['name'][0] != 'lbry' and request.args['name'][0] not in self._api.waiting_on.keys():
d = self._api._download_name(request.args['name'][0])
@@ -179,12 +362,51 @@ class HostedLBRYFile(resource.Resource):
# call.addErrback(lambda err: log.info("Error: " + str(err)))
# call.cancel()
class LBRYFileUpload(resource.Resource):
"""
Accepts a file sent via the file upload widget in the web UI, saves
it into a temporary dir, and responds with a JSON string containing
the path of the newly created file.
"""
def __init__(self, api):
self._api = api
def render_POST(self, request):
origfilename = request.args['file_filename'][0]
uploaded_file = request.args['file'][0] # Temp file created by request
# Move to a new temporary dir and restore the original file name
newdirpath = tempfile.mkdtemp()
newpath = os.path.join(newdirpath, origfilename)
if os.name == "nt":
shutil.copy(uploaded_file.name, newpath)
# TODO Still need to remove the file
# TODO deal with pylint error in cleaner fashion than this
try:
from exceptions import WindowsError as win_except
except ImportError as e:
log.error("This shouldn't happen")
win_except = Exception
try:
os.remove(uploaded_file.name)
except win_except as e:
pass
else:
shutil.move(uploaded_file.name, newpath)
self._api.uploaded_temp_files.append(newpath)
return json.dumps(newpath)
class LBRYDaemonServer(object):
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("upload", LBRYFileUpload(self._api))
self.root.putChild(API_ADDRESS, self._api)
return defer.succeed(True)
+73 -65
View File
@@ -3,14 +3,15 @@ import logging
import os
import sys
from copy import deepcopy
from appdirs import user_data_dir
from datetime import datetime
from twisted.internet import defer
from twisted.internet.task import LoopingCall
from lbrynet.core.Error import InvalidStreamInfoError, InsufficientFundsError
from lbrynet.core.Error import InsufficientFundsError, KeyFeeAboveMaxAllowed
from lbrynet.core.PaymentRateManager import PaymentRateManager
from lbrynet.core.StreamDescriptor import download_sd_blob
from lbrynet.metadata.LBRYFee import LBRYFeeValidator
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloaderFactory
from lbrynet.conf import DEFAULT_TIMEOUT, LOG_FILE_NAME
@@ -37,23 +38,20 @@ if not os.path.isdir(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 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):
def __init__(self, sd_identifier, session, wallet, lbry_file_manager, exchange_rate_manager,
max_key_fee, data_rate=0.5, timeout=DEFAULT_TIMEOUT, download_directory=None, file_name=None):
self.wallet = wallet
self.resolved_name = None
self.description = None
self.key_fee = None
self.key_fee_address = None
self.fee = None
self.data_rate = data_rate
self.pay_key = pay_key
self.name = None
self.file_name = file_name
self.session = session
self.exchange_rate_manager = exchange_rate_manager
self.payment_rate_manager = PaymentRateManager(self.session.base_payment_rate_manager)
self.lbry_file_manager = lbry_file_manager
self.sd_identifier = sd_identifier
@@ -67,93 +65,103 @@ class GetStream(object):
self.download_directory = download_directory
self.download_path = None
self.downloader = None
self.finished = defer.Deferred()
self.finished = defer.Deferred(None)
self.checker = LoopingCall(self.check_status)
self.code = STREAM_STAGES[0]
def check_status(self):
self.timeout_counter += 1
# TODO: Why is this the stopping condition for the finished callback?
if self.download_path:
self.checker.stop()
self.finished.callback((self.stream_hash, self.download_path))
self.finished.callback((True, self.stream_hash, self.download_path))
elif self.timeout_counter >= self.timeout:
log.info("Timeout downloading lbry://" + self.resolved_name + ", " + str(self.stream_info))
log.info("Timeout downloading lbry://%s" % self.resolved_name)
self.checker.stop()
self.d.cancel()
self.code = STREAM_STAGES[4]
self.finished.callback(False)
self.finished.callback((False, None, None))
def _convert_max_fee(self):
if isinstance(self.max_key_fee, dict):
max_fee = LBRYFeeValidator(self.max_key_fee)
if max_fee.currency_symbol == "LBC":
return max_fee.amount
return self.exchange_rate_manager.to_lbc(self.fee).amount
elif isinstance(self.max_key_fee, float):
return float(self.max_key_fee)
def start(self, stream_info, name):
self.resolved_name = name
self.stream_info = stream_info
if 'stream_hash' in self.stream_info.keys():
self.stream_hash = self.stream_info['stream_hash']
elif 'sources' in self.stream_info.keys():
self.stream_hash = self.stream_info['sources']['lbry_sd_hash']
else:
raise InvalidStreamInfoError(self.stream_info)
if 'description' in self.stream_info.keys():
self.description = self.stream_info['description']
if 'key_fee' in self.stream_info.keys():
self.key_fee = float(self.stream_info['key_fee'])
if 'key_fee_address' in self.stream_info.keys():
self.key_fee_address = self.stream_info['key_fee_address']
else:
self.key_fee_address = None
else:
self.key_fee = None
self.key_fee_address = None
if self.key_fee > self.max_key_fee:
if self.pay_key:
log.info("Key fee (" + str(self.key_fee) + ") above limit of " + str(
self.max_key_fee) + ", didn't download lbry://" + str(self.resolved_name))
return defer.fail(None)
else:
pass
def _cause_timeout():
def _cause_timeout(err):
log.error(err)
log.debug('Forcing a timeout')
self.timeout_counter = self.timeout * 2
def _set_status(x, status):
log.info("Download lbry://%s status changed to %s" % (self.resolved_name, status))
self.code = next(s for s in STREAM_STAGES if s[0] == status)
return x
def get_downloader_factory(metadata):
for factory in metadata.factories:
if isinstance(factory, ManagedLBRYFileDownloaderFactory):
return factory, metadata
raise Exception('No suitable factory was found in {}'.format(metadata.factories))
def make_downloader(args):
factory, metadata = args
return factory.make_downloader(metadata,
[self.data_rate, True],
self.payment_rate_manager,
download_directory=self.download_directory,
file_name=self.file_name)
self.resolved_name = name
self.stream_info = deepcopy(stream_info)
self.description = self.stream_info['description']
self.stream_hash = self.stream_info['sources']['lbry_sd_hash']
if 'fee' in self.stream_info:
self.fee = LBRYFeeValidator(self.stream_info['fee'])
max_key_fee = self._convert_max_fee()
if self.exchange_rate_manager.to_lbc(self.fee).amount > max_key_fee:
log.info("Key fee %f above limit of %f didn't download lbry://%s" % (self.fee.amount,
self.max_key_fee,
self.resolved_name))
return defer.fail(KeyFeeAboveMaxAllowed())
log.info("Key fee %s below limit of %f, downloading lbry://%s" % (json.dumps(self.fee),
max_key_fee,
self.resolved_name))
self.checker.start(1)
self.d.addCallback(lambda _: _set_status(None, DOWNLOAD_METADATA_CODE))
self.d.addCallback(lambda _: download_sd_blob(self.session, self.stream_hash, self.payment_rate_manager))
self.d.addCallback(self.sd_identifier.get_metadata_for_sd_blob)
self.d.addCallback(lambda r: _set_status(r, DOWNLOAD_RUNNING_CODE))
self.d.addCallback(lambda metadata: (
next(factory for factory in metadata.factories if isinstance(factory, ManagedLBRYFileDownloaderFactory)),
metadata))
self.d.addCallback(lambda (factory, metadata): factory.make_downloader(metadata,
[self.data_rate, True],
self.payment_rate_manager,
download_directory=self.download_directory,
file_name=self.file_name))
self.d.addCallbacks(self._start_download, lambda _: _cause_timeout())
self.d.addCallback(get_downloader_factory)
self.d.addCallback(make_downloader)
self.d.addCallbacks(self._start_download, _cause_timeout)
self.d.callback(None)
return self.finished
def _start_download(self, downloader):
def _pay_key_fee():
if self.key_fee is not None and self.key_fee_address is not None:
reserved_points = self.wallet.reserve_points(self.key_fee_address, self.key_fee)
if reserved_points is None:
return defer.fail(InsufficientFundsError())
log.info("Key fee: " + str(self.key_fee) + " | " + str(self.key_fee_address))
return self.wallet.send_points_to_address(reserved_points, self.key_fee)
return defer.succeed(None)
if self.pay_key:
d = _pay_key_fee()
else:
d = defer.Deferred()
log.info('Starting download for %s', self.name)
self.downloader = downloader
self.download_path = os.path.join(downloader.download_directory, downloader.file_name)
d.addCallback(lambda _: log.info("[" + str(datetime.now()) + "] Downloading " + str(self.stream_hash) + " --> " + str(self.download_path)))
d = self._pay_key_fee()
d.addCallback(lambda _: log.info("Downloading %s --> %s", self.stream_hash, self.downloader.file_name))
d.addCallback(lambda _: self.downloader.start())
def _pay_key_fee(self):
if self.fee is not None:
fee_lbc = self.exchange_rate_manager.to_lbc(self.fee).amount
reserved_points = self.wallet.reserve_points(self.fee.address, fee_lbc)
if reserved_points is None:
return defer.fail(InsufficientFundsError())
return self.wallet.send_points_to_address(reserved_points, fee_lbc)
return defer.succeed(None)
@@ -0,0 +1,215 @@
import time
import requests
import logging
import json
import googlefinance
from twisted.internet import defer, reactor
from twisted.internet.task import LoopingCall
from lbrynet.metadata.LBRYFee import LBRYFeeValidator
log = logging.getLogger(__name__)
CURRENCY_PAIRS = ["USDBTC", "BTCLBC"]
BITTREX_FEE = 0.0025
COINBASE_FEE = 0.0 #add fee
class ExchangeRate(object):
def __init__(self, market, spot, ts):
assert int(time.time()) - ts < 600
self.currency_pair = (market[0:3], market[3:6])
self.spot = spot
self.ts = ts
def as_dict(self):
return {'spot': self.spot, 'ts': self.ts}
class MarketFeed(object):
def __init__(self, market, name, url, params, fee):
self.market = market
self.name = name
self.url = url
self.params = params
self.fee = fee
self.rate = None
self._updater = LoopingCall(self._update_price)
def _make_request(self):
r = requests.get(self.url, self.params)
return r.text
def _handle_response(self, response):
return NotImplementedError
def _subtract_fee(self, from_amount):
return defer.succeed(from_amount / (1.0 - self.fee))
def _save_price(self, price):
log.debug("Saving price update %f for %s" % (price, self.market))
self.rate = ExchangeRate(self.market, price, int(time.time()))
def _update_price(self):
d = defer.succeed(self._make_request())
d.addCallback(self._handle_response)
d.addCallback(self._subtract_fee)
d.addCallback(self._save_price)
def start(self):
if not self._updater.running:
self._updater.start(300)
def stop(self):
if self._updater.running:
self._updater.stop()
class BittrexFeed(MarketFeed):
def __init__(self):
MarketFeed.__init__(
self,
"BTCLBC",
"Bittrex",
"https://bittrex.com/api/v1.1/public/getmarkethistory",
{'market': 'BTC-LBC', 'count': 50},
BITTREX_FEE
)
def _handle_response(self, response):
trades = json.loads(response)['result']
vwap = sum([i['Total'] for i in trades]) / sum([i['Quantity'] for i in trades])
return defer.succeed(float(1.0 / vwap))
class GoogleBTCFeed(MarketFeed):
def __init__(self):
MarketFeed.__init__(
self,
"USDBTC",
"Coinbase via Google finance",
None,
None,
COINBASE_FEE
)
def _make_request(self):
return googlefinance.getQuotes('CURRENCY:USDBTC')[0]
def _handle_response(self, response):
return float(response['LastTradePrice'])
def get_default_market_feed(currency_pair):
currencies = None
if isinstance(currency_pair, str):
currencies = (currency_pair[0:3], currency_pair[3:6])
elif isinstance(currency_pair, tuple):
currencies = currency_pair
assert currencies is not None
if currencies == ("USD", "BTC"):
return GoogleBTCFeed()
elif currencies == ("BTC", "LBC"):
return BittrexFeed()
class ExchangeRateManager(object):
def __init__(self):
reactor.addSystemEventTrigger('before', 'shutdown', self.stop)
self.market_feeds = [get_default_market_feed(currency_pair) for currency_pair in CURRENCY_PAIRS]
def start(self):
log.info("Starting exchange rate manager")
for feed in self.market_feeds:
feed.start()
def stop(self):
log.info("Stopping exchange rate manager")
for source in self.market_feeds:
source.stop()
def convert_currency(self, from_currency, to_currency, amount):
log.info("Converting %f %s to %s" % (amount, from_currency, to_currency))
if from_currency == to_currency:
return amount
for market in self.market_feeds:
if market.rate.currency_pair == (from_currency, to_currency):
return amount * market.rate.spot
for market in self.market_feeds:
if market.rate.currency_pair[0] == from_currency:
return self.convert_currency(market.rate.currency_pair[1], to_currency, amount * market.rate.spot)
raise Exception('Unable to convert {} from {} to {}'.format(amount, from_currency, to_currency))
def fee_dict(self):
return {market: market.rate.as_dict() for market in self.market_feeds}
def to_lbc(self, fee):
if fee is None:
return None
if not isinstance(fee, LBRYFeeValidator):
fee_in = LBRYFeeValidator(fee)
else:
fee_in = fee
return LBRYFeeValidator({fee_in.currency_symbol:
{
'amount': self.convert_currency(fee_in.currency_symbol, "LBC", fee_in.amount),
'address': fee_in.address
}
})
class DummyBTCLBCFeed(MarketFeed):
def __init__(self):
MarketFeed.__init__(
self,
"BTCLBC",
"market name",
"derp.com",
None,
0.0
)
class DummyUSDBTCFeed(MarketFeed):
def __init__(self):
MarketFeed.__init__(
self,
"USDBTC",
"market name",
"derp.com",
None,
0.0
)
class DummyExchangeRateManager(object):
def __init__(self, rates):
self.market_feeds = [DummyBTCLBCFeed(), DummyUSDBTCFeed()]
for feed in self.market_feeds:
feed.rate = ExchangeRate(feed.market, rates[feed.market]['spot'], rates[feed.market]['ts'])
def convert_currency(self, from_currency, to_currency, amount):
log.debug("Converting %f %s to %s" % (amount, from_currency, to_currency))
for market in self.market_feeds:
if market.rate.currency_pair == (from_currency, to_currency):
return amount * market.rate.spot
for market in self.market_feeds:
if market.rate.currency_pair[0] == from_currency:
return self.convert_currency(market.rate.currency_pair[1], to_currency, amount * market.rate.spot)
def to_lbc(self, fee):
if fee is None:
return None
if not isinstance(fee, LBRYFeeValidator):
fee_in = LBRYFeeValidator(fee)
else:
fee_in = fee
return LBRYFeeValidator({fee_in.currency_symbol:
{
'amount': self.convert_currency(fee_in.currency_symbol, "LBC", fee_in.amount),
'address': fee_in.address
}
})
+74 -59
View File
@@ -1,17 +1,20 @@
import logging
import mimetypes
import os
import sys
import random
from appdirs import user_data_dir
from datetime import datetime
from lbrynet.core.Error import InsufficientFundsError
from lbrynet.lbryfilemanager.LBRYFileCreator import create_lbry_file
from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob
from lbrynet.core.PaymentRateManager import PaymentRateManager
from lbrynet.metadata.LBRYMetadata import Metadata
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader
from lbrynet.conf import LOG_FILE_NAME
from twisted.internet import threads, defer
from lbrynet import reflector
from lbrynet.conf import LOG_FILE_NAME, REFLECTOR_SERVERS
from twisted.internet import threads, defer, reactor
if sys.platform != "darwin":
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
@@ -23,9 +26,6 @@ if not os.path.isdir(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 Publisher(object):
@@ -36,53 +36,58 @@ class Publisher(object):
self.received_file_name = False
self.file_path = None
self.file_name = None
self.thumbnail = None
self.title = None
self.publish_name = None
self.bid_amount = None
self.key_fee = None
self.key_fee_address = None
self.key_fee_address_chosen = False
self.description = None
self.verified = False
self.lbry_file = None
self.sd_hash = None
self.tx_hash = None
self.content_license = None
self.author = None
self.sources = None
def start(self, name, file_path, bid, title=None, description=None, thumbnail=None,
key_fee=None, key_fee_address=None, content_license=None, author=None, sources=None):
self.txid = None
self.stream_hash = None
reflector_server = random.choice(REFLECTOR_SERVERS)
self.reflector_server, self.reflector_port = reflector_server[0], reflector_server[1]
self.metadata = {}
def start(self, name, file_path, bid, metadata):
log.info('Starting publish for %s', name)
def _show_result():
message = "[" + str(datetime.now()) + "] Published " + self.file_name + " --> lbry://" + \
str(self.publish_name) + " with txid: " + str(self.tx_hash)
log.info(message)
return defer.succeed(self.tx_hash)
log.info("Success! Published %s --> lbry://%s txid: %s", self.file_name, self.publish_name, self.txid)
return defer.succeed(self.txid)
self.publish_name = name
self.file_path = file_path
self.bid_amount = bid
self.title = title
self.description = description
self.thumbnail = thumbnail
self.key_fee = key_fee
self.key_fee_address = key_fee_address
self.content_license = content_license
self.author = author
self.sources = sources
self.metadata = metadata
if os.name == "nt":
file_mode = 'rb'
else:
file_mode = 'r'
d = self._check_file_path(self.file_path)
d.addCallback(lambda _: create_lbry_file(self.session, self.lbry_file_manager,
self.file_name, open(self.file_path)))
self.file_name, open(self.file_path, file_mode)))
d.addCallback(self.add_to_lbry_files)
d.addCallback(lambda _: self._create_sd_blob())
d.addCallback(lambda _: self._claim_name())
d.addCallback(lambda _: self.set_status())
d.addCallback(lambda _: self.start_reflector())
d.addCallbacks(lambda _: _show_result(), self._show_publish_error)
return d
def start_reflector(self):
reflector_server = random.choice(REFLECTOR_SERVERS)
reflector_address, reflector_port = reflector_server[0], reflector_server[1]
log.info("Reflecting new publication")
factory = reflector.ClientFactory(
self.session.blob_manager,
self.lbry_file_manager.stream_info_manager,
self.stream_hash
)
d = reactor.resolve(reflector_address)
d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory))
d.addCallback(lambda _: factory.finished_deferred)
return d
def _check_file_path(self, file_path):
def check_file_threaded():
f = open(file_path)
@@ -91,59 +96,69 @@ class Publisher(object):
return True
return threads.deferToThread(check_file_threaded)
def _get_new_address(self):
d = self.wallet.get_new_address()
def set_address(address):
self.key_fee_address = address
return True
d.addCallback(set_address)
return d
def set_status(self, lbry_file_downloader):
def set_lbry_file(self, lbry_file_downloader):
self.lbry_file = lbry_file_downloader
d = self.lbry_file_manager.change_lbry_file_status(self.lbry_file, ManagedLBRYFileDownloader.STATUS_FINISHED)
d.addCallback(lambda _: lbry_file_downloader.restore())
return d
return defer.succeed(None)
def add_to_lbry_files(self, stream_hash):
self.stream_hash = stream_hash
prm = PaymentRateManager(self.session.base_payment_rate_manager)
d = self.lbry_file_manager.add_lbry_file(stream_hash, prm)
d.addCallback(self.set_status)
d.addCallback(self.set_lbry_file)
return d
def _create_sd_blob(self):
d = publish_sd_blob(self.lbry_file_manager.stream_info_manager, self.session.blob_manager,
log.debug('Creating stream descriptor blob')
d = publish_sd_blob(self.lbry_file_manager.stream_info_manager,
self.session.blob_manager,
self.lbry_file.stream_hash)
def set_sd_hash(sd_hash):
self.sd_hash = sd_hash
log.debug('stream descriptor hash: %s', sd_hash)
if 'sources' not in self.metadata:
self.metadata['sources'] = {}
self.metadata['sources']['lbry_sd_hash'] = sd_hash
d.addCallback(set_sd_hash)
return d
def set_status(self):
log.debug('Setting status')
d = self.lbry_file_manager.change_lbry_file_status(self.lbry_file, ManagedLBRYFileDownloader.STATUS_FINISHED)
d.addCallback(lambda _: self.lbry_file.restore())
return d
def _claim_name(self):
d = self.wallet.claim_name(self.publish_name, self.sd_hash, self.bid_amount,
description=self.description, key_fee=self.key_fee,
key_fee_address=self.key_fee_address, thumbnail=self.thumbnail,
content_license=self.content_license, author=self.author,
sources=self.sources)
log.debug('Claiming name')
self._update_metadata()
m = Metadata(self.metadata)
def set_tx_hash(tx_hash):
self.tx_hash = tx_hash
def set_tx_hash(txid):
log.debug('Name claimed using txid: %s', txid)
self.txid = txid
d = self.wallet.claim_name(self.publish_name, self.bid_amount, m)
d.addCallback(set_tx_hash)
return d
def _update_metadata(self):
filename = os.path.join(self.lbry_file.download_directory, self.lbry_file.file_name)
self.metadata['content_type'] = get_content_type(filename)
self.metadata['ver'] = Metadata.current_version
def _show_publish_error(self, err):
log.info(err.getTraceback())
message = "An error occurred publishing %s to %s. Error: %s."
if err.check(InsufficientFundsError):
error_message = "Insufficient funds"
else:
d = defer.succeed(True)
error_message = err.getErrorMessage()
log.error(error_message)
log.error(message, str(self.file_name), str(self.publish_name), err.getTraceback())
return d
return defer.fail(Exception("Publish failed"))
def get_content_type(filename):
return mimetypes.guess_type(filename)[0]
+25 -13
View File
@@ -8,9 +8,10 @@ from urllib2 import urlopen
from StringIO import StringIO
from twisted.web import static
from twisted.internet import defer
from twisted.internet.task import LoopingCall
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 lbryum.version import LBRYUM_VERSION as lbryum_version
from zipfile import ZipFile
from appdirs import user_data_dir
@@ -24,9 +25,6 @@ if not os.path.isdir(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):
@@ -52,9 +50,12 @@ class LBRYUIManager(object):
self.config = os.path.join(self.ui_root, "active.json")
self.update_requires = os.path.join(self.update_dir, "requirements.txt")
self.requirements = {}
self.check_requirements = True
self.ui_dir = self.active_dir
self.git_version = None
self.root = root
self.branch = None
self.update_checker = LoopingCall(self.setup)
if not os.path.isfile(os.path.join(self.config)):
self.loaded_git_version = None
@@ -73,8 +74,11 @@ class LBRYUIManager(object):
self.loaded_branch = None
self.loaded_requirements = None
def setup(self, branch=DEFAULT_UI_BRANCH, user_specified=None, branch_specified=False):
self.branch = branch
def setup(self, branch=DEFAULT_UI_BRANCH, user_specified=None, branch_specified=False, check_requirements=None):
if check_requirements is not None:
self.check_requirements = check_requirements
if self.branch is not None:
self.branch = branch
if user_specified:
if os.path.isdir(user_specified):
log.info("Checking user specified UI directory: " + str(user_specified))
@@ -84,15 +88,15 @@ class LBRYUIManager(object):
d.addCallback(lambda _: self._load_ui())
return d
else:
log.info("User specified UI directory doesn't exist, using " + branch)
log.info("User specified UI directory doesn't exist, using " + self.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
self._git_url = "https://s3.amazonaws.com/lbry-ui/{}/data.json".format(branch)
self._dist_url = "https://s3.amazonaws.com/lbry-ui/{}/dist.zip".format(branch)
d = self._up_to_date()
d.addCallback(lambda r: self._download_ui() if not r else self._load_ui())
@@ -102,7 +106,7 @@ class LBRYUIManager(object):
def _get_git_info():
response = urlopen(self._git_url)
data = json.loads(response.read())
return defer.succeed(data['object']['sha'])
return defer.succeed(data['sha'])
def _set_git(version):
self.git_version = version.replace('\n', '')
@@ -113,8 +117,12 @@ class LBRYUIManager(object):
log.info("UI updates available, checking if installation meets requirements")
return defer.succeed(False)
def _use_existing():
log.info("Failed to check for new ui version, trying to use cached ui")
return defer.succeed(True)
d = _get_git_info()
d.addCallback(_set_git)
d.addCallbacks(_set_git, lambda _: _use_existing)
return d
def migrate_ui(self, source=None):
@@ -127,6 +135,10 @@ class LBRYUIManager(object):
source_dir = source
delete_source = False
def _skip_requirements():
log.info("Skipping ui requirement check")
return defer.succeed(True)
def _check_requirements():
if not os.path.isfile(requires_file):
log.info("No requirements.txt file, rejecting request to migrate this UI")
@@ -197,7 +209,7 @@ class LBRYUIManager(object):
self.loaded_requirements = loaded_ui['requirements']
return defer.succeed(True)
d = _check_requirements()
d = _check_requirements() if self.check_requirements else _skip_requirements()
d.addCallback(lambda r: _do_migrate() if r else _disp_failure())
return d
@@ -224,4 +236,4 @@ class LBRYUIManager(object):
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)
return defer.succeed(True)
+27
View File
@@ -0,0 +1,27 @@
import logging
import random
from txjsonrpc.web.jsonrpc import Proxy
from lbrynet.conf import SEARCH_SERVERS
log = logging.getLogger(__name__)
class LighthouseClient(object):
def __init__(self, servers=None):
self.servers = servers or SEARCH_SERVERS
def _get_random_server(self):
return Proxy(random.choice(self.servers))
def _run_query(self, func, arg):
return self._get_random_server().callRemote(func, arg)
def search(self, search):
return self._run_query('search', search)
def announce_sd(self, sd_hash):
log.info("Announce sd to lighthouse")
return self._run_query('announce_sd', sd_hash)
def check_available(self, sd_hash):
return self._run_query('check_available', sd_hash)
-352
View File
@@ -1,352 +0,0 @@
import Tkinter as tk
import logging
import sys
import tkFont
import tkMessageBox
import ttk
from lbrynet.lbrynet_gui.LBRYGui import LBRYDownloader
from lbrynet.lbrynet_gui.StreamFrame import StreamFrame
import locale
import os
from twisted.internet import defer, reactor, tksupport, task
log = logging.getLogger(__name__)
class DownloaderApp(object):
def __init__(self):
self.master = None
self.downloader = None
self.wallet_balance_check = None
self.streams_frame = None
def start(self):
d = defer.maybeDeferred(self._start_root)
d.addCallback(lambda _: self._draw_main())
d.addCallback(lambda _: self._start_downloader())
d.addCallback(lambda _: self._start_checking_wallet_balance())
d.addCallback(lambda _: self._enable_lookup())
def show_error_and_stop(err):
log.error(err.getErrorMessage())
tkMessageBox.showerror(title="Start Error", message=err.getErrorMessage())
return self.stop()
d.addErrback(show_error_and_stop)
return d
def stop(self):
def log_error(err):
log.error(err.getErrorMessage())
if self.downloader is not None:
d = self.downloader.stop()
else:
d = defer.succeed(True)
d.addErrback(log_error)
d.addCallback(lambda _: self._stop_checking_wallet_balance())
d.addErrback(log_error)
d.addCallback(lambda _: reactor.stop())
d.addErrback(log_error)
return d
def _start_root(self):
if os.name == "nt":
button_foreground = "#104639"
lookup_button_padding = 10
else:
button_foreground = "#FFFFFF"
lookup_button_padding = 11
root = tk.Tk()
root.resizable(0, 0)
root.wm_title("LBRY")
tksupport.install(root)
if os.name == "nt":
root.iconbitmap(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),
"lbry-dark-icon.ico"))
else:
root.wm_iconbitmap("@" + os.path.join(os.path.dirname(__file__), "lbry-dark-icon.xbm"))
root.button_font = tkFont.Font(size=9)
ttk.Style().configure(".", background="#FFFFFF")
ttk.Style().configure("LBRY.TButton", background="#104639", foreground=button_foreground,
borderwidth=1, relief="solid", font=root.button_font)
ttk.Style().map("LBRY.TButton",
background=[('pressed', "#104639"),
('active', "#104639")])
#ttk.Style().configure("LBRY.TButton.border", background="#808080")
ttk.Style().configure("Lookup.LBRY.TButton", padding=lookup_button_padding)
ttk.Style().configure("Stop.TButton", padding=1, background="#FFFFFF", relief="flat", borderwidth=0)
ttk.Style().configure("TEntry", padding=11)
ttk.Style().configure("Float.TEntry", padding=2)
#ttk.Style().configure("A.TFrame", background="red")
#ttk.Style().configure("B.TFrame", background="green")
#ttk.Style().configure("B2.TFrame", background="#80FF80")
#ttk.Style().configure("C.TFrame", background="orange")
#ttk.Style().configure("D.TFrame", background="blue")
#ttk.Style().configure("E.TFrame", background="yellow")
#ttk.Style().configure("F.TFrame", background="#808080")
#ttk.Style().configure("G.TFrame", background="#FF80FF")
#ttk.Style().configure("H.TFrame", background="#0080FF")
#ttk.Style().configure("LBRY.TProgressbar", background="#104639", orient="horizontal", thickness=5)
#ttk.Style().configure("LBRY.TProgressbar")
#ttk.Style().layout("Horizontal.LBRY.TProgressbar", ttk.Style().layout("Horizontal.TProgressbar"))
root.configure(background="#FFFFFF")
root.protocol("WM_DELETE_WINDOW", self.stop)
self.master = root
def _draw_main(self):
self.frame = ttk.Frame(self.master, style="A.TFrame")
self.frame.grid(padx=20, pady=20)
logo_file_name = "lbry-dark-242x80.gif"
if os.name == "nt":
logo_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), logo_file_name)
else:
logo_file = os.path.join(os.path.dirname(__file__), logo_file_name)
self.logo_picture = tk.PhotoImage(file=logo_file)
self.logo_frame = ttk.Frame(self.frame, style="B.TFrame")
self.logo_frame.grid(pady=5, sticky=tk.W + tk.E)
self.dummy_frame = ttk.Frame(self.logo_frame, style="C.TFrame") # keeps the logo in the middle
self.dummy_frame.grid(row=0, column=1, padx=5)
self.logo_label = ttk.Label(self.logo_frame, image=self.logo_picture)
self.logo_label.grid(row=0, column=1, padx=5)
self.wallet_balance_frame = ttk.Frame(self.logo_frame, style="C.TFrame")
self.wallet_balance_frame.grid(sticky=tk.E + tk.N, row=0, column=2)
self.logo_frame.grid_columnconfigure(0, weight=1, uniform="a")
self.logo_frame.grid_columnconfigure(1, weight=2, uniform="b")
self.logo_frame.grid_columnconfigure(2, weight=1, uniform="a")
self.wallet_balance = ttk.Label(
self.wallet_balance_frame,
text=" -- LBC"
)
self.wallet_balance.grid(row=0, column=0)
dropdown_file_name = "drop_down.gif"
if os.name == "nt":
dropdown_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),
dropdown_file_name)
else:
dropdown_file = os.path.join(os.path.dirname(__file__), dropdown_file_name)
self.dropdown_picture = tk.PhotoImage(
file=dropdown_file
)
def get_new_address():
def show_address(address):
w = AddressWindow(self.master, address)
w.show()
d = defer.maybeDeferred(self.downloader.get_new_address)
d.addCallback(show_address)
def show_error(err):
tkMessageBox.showerror(title="Failed to get new address", message=err.getErrorMessage())
d.addErrback(show_error)
self.wallet_menu = tk.Menu(
self.master, tearoff=0
)
self.wallet_menu.add_command(label="Get new LBRYcrd address", command=get_new_address)
if os.name == "nt":
button_cursor = ""
else:
button_cursor = "hand1"
self.wallet_menu_button = ttk.Button(self.wallet_balance_frame, image=self.dropdown_picture,
style="Stop.TButton", cursor=button_cursor)
self.wallet_menu_button.grid(row=0, column=1, padx=(5, 0))
def popup_wallet(event):
self.wallet_menu.tk_popup(event.x_root, event.y_root)
self.wallet_menu_button.bind("<Button-1>", popup_wallet)
self.uri_frame = ttk.Frame(self.frame, style="B.TFrame")
self.uri_frame.grid()
self.uri_label = ttk.Label(
self.uri_frame, text="lbry://"
)
self.uri_label.grid(row=0, column=0, sticky=tk.E, pady=2)
self.entry_font = tkFont.Font(size=11)
self.uri_entry = ttk.Entry(self.uri_frame, width=50, foreground="#222222", font=self.entry_font,
state=tk.DISABLED)
self.uri_entry.grid(row=0, column=1, padx=2, pady=2)
def copy_command():
self.uri_entry.event_generate('<Control-c>')
def cut_command():
self.uri_entry.event_generate('<Control-x>')
def paste_command():
self.uri_entry.event_generate('<Control-v>')
def popup_uri(event):
selection_menu = tk.Menu(
self.master, tearoff=0
)
if self.uri_entry.selection_present():
selection_menu.add_command(label=" Cut ", command=cut_command)
selection_menu.add_command(label=" Copy ", command=copy_command)
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_uri)
self.uri_button = ttk.Button(
self.uri_frame, text="Go", command=self._open_stream,
style='Lookup.LBRY.TButton', cursor=button_cursor
)
self.uri_button.grid(row=0, column=2, pady=2, padx=0)
def _start_downloader(self):
self.downloader = LBRYDownloader()
d = self.downloader.start()
d.addCallback(lambda _: self.downloader.check_first_run())
d.addCallback(self._show_welcome_message)
return d
def _show_welcome_message(self, points_sent):
if points_sent != 0.0:
w = WelcomeWindow(self.master, points_sent)
w.show()
def stream_removed(self):
if self.streams_frame is not None:
if len(self.streams_frame.winfo_children()) == 0:
self.streams_frame.destroy()
self.streams_frame = None
def _start_checking_wallet_balance(self):
def set_balance(balance):
self.wallet_balance.configure(text=locale.format_string("%.2f LBC", (round(balance, 2),),
grouping=True))
def update_balance():
balance = self.downloader.session.wallet.get_available_balance()
set_balance(balance)
def start_looping_call():
self.wallet_balance_check = task.LoopingCall(update_balance)
self.wallet_balance_check.start(5)
d = self.downloader.session.wallet.get_balance()
d.addCallback(set_balance)
d.addCallback(lambda _: start_looping_call())
def _stop_checking_wallet_balance(self):
if self.wallet_balance_check is not None:
self.wallet_balance_check.stop()
def _enable_lookup(self):
self.uri_entry.bind('<Return>', self._open_stream)
self.uri_entry.config(state=tk.NORMAL)
def _open_stream(self, event=None):
if self.streams_frame is None:
self.streams_frame = ttk.Frame(self.frame, style="B2.TFrame")
self.streams_frame.grid(sticky=tk.E + tk.W)
uri = self.uri_entry.get()
self.uri_entry.delete(0, tk.END)
stream_frame = StreamFrame(self, "lbry://" + uri)
self.downloader.download_stream(stream_frame, uri)
class WelcomeWindow(object):
def __init__(self, root, points_sent):
self.root = root
self.points_sent = points_sent
def show(self):
window = tk.Toplevel(self.root, background="#FFFFFF")
window.transient(self.root)
window.wm_title("Welcome to LBRY")
window.protocol("WM_DELETE_WINDOW", window.destroy)
window.resizable(0, 0)
text_box = tk.Text(window, width=45, height=3, relief=tk.FLAT, borderwidth=0,
highlightthickness=0)
points_string = locale.format_string("%.2f LBC", (round(self.points_sent, 2),),
grouping=True)
text_box.insert(tk.END, "Thank you for using LBRY! You have been\n"
"given %s for free because we love\n"
"you. Please give them 60 seconds to show up." % points_string)
text_box.grid(row=0, padx=10, pady=5, columnspan=2)
text_box.config(state='normal')
window.focus_set()
class AddressWindow(object):
def __init__(self, root, address):
self.root = root
self.address = address
def show(self):
window = tk.Toplevel(self.root, background="#FFFFFF")
window.transient(self.root)
window.wm_title("New address")
window.protocol("WM_DELETE_WINDOW", window.destroy)
window.resizable(0, 0)
text_box = tk.Text(window, width=35, height=1, relief=tk.FLAT, borderwidth=0,
highlightthickness=0)
text_box.insert(tk.END, self.address)
text_box.grid(row=0, padx=10, pady=5, columnspan=2)
text_box.config(state='normal')
def copy_to_clipboard():
self.root.clipboard_clear()
self.root.clipboard_append(text_box.get('1.0', 'end-1c'))
def copy_command():
text_box.event_generate("<Control-c>")
copy_menu = tk.Menu(
self.root, tearoff=0
)
copy_menu.add_command(label=" Copy ", command=copy_command)
def popup(event):
if text_box.tag_ranges("sel"):
copy_menu.tk_popup(event.x_root, event.y_root)
text_box.bind("<Button-3>", popup)
copy_button = ttk.Button(
window, text="Copy", command=copy_to_clipboard, style="LBRY.TButton"
)
copy_button.grid(row=1, column=0, pady=(0, 5), padx=5, sticky=tk.E)
done_button = ttk.Button(
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()
@@ -1,393 +0,0 @@
Attribution 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More_considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution 4.0 International Public License ("Public License"). To the
extent this Public License may be interpreted as a contract, You are
granted the Licensed Rights in consideration of Your acceptance of
these terms and conditions, and the Licensor grants You such rights in
consideration of benefits the Licensor receives from making the
Licensed Material available under these terms and conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
d. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
g. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
i. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part; and
b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's
License You apply must not prevent recipients of the Adapted
Material from complying with this Public License.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public licenses.
Notwithstanding, Creative Commons may elect to apply one of its public
licenses to material it publishes and in those instances will be
considered the "Licensor." Except for the limited purpose of indicating
that material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the public
licenses.
Creative Commons may be contacted at creativecommons.org.
-571
View File
@@ -1,571 +0,0 @@
import binascii
import logging
import tkMessageBox
from Crypto import Random
from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE
from lbrynet.core import StreamDescriptor
from lbrynet.core.Error import UnknownNameError, UnknownStreamTypeError, InvalidStreamDescriptorError
from lbrynet.core.Error import InvalidStreamInfoError
from lbrynet.core.LBRYcrdWallet import LBRYcrdWallet
from lbrynet.core.PaymentRateManager import PaymentRateManager
from lbrynet.core.Session import LBRYSession
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier
from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerFactory
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
from lbrynet.lbryfile.LBRYFileMetadataManager import TempLBRYFileMetadataManager
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
import os
import requests
import shutil
import sys
from twisted.internet import threads, defer, task
log = logging.getLogger(__name__)
class LBRYDownloader(object):
def __init__(self):
self.session = None
self.known_dht_nodes = [('104.236.42.182', 4000)]
self.db_dir = os.path.join(os.path.expanduser("~"), ".lbrydownloader")
self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
self.peer_port = 3333
self.dht_node_port = 4444
self.run_server = True
self.first_run = False
self.current_db_revision = 1
if os.name == "nt":
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
self.download_directory = get_path(FOLDERID.Downloads, UserHandle.current)
self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbrycrd")
else:
if sys.platform == 'darwin':
self.download_directory = os.path.join(os.path.expanduser("~"), "Downloads")
self.wallet_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrycrd")
else:
self.download_directory = os.getcwd()
self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
self.wallet_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
self.wallet_user = None
self.wallet_password = None
self.sd_identifier = StreamDescriptorIdentifier()
self.wallet_rpc_port = 8332
self.download_deferreds = []
self.stream_frames = []
self.default_blob_data_payment_rate = MIN_BLOB_DATA_PAYMENT_RATE
self.use_upnp = True
self.start_lbrycrdd = True
if os.name == "nt":
self.lbrycrdd_path = "lbrycrdd.exe"
else:
self.lbrycrdd_path = None
self.default_lbrycrdd_path = "./lbrycrdd"
self.delete_blobs_on_remove = True
self.blob_request_payment_rate_manager = None
def start(self):
d = self._load_conf_options()
d.addCallback(lambda _: threads.deferToThread(self._create_directory))
d.addCallback(lambda _: self._check_db_migration())
d.addCallback(lambda _: self._get_session())
d.addCallback(lambda _: self._setup_stream_info_manager())
d.addCallback(lambda _: self._setup_stream_identifier())
d.addCallback(lambda _: self.start_server())
return d
def stop(self):
dl = defer.DeferredList(self.download_deferreds)
for stream_frame in self.stream_frames:
stream_frame.cancel_func()
if self.session is not None:
dl.addBoth(lambda _: self.stop_server())
dl.addBoth(lambda _: self.session.shut_down())
return dl
def get_new_address(self):
return self.session.wallet.get_new_address()
def _check_db_migration(self):
old_revision = 0
db_revision_file = os.path.join(self.db_dir, "db_revision")
if os.path.exists(db_revision_file):
old_revision = int(open(db_revision_file).read().strip())
if old_revision < self.current_db_revision:
if os.name == "nt":
import subprocess
import sys
def run_migrator():
migrator_exe = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),
"dbmigrator", "migrator.exe")
print "trying to find the migrator at", migrator_exe
si = subprocess.STARTUPINFO
si.dwFlags = subprocess.STARTF_USESHOWWINDOW
si.wShowWindow = subprocess.SW_HIDE
print "trying to run the migrator"
migrator_proc = subprocess.Popen([migrator_exe, self.db_dir, str(old_revision),
str(self.current_db_revision)], startupinfo=si)
print "started the migrator"
migrator_proc.wait()
print "migrator has returned"
return threads.deferToThread(run_migrator)
else:
from lbrynet.db_migrator import dbmigrator
return threads.deferToThread(dbmigrator.migrate_db, self.db_dir, old_revision,
self.current_db_revision)
return defer.succeed(True)
def _load_conf_options(self):
def get_lbrycrdd_path_conf_file():
if os.name == "nt":
return ""
lbrycrdd_path_conf_path = os.path.join(os.path.expanduser("~"), ".lbrycrddpath.conf")
if not os.path.exists(lbrycrdd_path_conf_path):
return ""
lbrycrdd_path_conf = open(lbrycrdd_path_conf_path)
lines = lbrycrdd_path_conf.readlines()
return lines
d = threads.deferToThread(get_lbrycrdd_path_conf_file)
def load_lbrycrdd_path(conf):
for line in conf:
if len(line.strip()) and line.strip()[0] != "#":
self.lbrycrdd_path = line.strip()
d.addCallback(load_lbrycrdd_path)
def get_configuration_file():
if os.name == "nt":
lbry_conf_path = "lbry.conf"
if not os.path.exists(lbry_conf_path):
log.debug("Could not read lbry.conf")
return ""
else:
lbry_conf_path = os.path.join(os.path.expanduser("~"), ".lbrynetgui.conf")
if not os.path.exists(lbry_conf_path):
clean_conf_path = os.path.join(os.path.dirname(__file__), "lbry.conf")
shutil.copy(clean_conf_path, lbry_conf_path)
lbry_conf = open(lbry_conf_path)
log.debug("Loading configuration options from %s", lbry_conf_path)
lines = lbry_conf.readlines()
log.debug("%s file contents:\n%s", lbry_conf_path, str(lines))
return lines
d.addCallback(lambda _: threads.deferToThread(get_configuration_file))
def load_configuration_file(conf):
for line in conf:
if len(line.strip()) and line.strip()[0] != "#":
try:
field_name, field_value = map(lambda x: x.strip(), line.strip().split("=", 1))
field_name = field_name.lower()
except ValueError:
raise ValueError("Invalid configuration line: %s" % line)
if field_name == "known_dht_nodes":
known_nodes = []
nodes = field_value.split(",")
for n in nodes:
if n.strip():
try:
ip_address, port_string = map(lambda x: x.strip(), n.split(":"))
ip_numbers = ip_address.split(".")
assert len(ip_numbers) == 4
for ip_num in ip_numbers:
num = int(ip_num)
assert 0 <= num <= 255
known_nodes.append((ip_address, int(port_string)))
except (ValueError, AssertionError):
raise ValueError("Expected known nodes in format 192.168.1.1:4000,192.168.1.2:4001. Got %s" % str(field_value))
log.debug("Setting known_dht_nodes to %s", str(known_nodes))
self.known_dht_nodes = known_nodes
elif field_name == "run_server":
if field_value.lower() == "true":
run_server = True
elif field_value.lower() == "false":
run_server = False
else:
raise ValueError("run_server must be set to True or False. Got %s" % field_value)
log.debug("Setting run_server to %s", str(run_server))
self.run_server = run_server
elif field_name == "data_dir":
log.debug("Setting data_dir to %s", str(field_value))
self.db_dir = field_value
self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
elif field_name == "wallet_dir":
log.debug("Setting wallet_dir to %s", str(field_value))
self.wallet_dir = field_value
elif field_name == "wallet_conf":
log.debug("Setting wallet_conf to %s", str(field_value))
self.wallet_conf = field_value
elif field_name == "peer_port":
try:
peer_port = int(field_value)
assert 0 <= peer_port <= 65535
log.debug("Setting peer_port to %s", str(peer_port))
self.peer_port = peer_port
except (ValueError, AssertionError):
raise ValueError("peer_port must be set to an integer between 1 and 65535. Got %s" % field_value)
elif field_name == "dht_port":
try:
dht_port = int(field_value)
assert 0 <= dht_port <= 65535
log.debug("Setting dht_node_port to %s", str(dht_port))
self.dht_node_port = dht_port
except (ValueError, AssertionError):
raise ValueError("dht_port must be set to an integer between 1 and 65535. Got %s" % field_value)
elif field_name == "use_upnp":
if field_value.lower() == "true":
use_upnp = True
elif field_value.lower() == "false":
use_upnp = False
else:
raise ValueError("use_upnp must be set to True or False. Got %s" % str(field_value))
log.debug("Setting use_upnp to %s", str(use_upnp))
self.use_upnp = use_upnp
elif field_name == "default_blob_data_payment_rate":
try:
rate = float(field_value)
assert rate >= 0.0
log.debug("Setting default_blob_data_payment_rate to %s", str(rate))
self.default_blob_data_payment_rate = rate
except (ValueError, AssertionError):
raise ValueError("default_blob_data_payment_rate must be a positive floating point number, e.g. 0.5. Got %s" % str(field_value))
elif field_name == "start_lbrycrdd":
if field_value.lower() == "true":
start_lbrycrdd = True
elif field_value.lower() == "false":
start_lbrycrdd = False
else:
raise ValueError("start_lbrycrdd must be set to True or False. Got %s" % field_value)
log.debug("Setting start_lbrycrdd to %s", str(start_lbrycrdd))
self.start_lbrycrdd = start_lbrycrdd
elif field_name == "lbrycrdd_path":
self.lbrycrdd_path = field_value
elif field_name == "download_directory":
log.debug("Setting download_directory to %s", str(field_value))
self.download_directory = field_value
elif field_name == "delete_blobs_on_stream_remove":
if field_value.lower() == "true":
self.delete_blobs_on_remove = True
elif field_value.lower() == "false":
self.delete_blobs_on_remove = False
else:
raise ValueError("delete_blobs_on_stream_remove must be set to True or False")
else:
log.warning("Got unknown configuration field: %s", field_name)
d.addCallback(load_configuration_file)
return d
def _create_directory(self):
if not os.path.exists(self.db_dir):
os.makedirs(self.db_dir)
db_revision = open(os.path.join(self.db_dir, "db_revision"), mode='w')
db_revision.write(str(self.current_db_revision))
db_revision.close()
log.debug("Created the configuration directory: %s", str(self.db_dir))
if not os.path.exists(self.blobfile_dir):
os.makedirs(self.blobfile_dir)
log.debug("Created the data directory: %s", str(self.blobfile_dir))
if os.name == "nt":
if not os.path.exists(self.wallet_dir):
os.makedirs(self.wallet_dir)
if not os.path.exists(self.wallet_conf):
lbrycrd_conf = open(self.wallet_conf, mode='w')
self.wallet_user = "rpcuser"
lbrycrd_conf.write("rpcuser=%s\n" % self.wallet_user)
self.wallet_password = binascii.hexlify(Random.new().read(20))
lbrycrd_conf.write("rpcpassword=%s\n" % self.wallet_password)
lbrycrd_conf.write("server=1\n")
lbrycrd_conf.close()
else:
lbrycrd_conf = open(self.wallet_conf)
for l in lbrycrd_conf:
if l.startswith("rpcuser="):
self.wallet_user = l[8:].rstrip('\n')
if l.startswith("rpcpassword="):
self.wallet_password = l[12:].rstrip('\n')
if l.startswith("rpcport="):
self.wallet_rpc_port = int(l[8:-1].rstrip('\n'))
def _get_session(self):
lbrycrdd_path = None
if self.start_lbrycrdd is True:
lbrycrdd_path = self.lbrycrdd_path
if not lbrycrdd_path:
lbrycrdd_path = self.default_lbrycrdd_path
if sys.platform == 'darwin':
os.chdir("/Applications/LBRY.app/Contents/Resources")
wallet = LBRYcrdWallet(self.db_dir, wallet_dir=self.wallet_dir, wallet_conf=self.wallet_conf,
lbrycrdd_path=lbrycrdd_path)
peer_port = None
if self.run_server:
peer_port = self.peer_port
self.session = LBRYSession(self.default_blob_data_payment_rate, db_dir=self.db_dir,
blob_dir=self.blobfile_dir, use_upnp=self.use_upnp, wallet=wallet,
known_dht_nodes=self.known_dht_nodes, dht_node_port=self.dht_node_port,
peer_port=peer_port)
return self.session.setup()
def _setup_stream_info_manager(self):
self.stream_info_manager = TempLBRYFileMetadataManager()
return defer.succeed(True)
def start_server(self):
if self.run_server:
self.blob_request_payment_rate_manager = PaymentRateManager(
self.session.base_payment_rate_manager,
self.default_blob_data_payment_rate
)
handlers = [
BlobAvailabilityHandlerFactory(self.session.blob_manager),
self.session.wallet.get_wallet_info_query_handler_factory(),
BlobRequestHandlerFactory(self.session.blob_manager, self.session.wallet,
self.blob_request_payment_rate_manager)
]
server_factory = ServerProtocolFactory(self.session.rate_limiter,
handlers,
self.session.peer_manager)
from twisted.internet import reactor
self.lbry_server_port = reactor.listenTCP(self.peer_port, server_factory)
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:
return defer.succeed(True)
def _setup_stream_identifier(self):
add_lbry_file_to_sd_identifier(self.sd_identifier)
file_saver_factory = LBRYFileSaverFactory(self.session.peer_finder, self.session.rate_limiter,
self.session.blob_manager, self.stream_info_manager,
self.session.wallet, self.download_directory)
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, file_saver_factory)
file_opener_factory = LBRYFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter,
self.session.blob_manager, self.stream_info_manager,
self.session.wallet)
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, file_opener_factory)
def check_first_run(self):
d = self.session.wallet.is_first_run()
d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run else 0.0)
return d
def _do_first_run(self):
d = self.session.wallet.get_new_address()
def send_request(url, data):
r = requests.post(url, json=data)
if r.status_code == 200:
return r.json()['credits_sent']
return 0.0
def log_error(err):
log.warning("unable to request free credits. %s", err.getErrorMessage())
return 0.0
def request_credits(address):
url = "http://credreq.lbry.io/requestcredits"
data = {"address": address}
d = threads.deferToThread(send_request, url, data)
d.addErrback(log_error)
return d
d.addCallback(request_credits)
return d
def _resolve_name(self, uri):
return self.session.wallet.get_stream_info_for_name(uri)
def download_stream(self, stream_frame, uri):
resolve_d = self._resolve_name(uri)
stream_frame.show_metadata_status("resolving name...")
stream_frame.cancel_func = resolve_d.cancel
payment_rate_manager = PaymentRateManager(self.session.base_payment_rate_manager)
def update_stream_name(value):
if 'name' in value:
stream_frame.show_name(value['name'])
if 'description' in value:
stream_frame.show_description(value['description'])
if 'thumbnail' in value:
stream_frame.show_thumbnail(value['thumbnail'])
return value
def get_sd_hash(value):
if 'stream_hash' in value:
return value['stream_hash']
raise UnknownNameError(uri)
def get_sd_blob(sd_hash):
stream_frame.show_metadata_status("name resolved, fetching metadata...")
get_sd_d = StreamDescriptor.download_sd_blob(self.session, sd_hash,
payment_rate_manager)
get_sd_d.addCallback(self.sd_identifier.get_metadata_for_sd_blob)
get_sd_d.addCallbacks(choose_download_factory, bad_sd_blob)
return get_sd_d
def get_info_from_validator(info_validator):
stream_name = None
stream_size = None
for field, val in info_validator.info_to_show():
if field == "suggested_file_name":
stream_name = val
elif field == "stream_name" and stream_name is None:
stream_name = val
elif field == "stream_size":
stream_size = int(val)
if stream_size is None:
stream_size = "unknown"
if stream_name is None:
stream_name = "unknown"
return stream_name, stream_size
def choose_download_factory(metadata):
#info_validator, options, factories = info_and_factories
stream_name, stream_size = get_info_from_validator(metadata.validator)
if isinstance(stream_size, (int, long)):
price = payment_rate_manager.get_effective_min_blob_data_payment_rate()
estimated_cost = stream_size * 1.0 / 2**20 * price
else:
estimated_cost = "unknown"
stream_frame.show_stream_metadata(stream_name, stream_size, estimated_cost)
available_options = metadata.options.get_downloader_options(metadata.validator,
payment_rate_manager)
stream_frame.show_download_options(available_options)
get_downloader_d = defer.Deferred()
def create_downloader(f, chosen_options):
def fire_get_downloader_d(downloader):
if not get_downloader_d.called:
get_downloader_d.callback(downloader)
stream_frame.disable_download_buttons()
d = f.make_downloader(metadata, chosen_options,
payment_rate_manager)
d.addCallback(fire_get_downloader_d)
for factory in metadata.factories:
def choose_factory(f=factory):
chosen_options = stream_frame.get_chosen_options()
create_downloader(f, chosen_options)
stream_frame.add_download_factory(factory, choose_factory)
get_downloader_d.addCallback(start_download)
return get_downloader_d
def show_stream_status(downloader):
total_bytes = downloader.get_total_bytes_cached()
bytes_left_to_download = downloader.get_bytes_left_to_download()
points_paid = payment_rate_manager.points_paid
payment_rate = payment_rate_manager.get_effective_min_blob_data_payment_rate()
points_remaining = 1.0 * bytes_left_to_download * payment_rate / 2**20
stream_frame.show_progress(total_bytes, bytes_left_to_download,
points_paid, points_remaining)
def show_finished(arg, downloader):
show_stream_status(downloader)
stream_frame.show_download_done(payment_rate_manager.points_paid)
return arg
def start_download(downloader):
stream_frame.stream_hash = downloader.stream_hash
l = task.LoopingCall(show_stream_status, downloader)
l.start(1)
d = downloader.start()
stream_frame.cancel_func = downloader.stop
def stop_looping_call(arg):
l.stop()
stream_frame.cancel_func = resolve_d.cancel
return arg
d.addBoth(stop_looping_call)
d.addCallback(show_finished, downloader)
return d
def lookup_failed(err):
stream_frame.show_metadata_status("name lookup failed")
return err
def bad_sd_blob(err):
stream_frame.show_metadata_status("Unknown type or badly formed metadata")
return err
resolve_d.addCallback(update_stream_name)
resolve_d.addCallback(get_sd_hash)
resolve_d.addCallbacks(get_sd_blob, lookup_failed)
def show_err(err):
tkMessageBox.showerror(title="Download Error", message=err.getErrorMessage())
log.error(err.getErrorMessage())
stream_frame.show_download_done(payment_rate_manager.points_paid)
resolve_d.addErrback(lambda err: err.trap(defer.CancelledError, UnknownNameError,
UnknownStreamTypeError, InvalidStreamDescriptorError,
InvalidStreamInfoError))
resolve_d.addErrback(show_err)
def delete_associated_blobs():
if stream_frame.stream_hash is None or self.delete_blobs_on_remove is False:
return defer.succeed(True)
d1 = self.stream_info_manager.get_blobs_for_stream(stream_frame.stream_hash)
def get_blob_hashes(blob_infos):
return [b[0] for b in blob_infos if b[0] is not None]
d1.addCallback(get_blob_hashes)
d2 = self.stream_info_manager.get_sd_blob_hashes_for_stream(stream_frame.stream_hash)
def combine_blob_hashes(results):
blob_hashes = []
for success, result in results:
if success is True:
blob_hashes.extend(result)
return blob_hashes
def delete_blobs(blob_hashes):
return self.session.blob_manager.delete_blobs(blob_hashes)
dl = defer.DeferredList([d1, d2], fireOnOneErrback=True)
dl.addCallback(combine_blob_hashes)
dl.addCallback(delete_blobs)
return dl
resolve_d.addCallback(lambda _: delete_associated_blobs())
self._add_download_deferred(resolve_d, stream_frame)
def _add_download_deferred(self, d, stream_frame):
self.download_deferreds.append(d)
self.stream_frames.append(stream_frame)
def remove_from_list():
self.download_deferreds.remove(d)
self.stream_frames.remove(stream_frame)
d.addBoth(lambda _: remove_from_list())
-463
View File
@@ -1,463 +0,0 @@
import Tkinter as tk
import sys
import tkFont
import ttk
import locale
import os
class StreamFrame(object):
def __init__(self, app, uri):
self.app = app
self.uri = uri
self.stream_hash = None
self.cancel_func = None
self.stream_frame = ttk.Frame(self.app.streams_frame, style="B.TFrame")
self.stream_frame.pack(fill=tk.X, side=tk.BOTTOM, pady=(30, 0))
self.stream_frame_header = ttk.Frame(self.stream_frame, style="C.TFrame")
self.stream_frame_header.grid(sticky=tk.E + tk.W)
self.uri_font = tkFont.Font(size=8)
self.uri_label = ttk.Label(
self.stream_frame_header, text=self.uri, font=self.uri_font, foreground="#666666"
)
self.uri_label.grid(row=0, column=0, sticky=tk.W)
if os.name == "nt":
self.button_cursor = ""
else:
self.button_cursor = "hand1"
close_file_name = "close2.gif"
if os.name == "nt":
close_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), close_file_name)
else:
close_file = os.path.join(os.path.dirname(__file__), close_file_name)
self.close_picture = tk.PhotoImage(
file=close_file
)
self.close_button = ttk.Button(
self.stream_frame_header, command=self.cancel, style="Stop.TButton", cursor=self.button_cursor
)
self.close_button.config(image=self.close_picture)
self.close_button.grid(row=0, column=1, sticky=tk.E + tk.N)
self.stream_frame_header.grid_columnconfigure(0, weight=1)
self.stream_frame.grid_columnconfigure(0, weight=1)
self.stream_frame_body = ttk.Frame(self.stream_frame, style="C.TFrame")
self.stream_frame_body.grid(row=1, column=0, sticky=tk.E + tk.W)
self.name_frame = ttk.Frame(self.stream_frame_body, style="D.TFrame")
self.name_frame.grid(sticky=tk.W + tk.E)
self.name_frame.grid_columnconfigure(0, weight=16)
self.name_frame.grid_columnconfigure(1, weight=1)
self.stream_frame_body.grid_columnconfigure(0, weight=1)
self.metadata_frame = ttk.Frame(self.stream_frame_body, style="D.TFrame")
self.metadata_frame.grid(sticky=tk.W + tk.E, row=1)
self.metadata_frame.grid_columnconfigure(0, weight=1)
self.options_frame = ttk.Frame(self.stream_frame_body, style="D.TFrame")
self.outer_button_frame = ttk.Frame(self.stream_frame_body, style="D.TFrame")
self.outer_button_frame.grid(sticky=tk.W + tk.E, row=4)
#show_options_picture_file_name = "show_options.gif"
#if os.name == "nt":
# show_options_picture_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),
# "lbrynet", "lbrynet_downloader_gui",
# show_options_picture_file_name)
#else:
# show_options_picture_file = os.path.join(os.path.dirname(__file__),
# show_options_picture_file_name)
#self.show_options_picture = tk.PhotoImage(
# file=show_options_picture_file
#)
#hide_options_picture_file_name = "hide_options.gif"
#if os.name == "nt":
# hide_options_picture_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),
# "lbrynet", "lbrynet_downloader_gui",
# hide_options_picture_file_name)
#else:
# hide_options_picture_file = os.path.join(os.path.dirname(__file__),
# hide_options_picture_file_name)
#self.hide_options_picture = tk.PhotoImage(
# file=hide_options_picture_file
#)
#self.show_options_button = None
self.status_label = None
#self.name_label = None
self.name_text = None
self.estimated_cost_frame = None
self.bytes_downloaded_label = None
self.button_frame = None
self.download_buttons = []
self.option_frames = []
self.name_font = None
self.description_text = None
#self.description_label = None
self.file_name_frame = None
self.cost_frame = None
self.cost_description = None
self.remaining_cost_description = None
self.cost_label = None
self.remaining_cost_label = None
self.progress_frame = None
def cancel(self):
if self.cancel_func is not None:
self.cancel_func() # pylint: disable=not-callable
self.stream_frame.destroy()
self.app.stream_removed()
def _resize_text(self, text_widget):
actual_height = text_widget.tk.call(text_widget._w, "count", "-displaylines", "0.0", "end")
text_widget.config(height=int(actual_height))
def show_name(self, name):
self.name_font = tkFont.Font(size=16)
#self.name_label = ttk.Label(
# self.name_frame, text=name, font=self.name_font
#)
#self.name_label.grid(row=0, column=0, sticky=tk.W)
self.name_text = tk.Text(
self.name_frame, font=self.name_font, wrap=tk.WORD, relief=tk.FLAT, borderwidth=0,
highlightthickness=0, width=1, height=1
)
self.name_text.insert(tk.INSERT, name)
self.name_text.config(state=tk.DISABLED)
self.name_text.grid(row=0, column=0, sticky=tk.W+tk.E+tk.N+tk.S)
self.name_text.update()
self._resize_text(self.name_text)
def show_description(self, description):
#if os.name == "nt":
# wraplength = 580
#else:
# wraplength = 600
#self.description_label = ttk.Label(
# self.name_frame, text=description, wraplength=wraplength
#)
#self.description_label.grid(row=1, column=0, sticky=tk.W)
self.description_text = tk.Text(
self.name_frame, wrap=tk.WORD, relief=tk.FLAT, borderwidth=0,
highlightthickness=0, width=1, height=1
)
self.description_text.insert(tk.INSERT, description)
self.description_text.config(state=tk.DISABLED)
self.description_text.grid(row=1, column=0, sticky=tk.W+tk.E+tk.N+tk.S)
self.description_text.update()
self._resize_text(self.description_text)
def show_thumbnail(self, url=None):
thumbnail = None
if url is not None:
import urllib2
import base64
response = urllib2.urlopen(url)
thumbnail_data = base64.b64encode(response.read())
thumbnail = tk.PhotoImage(data=thumbnail_data)
current_width = thumbnail.width()
current_height = thumbnail.height()
max_width = 130
max_height = 90
scale_ratio = max(1.0 * current_width / max_width, 1.0 * current_height / max_height)
if scale_ratio < 1:
scale_ratio = 1
else:
scale_ratio = int(scale_ratio + 1)
thumbnail = thumbnail.subsample(scale_ratio)
if thumbnail is not None:
label = ttk.Label(self.name_frame, image=thumbnail)
label.safekeeping = thumbnail
label.grid(row=0, column=1, rowspan=2, sticky=tk.E+tk.N+tk.W+tk.S)
label.update()
self.description_text.update()
self.name_text.update()
self._resize_text(self.description_text)
self._resize_text(self.name_text)
def show_metadata_status(self, value):
if self.status_label is None:
self.status_label = ttk.Label(
self.metadata_frame, text=value
)
self.status_label.grid()
self.metadata_frame.grid_columnconfigure(0, weight=1)
else:
self.status_label.config(text=value)
@staticmethod
def get_formatted_stream_size(stream_size):
if isinstance(stream_size, (int, long)):
if stream_size >= 2**40:
units = "TB"
factor = 2**40
elif stream_size >= 2**30:
units = "GB"
factor = 2**30
elif stream_size >= 2**20:
units = "MB"
factor = 2**20
elif stream_size >= 2**10:
units = "KB"
factor = 2**10
else:
return str(stream_size) + " B"
return "%.1f %s" % (round((stream_size * 1.0 / factor), 1), units)
return stream_size
def show_stream_metadata(self, stream_name, stream_size, stream_cost):
if self.status_label is not None:
self.status_label.destroy()
self.file_name_frame = ttk.Frame(self.metadata_frame, style="F.TFrame")
self.file_name_frame.grid(row=0, column=0, sticky=tk.W)
self.metadata_frame.grid_columnconfigure(0, weight=1, uniform="metadata")
file_size_label = ttk.Label(
self.file_name_frame,
text=self.get_formatted_stream_size(stream_size)
)
file_size_label.grid(row=0, column=2)
file_name_label = ttk.Label(
self.file_name_frame,
text=" - " + stream_name,
)
file_name_label.grid(row=0, column=3)
self.estimated_cost_frame = ttk.Frame(self.metadata_frame, style="F.TFrame")
self.estimated_cost_frame.grid(row=1, column=0, sticky=tk.W)
estimated_cost_label = ttk.Label(
self.estimated_cost_frame,
text=locale.format_string("%.2f LBC",
(round(stream_cost, 2)), grouping=True),
foreground="red"
)
estimated_cost_label.grid(row=1, column=2)
self.button_frame = ttk.Frame(self.outer_button_frame, style="E.TFrame")
self.button_frame.grid(row=0, column=1)
self.outer_button_frame.grid_columnconfigure(0, weight=1, uniform="buttons")
self.outer_button_frame.grid_columnconfigure(1, weight=2, uniform="buttons1")
self.outer_button_frame.grid_columnconfigure(2, weight=1, uniform="buttons")
def add_download_factory(self, factory, download_func):
download_button = ttk.Button(
self.button_frame, text=factory.get_description(), command=download_func,
style='LBRY.TButton', cursor=self.button_cursor
)
self.download_buttons.append(download_button)
download_button.grid(row=0, column=len(self.download_buttons) - 1, padx=5, pady=(1, 2))
def disable_download_buttons(self):
for download_button in self.download_buttons:
download_button.config(state=tk.DISABLED)
def remove_download_buttons(self):
for download_button in self.download_buttons:
download_button.destroy()
self.download_buttons = []
def get_option_widget(self, option_type, option_frame):
if option_type.value == float:
entry_frame = ttk.Frame(
option_frame,
style="H.TFrame"
)
entry_frame.grid()
col = 0
if option_type.short_description is not None:
entry_label = ttk.Label(
entry_frame,
#text=option_type.short_description
text=""
)
entry_label.grid(row=0, column=0, sticky=tk.W)
col = 1
entry = ttk.Entry(
entry_frame,
width=10,
style="Float.TEntry"
)
entry_frame.entry = entry
entry.grid(row=0, column=col, sticky=tk.W)
return entry_frame
if option_type.value == bool:
bool_frame = ttk.Frame(
option_frame,
style="H.TFrame"
)
bool_frame.chosen_value = tk.BooleanVar()
true_text = "True"
false_text = "False"
if option_type.bool_options_description is not None:
true_text, false_text = option_type.bool_options_description
true_radio_button = ttk.Radiobutton(
bool_frame, text=true_text, variable=bool_frame.chosen_value, value=True
)
true_radio_button.grid(row=0, sticky=tk.W)
false_radio_button = ttk.Radiobutton(
bool_frame, text=false_text, variable=bool_frame.chosen_value, value=False
)
false_radio_button.grid(row=1, sticky=tk.W)
return bool_frame
label = ttk.Label(
option_frame,
text=""
)
return label
def show_download_options(self, options):
left_padding = 20
for option in options:
f = ttk.Frame(
self.options_frame,
style="E.TFrame"
)
f.grid(sticky=tk.W + tk.E, padx=left_padding)
self.option_frames.append((option, f))
description_label = ttk.Label(
f,
text=option.long_description
)
description_label.grid(row=0, sticky=tk.W)
if len(option.option_types) > 1:
f.chosen_type = tk.IntVar()
choices_frame = ttk.Frame(
f,
style="F.TFrame"
)
f.choices_frame = choices_frame
choices_frame.grid(row=1, sticky=tk.W, padx=left_padding)
choices_frame.choices = []
for i, option_type in enumerate(option.option_types):
choice_frame = ttk.Frame(
choices_frame,
style="G.TFrame"
)
choice_frame.grid(sticky=tk.W)
option_text = ""
if option_type.short_description is not None:
option_text = option_type.short_description
option_radio_button = ttk.Radiobutton(
choice_frame, text=option_text, variable=f.chosen_type, value=i
)
option_radio_button.grid(row=0, column=0, sticky=tk.W)
option_widget = self.get_option_widget(option_type, choice_frame)
option_widget.grid(row=0, column=1, sticky=tk.W)
choices_frame.choices.append(option_widget)
if i == 0:
option_radio_button.invoke()
else:
choice_frame = ttk.Frame(
f,
style="F.TFrame"
)
choice_frame.grid(sticky=tk.W, padx=left_padding)
option_widget = self.get_option_widget(option.option_types[0], choice_frame)
option_widget.grid(row=0, column=0, sticky=tk.W)
f.option_widget = option_widget
#self.show_options_button = ttk.Button(
# self.stream_frame_body, command=self._toggle_show_options, style="Stop.TButton",
# cursor=self.button_cursor
#)
#self.show_options_button.config(image=self.show_options_picture)
#self.show_options_button.grid(sticky=tk.W, row=2, column=0)
def _get_chosen_option(self, option_type, option_widget):
if option_type.value == float:
return float(option_widget.entry.get())
if option_type.value == bool:
return option_widget.chosen_value.get()
return option_type.value
def get_chosen_options(self):
chosen_options = []
for o, f in self.option_frames:
if len(o.option_types) > 1:
chosen_index = f.chosen_type.get()
option_type = o.option_types[chosen_index]
option_widget = f.choices_frame.choices[chosen_index]
chosen_options.append(self._get_chosen_option(option_type, option_widget))
else:
option_type = o.option_types[0]
option_widget = f.option_widget
chosen_options.append(self._get_chosen_option(option_type, option_widget))
return chosen_options
#def _toggle_show_options(self):
# if self.options_frame.winfo_ismapped():
# self.show_options_button.config(image=self.show_options_picture)
# self.options_frame.grid_forget()
# else:
# self.show_options_button.config(image=self.hide_options_picture)
# self.options_frame.grid(sticky=tk.W + tk.E, row=3)
def show_progress(self, total_bytes, bytes_left_to_download, points_paid,
points_remaining):
if self.bytes_downloaded_label is None:
self.remove_download_buttons()
self.button_frame.destroy()
self.estimated_cost_frame.destroy()
for option, frame in self.option_frames:
frame.destroy()
self.options_frame.destroy()
#self.show_options_button.destroy()
self.progress_frame = ttk.Frame(self.outer_button_frame, style="F.TFrame")
self.progress_frame.grid(row=0, column=0, sticky=tk.W, pady=(0, 8))
self.bytes_downloaded_label = ttk.Label(
self.progress_frame,
text=""
)
self.bytes_downloaded_label.grid(row=0, column=0)
self.cost_frame = ttk.Frame(self.outer_button_frame, style="F.TFrame")
self.cost_frame.grid(row=1, column=0, sticky=tk.W, pady=(0, 4))
self.cost_label = ttk.Label(
self.cost_frame,
text="",
foreground="red"
)
self.cost_label.grid(row=0, column=1, padx=(1, 0))
self.outer_button_frame.grid_columnconfigure(2, weight=0, uniform="")
if self.bytes_downloaded_label.winfo_exists():
percent_done = 0
if total_bytes > 0:
percent_done = 100.0 * (total_bytes - bytes_left_to_download) / total_bytes
percent_done_string = locale.format_string(" (%.2f%%)", percent_done)
self.bytes_downloaded_label.config(
text=self.get_formatted_stream_size(total_bytes - bytes_left_to_download) + percent_done_string
)
if self.cost_label.winfo_exists():
total_points = points_remaining + points_paid
self.cost_label.config(text=locale.format_string("%.2f/%.2f LBC",
(round(points_paid, 2), round(total_points, 2)),
grouping=True))
def show_download_done(self, total_points_paid):
if self.bytes_downloaded_label is not None and self.bytes_downloaded_label.winfo_exists():
self.bytes_downloaded_label.destroy()
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))
-1
View File
@@ -1 +0,0 @@
"""A gui application for downloading LBRY files from LBRYnet"""
Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 B

-33
View File
@@ -1,33 +0,0 @@
import logging
import sys
from lbrynet.lbrynet_gui.GuiApp import DownloaderApp
from twisted.internet import reactor, task
import locale
def start_gui():
log_format = "(%(asctime)s)[%(filename)s:%(lineno)s] %(funcName)s(): %(message)s"
formatter = logging.Formatter(log_format)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
file_handler = logging.FileHandler("gui.log")
file_handler.setFormatter(formatter)
file_handler.addFilter(logging.Filter("lbrynet"))
logger.addHandler(file_handler)
sys.stdout = open("gui.out.log", 'w')
sys.stderr = open("gui.err.log", 'w')
locale.setlocale(locale.LC_ALL, '')
app = DownloaderApp()
d = task.deferLater(reactor, 0, app.start)
reactor.run()
if __name__ == "__main__":
start_gui()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 KiB

-14
View File
@@ -1,14 +0,0 @@
#define lbry_dark_icon2_width 32
#define lbry_dark_icon2_height 32
static unsigned char lbry_dark_icon2_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
0x00, 0xc0, 0x07, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x1c, 0xf0, 0x00,
0x00, 0x0e, 0xc0, 0x03, 0x80, 0x03, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x3c,
0x70, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x38,
0x03, 0x00, 0x00, 0x0e, 0x13, 0x00, 0x00, 0x07, 0x71, 0x00, 0xc0, 0xf1,
0xe3, 0x01, 0x60, 0x70, 0x03, 0x07, 0x38, 0x7c, 0x07, 0x1e, 0x0e, 0x0e,
0x3c, 0x70, 0x87, 0x03, 0xf0, 0xe0, 0xc1, 0x00, 0xc0, 0x03, 0x70, 0x00,
0x00, 0x0f, 0x1c, 0x00, 0x00, 0x38, 0x0e, 0x00, 0x00, 0xf0, 0x03, 0x00,
0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-108
View File
@@ -1,108 +0,0 @@
# ===== known_dht_nodes =====
# A comma-separated list of dht nodes to use to bootstrap into the
# DHT network. The nodes must be specified in dotted quad format
# followed by a colon and the port number. For example:
# 192.168.1.1:4000,10.0.0.1:4000,172.16.1.1:5000
#
# known_dht_nodes = 104.236.42.182:4000
# ===== download_directory =====
# On Windows, the default location for "download_directory" is the
# directory the user has registered with the OS as the default
# download directory, usually the 'Downloads' folder in the user's
# home directory. On Linux, it is the current directory.
#
# download_directory = /path/to/example_directory
# ===== data_dir =====
# The data directory is the directory in which the application
# stores information about the encrypted chunks stored on disk
# and the streams they belong to, the encrypted chunks themselves,
# and any other metadata. By default, set to '.lbrydownloader'
# in the user's home directory.
#
# data_dir = /path/to/home/.lbrydownloader
# ===== run_server =====
# Turn on or off the server, which uploads encrypted chunks of data
# to other clients on the network.
#
# run_server = True
# ===== start_lbrycrdd =====
# Whether to launch an lbyrcrdd server to use to send and receive
# LBC and to look up names regisered on the LBRYcrd network.
# Defaults to True on Windows and False on Linux.
#
# start_lbrycrdd = True/False
# ===== lbrycrdd_path =====
# If start_lbrycrdd is set to True, the path the application will
# use to try to run lbrycrdd. On Windows, the default path will
# be "lbrycrdd.exe". On Linux, the default path will be "./lbrycrdd".
#
# lbrycrdd_path = /path/to/lbrycrdd
# ===== wallet_dir =====
# The directory which the lbrycrdd instance will be given as the
# base directory for the instance of lbrycrdd, if it is launched
# by the application. By default, it is set to the .lbrycrd
# directory in the user's home directory.
#
# wallet_dir = /path/to/home/.lbrycrd
# ===== wallet_conf =====
# The configuration file used by the lbrycrd server which will be
# used by the application to send and receive LBC and to look up
# registered names on the LBRYcrd network. By default, this is
# set to the file lbrycrd.conf in the wallet_dir directory.
#
# wallet_conf = /path/to/home/.lbrycrd/lbrycrd.conf
# ===== use_upnp =====
# Whether to try to use UPnP to open ports in a firewall so that
# other applications on the network can connect to the application
#
# use_upnp = True
# ===== default_blob_data_payment_rate =====
# The amount of LBC per megabyte to send to uploaders of data, by
# default. Must be a positive floating point number.
#
# default_blob_data_payment_rate = 0.5
# ===== dht_port =====
# The UPD port which other applications will connect to in order
# to announce their association with sha384 hashsums and to
# find other applications which are associated with sha384
# hashsums.
#
# dht_port = 4444
# ===== peer_port =====
# The TCP port which other applications will connect to in order
# to download encrypted chunks of data from this application,
# if this application is acting as a server.
#
# peer_port = 3333
# ===== delete_blobs_on_stream_remove =====
# If this is set to True, all blobs associated with the stream
# will be deleted when the stream is removed from the GUI,
# whether by clicking the 'x' or by closing the application.
# If this is set to False, they will not be deleted then.
# However, they may be deleted otherwise. For example if the
# option to allow reuploading is set to False, they will be
# deleted as soon as they're outputted by the application.
#
# delete_blobs_on_stream_remove = True
Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

+116
View File
@@ -0,0 +1,116 @@
import logging
from lbrynet.metadata.Validator import Validator, skip_validate
from lbrynet.conf import CURRENCIES
log = logging.getLogger(__name__)
def verify_supported_currency(fee):
assert len(fee) == 1
for c in fee:
assert c in CURRENCIES
return True
def verify_amount(x):
return isinstance(x, float) or isinstance(x, int) and x > 0
class LBCFeeValidator(Validator):
FV001 = "0.0.1"
CURRENT_FEE_VERSION = FV001
FEE_REVISIONS = {}
FEE_REVISIONS[FV001] = [
(Validator.REQUIRE, 'amount', verify_amount),
(Validator.REQUIRE, 'address', skip_validate),
]
FEE_MIGRATIONS = []
current_version = CURRENT_FEE_VERSION
versions = FEE_REVISIONS
migrations = FEE_MIGRATIONS
def __init__(self, fee):
Validator.__init__(self, fee)
class BTCFeeValidator(Validator):
FV001 = "0.0.1"
CURRENT_FEE_VERSION = FV001
FEE_REVISIONS = {}
FEE_REVISIONS[FV001] = [
(Validator.REQUIRE, 'amount',verify_amount),
(Validator.REQUIRE, 'address', skip_validate),
]
FEE_MIGRATIONS = []
current_version = CURRENT_FEE_VERSION
versions = FEE_REVISIONS
migrations = FEE_MIGRATIONS
def __init__(self, fee):
Validator.__init__(self, fee)
class USDFeeValidator(Validator):
FV001 = "0.0.1"
CURRENT_FEE_VERSION = FV001
FEE_REVISIONS = {}
FEE_REVISIONS[FV001] = [
(Validator.REQUIRE, 'amount',verify_amount),
(Validator.REQUIRE, 'address', skip_validate),
]
FEE_MIGRATIONS = []
current_version = CURRENT_FEE_VERSION
versions = FEE_REVISIONS
migrations = FEE_MIGRATIONS
def __init__(self, fee):
Validator.__init__(self, fee)
class LBRYFeeValidator(Validator):
CV001 = "0.0.1"
CURRENT_CURRENCY_VERSION = CV001
CURRENCY_REVISIONS = {}
CURRENCY_REVISIONS[CV001] = [
(Validator.OPTIONAL, 'BTC', BTCFeeValidator.validate),
(Validator.OPTIONAL, 'USD', USDFeeValidator.validate),
(Validator.OPTIONAL, 'LBC', LBCFeeValidator.validate),
]
CURRENCY_MIGRATIONS = []
current_version = CURRENT_CURRENCY_VERSION
versions = CURRENCY_REVISIONS
migrations = CURRENCY_MIGRATIONS
def __init__(self, fee_dict):
Validator.__init__(self, fee_dict)
self.currency_symbol = self.keys()[0]
self.amount = self._get_amount()
self.address = self[self.currency_symbol]['address']
def _get_amount(self):
amt = self[self.currency_symbol]['amount']
if isinstance(amt, float):
return amt
else:
try:
return float(amt)
except TypeError:
log.error('Failed to convert %s to float', amt)
raise
+86
View File
@@ -0,0 +1,86 @@
import logging
from lbrynet.metadata.Validator import Validator, skip_validate
from lbrynet.metadata.LBRYFee import LBRYFeeValidator, verify_supported_currency
from lbrynet.conf import SOURCE_TYPES
log = logging.getLogger(__name__)
NAME_ALLOWED_CHARSET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0987654321-'
def verify_name_characters(name):
for c in name:
assert c in NAME_ALLOWED_CHARSET, "Invalid character"
return True
def validate_sources(sources):
for source in sources:
assert source in SOURCE_TYPES, "Unknown source type: %s" % str(source)
return True
class Metadata(Validator):
MV001 = "0.0.1"
MV002 = "0.0.2"
MV003 = "0.0.3"
CURRENT_METADATA_VERSION = MV003
METADATA_REVISIONS = {}
METADATA_REVISIONS[MV001] = [
(Validator.REQUIRE, 'title', skip_validate),
(Validator.REQUIRE, 'description', skip_validate),
(Validator.REQUIRE, 'author', skip_validate),
(Validator.REQUIRE, 'language', skip_validate),
(Validator.REQUIRE, 'license', skip_validate),
(Validator.REQUIRE, 'content-type', skip_validate),
(Validator.REQUIRE, 'sources', validate_sources),
(Validator.OPTIONAL, 'thumbnail', skip_validate),
(Validator.OPTIONAL, 'preview', skip_validate),
(Validator.OPTIONAL, 'fee', verify_supported_currency),
(Validator.OPTIONAL, 'contact', skip_validate),
(Validator.OPTIONAL, 'pubkey', skip_validate),
]
METADATA_REVISIONS[MV002] = [
(Validator.REQUIRE, 'nsfw', skip_validate),
(Validator.REQUIRE, 'ver', skip_validate),
(Validator.OPTIONAL, 'license_url', skip_validate),
]
METADATA_REVISIONS[MV003] = [
(Validator.REQUIRE, 'content_type', skip_validate),
(Validator.SKIP, 'content-type'),
(Validator.OPTIONAL, 'sig', skip_validate),
(Validator.IF_KEY, 'sig', (Validator.REQUIRE, 'pubkey', skip_validate), Validator.DO_NOTHING),
(Validator.IF_KEY, 'pubkey', (Validator.REQUIRE, 'sig', skip_validate), Validator.DO_NOTHING),
]
MIGRATE_MV001_TO_MV002 = [
(Validator.IF_KEY, 'nsfw', Validator.DO_NOTHING, (Validator.LOAD, 'nsfw', False)),
(Validator.IF_KEY, 'ver', Validator.DO_NOTHING, (Validator.LOAD, 'ver', MV002)),
]
MIGRATE_MV002_TO_MV003 = [
(Validator.IF_KEY, 'content-type', (Validator.UPDATE, 'content-type', 'content_type'), Validator.DO_NOTHING),
(Validator.IF_VAL, 'ver', MV002, (Validator.LOAD, 'ver', MV003), Validator.DO_NOTHING),
]
METADATA_MIGRATIONS = [
MIGRATE_MV001_TO_MV002,
MIGRATE_MV002_TO_MV003,
]
current_version = CURRENT_METADATA_VERSION
versions = METADATA_REVISIONS
migrations = METADATA_MIGRATIONS
def __init__(self, metadata, process_now=True):
Validator.__init__(self, metadata, process_now)
self.meta_version = self.get('ver', Metadata.MV001)
self._load_fee()
def _load_fee(self):
if 'fee' in self:
self.update({'fee': LBRYFeeValidator(self['fee'])})
+155
View File
@@ -0,0 +1,155 @@
import json
import logging
from copy import deepcopy
from distutils.version import StrictVersion
from lbrynet.core.utils import version_is_greater_than
log = logging.getLogger(__name__)
def skip_validate(value):
return True
def processor(cls):
for methodname in dir(cls):
method = getattr(cls, methodname)
if hasattr(method, 'cmd_name'):
cls.commands.update({method.cmd_name: methodname})
return cls
def cmd(cmd_name):
def wrapper(func):
func.cmd_name = cmd_name
return func
return wrapper
@processor
class Validator(dict):
"""
Base class for validated dictionaries
"""
# override these
current_version = None
versions = {}
migrations = []
# built in commands
DO_NOTHING = "do_nothing"
UPDATE = "update_key"
IF_KEY = "if_key"
REQUIRE = "require"
SKIP = "skip"
OPTIONAL = "optional"
LOAD = "load"
IF_VAL = "if_val"
commands = {}
@classmethod
def load_from_hex(cls, hex_val):
return cls(json.loads(hex_val.decode('hex')))
@classmethod
def validate(cls, value):
if cls(value):
return True
else:
return False
def __init__(self, value, process_now=False):
dict.__init__(self)
self._skip = []
value_to_load = deepcopy(value)
if process_now:
self.process(value_to_load)
self._verify_value(value_to_load)
self.version = self.get('ver', "0.0.1")
def process(self, value):
if self.migrations is not None:
self._migrate_value(value)
@cmd(DO_NOTHING)
def _do_nothing(self):
pass
@cmd(SKIP)
def _add_to_skipped(self, rx_value, key):
if key not in self._skip:
self._skip.append(key)
@cmd(UPDATE)
def _update(self, rx_value, old_key, new_key):
rx_value.update({new_key: rx_value.pop(old_key)})
@cmd(IF_KEY)
def _if_key(self, rx_value, key, if_true, if_else):
if key in rx_value:
return self._handle(if_true, rx_value)
return self._handle(if_else, rx_value)
@cmd(IF_VAL)
def _if_val(self, rx_value, key, val, if_true, if_else):
if key in rx_value:
if rx_value[key] == val:
return self._handle(if_true, rx_value)
return self._handle(if_else, rx_value)
@cmd(LOAD)
def _load(self, rx_value, key, value):
rx_value.update({key: value})
@cmd(REQUIRE)
def _require(self, rx_value, key, validator=None):
if key not in self._skip:
assert key in rx_value, "Key is missing: %s" % key
if isinstance(validator, type):
assert isinstance(rx_value[key], validator), "%s: %s isn't required %s" % (key, type(rx_value[key]), validator)
elif callable(validator):
assert validator(rx_value[key]), "Failed to validate %s" % key
self.update({key: rx_value.pop(key)})
@cmd(OPTIONAL)
def _optional(self, rx_value, key, validator=None):
if key in rx_value and key not in self._skip:
if isinstance(validator, type):
assert isinstance(rx_value[key], validator), "%s type %s isn't required %s" % (key, type(rx_value[key]), validator)
elif callable(validator):
assert validator(rx_value[key]), "Failed to validate %s" % key
self.update({key: rx_value.pop(key)})
def _handle(self, cmd_tpl, value):
if cmd_tpl == Validator.DO_NOTHING:
return
command = cmd_tpl[0]
f = getattr(self, self.commands[command])
if len(cmd_tpl) > 1:
args = (value,) + cmd_tpl[1:]
f(*args)
else:
f()
def _load_revision(self, version, value):
for k in self.versions[version]:
self._handle(k, value)
def _verify_value(self, value):
val_ver = value.get('ver', "0.0.1")
# verify version requirements in reverse order starting from the version asserted in the value
versions = sorted([v for v in self.versions if not version_is_greater_than(v, val_ver)], key=StrictVersion, reverse=True)
for version in versions:
self._load_revision(version, value)
assert value == {} or value.keys() == self._skip, "Unknown keys: %s" % json.dumps(value)
def _migrate_value(self, value):
for migration in self.migrations:
self._run_migration(migration, value)
def _run_migration(self, commands, value):
for cmd in commands:
self._handle(cmd, value)
View File
Whitespace-only changes.
+1 -2
View File
@@ -6,7 +6,6 @@ CLI for sending rpc commands to a DHT node
from twisted.internet import reactor
from txjsonrpc.web.jsonrpc import Proxy
import argparse
import sys
def print_value(value):
@@ -39,4 +38,4 @@ def main():
d = proxy.callRemote(args.rpc_command)
d.addCallbacks(print_value, print_error)
d.addBoth(lambda _: shut_down())
reactor.run()
reactor.run()
+3
View File
@@ -0,0 +1,3 @@
from lbrynet.reflector.server.server import ReflectorServerFactory as ServerFactory
from lbrynet.reflector.client.client import LBRYFileReflectorClientFactory as ClientFactory
from lbrynet.reflector.client.client import LBRYBlobReflectorClientFactory as BlobClientFactory
Whitespace-only changes.
+454
View File
@@ -0,0 +1,454 @@
"""
The reflector protocol (all dicts encoded in json):
Client Handshake (sent once per connection, at the start of the connection):
{
'version': 0,
}
Server Handshake (sent once per connection, after receiving the client handshake):
{
'version': 0,
}
Client Info Request:
{
'blob_hash': "<blob_hash>",
'blob_size': <blob_size>
}
Server Info Response (sent in response to Client Info Request):
{
'send_blob': True|False
}
If response is 'YES', client may send a Client Blob Request or a Client Info Request.
If response is 'NO', client may only send a Client Info Request
Client Blob Request:
{} # Yes, this is an empty dictionary, in case something needs to go here in the future
<raw blob_data> # this blob data must match the info sent in the most recent Client Info Request
Server Blob Response (sent in response to Client Blob Request):
{
'received_blob': True
}
Client may now send another Client Info Request
"""
import json
import logging
from twisted.protocols.basic import FileSender
from twisted.internet.protocol import Protocol, ClientFactory
from twisted.internet import defer, error
log = logging.getLogger(__name__)
class IncompleteResponseError(Exception):
pass
class LBRYFileReflectorClient(Protocol):
# Protocol stuff
def connectionMade(self):
self.blob_manager = self.factory.blob_manager
self.response_buff = ''
self.outgoing_buff = ''
self.blob_hashes_to_send = []
self.next_blob_to_send = None
self.blob_read_handle = None
self.received_handshake_response = False
self.protocol_version = None
self.file_sender = None
self.producer = None
self.streaming = False
d = self.get_blobs_to_send(self.factory.stream_info_manager, self.factory.stream_hash)
d.addCallback(lambda _: self.send_handshake())
d.addErrback(lambda err: log.warning("An error occurred immediately: %s", err.getTraceback()))
def dataReceived(self, data):
log.debug('Recieved %s', data)
self.response_buff += data
try:
msg = self.parse_response(self.response_buff)
except IncompleteResponseError:
pass
else:
self.response_buff = ''
d = self.handle_response(msg)
d.addCallback(lambda _: self.send_next_request())
d.addErrback(self.response_failure_handler)
def connectionLost(self, reason):
if reason.check(error.ConnectionDone):
log.debug('Finished sending data via reflector')
self.factory.finished_deferred.callback(True)
else:
log.debug('reflector finished: %s', reason)
self.factory.finished_deferred.callback(reason)
# IConsumer stuff
def registerProducer(self, producer, streaming):
self.producer = producer
self.streaming = streaming
if self.streaming is False:
from twisted.internet import reactor
reactor.callLater(0, self.producer.resumeProducing)
def unregisterProducer(self):
self.producer = None
def write(self, data):
self.transport.write(data)
if self.producer is not None and self.streaming is False:
from twisted.internet import reactor
reactor.callLater(0, self.producer.resumeProducing)
def get_blobs_to_send(self, stream_info_manager, stream_hash):
log.debug('Getting blobs from stream hash: %s', stream_hash)
d = stream_info_manager.get_blobs_for_stream(stream_hash)
def set_blobs(blob_hashes):
for blob_hash, position, iv, length in blob_hashes:
log.info("Preparing to send %s", blob_hash)
if blob_hash is not None:
self.blob_hashes_to_send.append(blob_hash)
d.addCallback(set_blobs)
d.addCallback(lambda _: stream_info_manager.get_sd_blob_hashes_for_stream(stream_hash))
def set_sd_blobs(sd_blob_hashes):
for sd_blob_hash in sd_blob_hashes:
self.blob_hashes_to_send.append(sd_blob_hash)
d.addCallback(set_sd_blobs)
return d
def send_handshake(self):
log.debug('Sending handshake')
self.write(json.dumps({'version': 0}))
def parse_response(self, buff):
try:
return json.loads(buff)
except ValueError:
raise IncompleteResponseError()
def response_failure_handler(self, err):
log.warning("An error occurred handling the response: %s", err.getTraceback())
def handle_response(self, response_dict):
if self.received_handshake_response is False:
return self.handle_handshake_response(response_dict)
else:
return self.handle_normal_response(response_dict)
def set_not_uploading(self):
if self.next_blob_to_send is not None:
self.next_blob_to_send.close_read_handle(self.read_handle)
self.read_handle = None
self.next_blob_to_send = None
self.file_sender = None
return defer.succeed(None)
def start_transfer(self):
self.write(json.dumps({}))
assert self.read_handle is not None, "self.read_handle was None when trying to start the transfer"
d = self.file_sender.beginFileTransfer(self.read_handle, self)
return d
def handle_handshake_response(self, response_dict):
if 'version' not in response_dict:
raise ValueError("Need protocol version number!")
self.protocol_version = int(response_dict['version'])
if self.protocol_version != 0:
raise ValueError("I can't handle protocol version {}!".format(self.protocol_version))
self.received_handshake_response = True
return defer.succeed(True)
def handle_normal_response(self, response_dict):
if self.file_sender is None: # Expecting Server Info Response
if 'send_blob' not in response_dict:
raise ValueError("I don't know whether to send the blob or not!")
if response_dict['send_blob'] is True:
self.file_sender = FileSender()
return defer.succeed(True)
else:
return self.set_not_uploading()
else: # Expecting Server Blob Response
if 'received_blob' not in response_dict:
raise ValueError("I don't know if the blob made it to the intended destination!")
else:
return self.set_not_uploading()
def open_blob_for_reading(self, blob):
if blob.is_validated():
read_handle = blob.open_for_reading()
if read_handle is not None:
log.debug('Getting ready to send %s', blob.blob_hash)
self.next_blob_to_send = blob
self.read_handle = read_handle
return None
raise ValueError("Couldn't open that blob for some reason. blob_hash: {}".format(blob.blob_hash))
def send_blob_info(self):
log.info("Send blob info for %s", self.next_blob_to_send.blob_hash)
assert self.next_blob_to_send is not None, "need to have a next blob to send at this point"
log.debug('sending blob info')
self.write(json.dumps({
'blob_hash': self.next_blob_to_send.blob_hash,
'blob_size': self.next_blob_to_send.length
}))
def send_next_request(self):
if self.file_sender is not None:
# send the blob
log.debug('Sending the blob')
return self.start_transfer()
elif self.blob_hashes_to_send:
# open the next blob to send
blob_hash = self.blob_hashes_to_send[0]
log.debug('No current blob, sending the next one: %s', blob_hash)
self.blob_hashes_to_send = self.blob_hashes_to_send[1:]
d = self.blob_manager.get_blob(blob_hash, True)
d.addCallback(self.open_blob_for_reading)
# send the server the next blob hash + length
d.addCallback(lambda _: self.send_blob_info())
return d
else:
# close connection
log.debug('No more blob hashes, closing connection')
self.transport.loseConnection()
class LBRYFileReflectorClientFactory(ClientFactory):
protocol = LBRYFileReflectorClient
def __init__(self, blob_manager, stream_info_manager, stream_hash):
self.blob_manager = blob_manager
self.stream_info_manager = stream_info_manager
self.stream_hash = stream_hash
self.p = None
self.finished_deferred = defer.Deferred()
def buildProtocol(self, addr):
p = self.protocol()
p.factory = self
self.p = p
return p
def startFactory(self):
log.debug('Starting reflector factory')
ClientFactory.startFactory(self)
def startedConnecting(self, connector):
log.debug('Started connecting')
def clientConnectionLost(self, connector, reason):
"""If we get disconnected, reconnect to server."""
log.debug("connection lost: %s", reason)
def clientConnectionFailed(self, connector, reason):
log.debug("connection failed: %s", reason)
class LBRYBlobReflectorClient(Protocol):
# Protocol stuff
def connectionMade(self):
self.blob_manager = self.factory.blob_manager
self.response_buff = ''
self.outgoing_buff = ''
self.blob_hashes_to_send = self.factory.blobs
self.next_blob_to_send = None
self.blob_read_handle = None
self.received_handshake_response = False
self.protocol_version = None
self.file_sender = None
self.producer = None
self.streaming = False
d = self.send_handshake()
d.addErrback(lambda err: log.warning("An error occurred immediately: %s", err.getTraceback()))
def dataReceived(self, data):
log.debug('Recieved %s', data)
self.response_buff += data
try:
msg = self.parse_response(self.response_buff)
except IncompleteResponseError:
pass
else:
self.response_buff = ''
d = self.handle_response(msg)
d.addCallback(lambda _: self.send_next_request())
d.addErrback(self.response_failure_handler)
def connectionLost(self, reason):
if reason.check(error.ConnectionDone):
log.debug('Finished sending data via reflector')
self.factory.finished_deferred.callback(True)
else:
log.debug('reflector finished: %s', reason)
self.factory.finished_deferred.callback(reason)
# IConsumer stuff
def registerProducer(self, producer, streaming):
self.producer = producer
self.streaming = streaming
if self.streaming is False:
from twisted.internet import reactor
reactor.callLater(0, self.producer.resumeProducing)
def unregisterProducer(self):
self.producer = None
def write(self, data):
self.transport.write(data)
if self.producer is not None and self.streaming is False:
from twisted.internet import reactor
reactor.callLater(0, self.producer.resumeProducing)
def send_handshake(self):
log.debug('Sending handshake')
self.write(json.dumps({'version': 0}))
return defer.succeed(None)
def parse_response(self, buff):
try:
return json.loads(buff)
except ValueError:
raise IncompleteResponseError()
def response_failure_handler(self, err):
log.warning("An error occurred handling the response: %s", err.getTraceback())
def handle_response(self, response_dict):
if self.received_handshake_response is False:
return self.handle_handshake_response(response_dict)
else:
return self.handle_normal_response(response_dict)
def set_not_uploading(self):
if self.next_blob_to_send is not None:
self.next_blob_to_send.close_read_handle(self.read_handle)
self.read_handle = None
self.next_blob_to_send = None
self.file_sender = None
return defer.succeed(None)
def start_transfer(self):
self.write(json.dumps({}))
assert self.read_handle is not None, "self.read_handle was None when trying to start the transfer"
d = self.file_sender.beginFileTransfer(self.read_handle, self)
return d
def handle_handshake_response(self, response_dict):
if 'version' not in response_dict:
raise ValueError("Need protocol version number!")
self.protocol_version = int(response_dict['version'])
if self.protocol_version != 0:
raise ValueError("I can't handle protocol version {}!".format(self.protocol_version))
self.received_handshake_response = True
return defer.succeed(True)
def handle_normal_response(self, response_dict):
if self.file_sender is None: # Expecting Server Info Response
if 'send_blob' not in response_dict:
raise ValueError("I don't know whether to send the blob or not!")
if response_dict['send_blob'] is True:
self.file_sender = FileSender()
return defer.succeed(True)
else:
return self.set_not_uploading()
else: # Expecting Server Blob Response
if 'received_blob' not in response_dict:
raise ValueError("I don't know if the blob made it to the intended destination!")
else:
return self.set_not_uploading()
def open_blob_for_reading(self, blob):
if blob.is_validated():
read_handle = blob.open_for_reading()
if read_handle is not None:
log.debug('Getting ready to send %s', blob.blob_hash)
self.next_blob_to_send = blob
self.read_handle = read_handle
return None
raise ValueError("Couldn't open that blob for some reason. blob_hash: {}".format(blob.blob_hash))
def send_blob_info(self):
log.info("Send blob info for %s", self.next_blob_to_send.blob_hash)
assert self.next_blob_to_send is not None, "need to have a next blob to send at this point"
log.debug('sending blob info')
self.write(json.dumps({
'blob_hash': self.next_blob_to_send.blob_hash,
'blob_size': self.next_blob_to_send.length
}))
def send_next_request(self):
if self.file_sender is not None:
# send the blob
log.debug('Sending the blob')
return self.start_transfer()
elif self.blob_hashes_to_send:
# open the next blob to send
blob_hash = self.blob_hashes_to_send[0]
log.debug('No current blob, sending the next one: %s', blob_hash)
self.blob_hashes_to_send = self.blob_hashes_to_send[1:]
d = self.blob_manager.get_blob(blob_hash, True)
d.addCallback(self.open_blob_for_reading)
# send the server the next blob hash + length
d.addCallback(lambda _: self.send_blob_info())
return d
else:
# close connection
log.debug('No more blob hashes, closing connection')
self.transport.loseConnection()
class LBRYBlobReflectorClientFactory(ClientFactory):
protocol = LBRYBlobReflectorClient
def __init__(self, blob_manager, blobs):
self.blob_manager = blob_manager
self.blobs = blobs
self.p = None
self.finished_deferred = defer.Deferred()
def buildProtocol(self, addr):
p = self.protocol()
p.factory = self
self.p = p
return p
def startFactory(self):
log.debug('Starting reflector factory')
ClientFactory.startFactory(self)
def startedConnecting(self, connector):
log.debug('Started connecting')
def clientConnectionLost(self, connector, reason):
"""If we get disconnected, reconnect to server."""
log.debug("connection lost: %s", reason)
def clientConnectionFailed(self, connector, reason):
log.debug("connection failed: %s", reason)
Whitespace-only changes.
+147
View File
@@ -0,0 +1,147 @@
import logging
from twisted.python import failure
from twisted.internet import error, defer
from twisted.internet.protocol import Protocol, ServerFactory
import json
from lbrynet.core.utils import is_valid_blobhash
log = logging.getLogger(__name__)
class ReflectorServer(Protocol):
def connectionMade(self):
peer_info = self.transport.getPeer()
log.debug('Connection made to %s', peer_info)
self.peer = self.factory.peer_manager.get_peer(peer_info.host, peer_info.port)
self.blob_manager = self.factory.blob_manager
self.received_handshake = False
self.peer_version = None
self.receiving_blob = False
self.incoming_blob = None
self.blob_write = None
self.blob_finished_d = None
self.cancel_write = None
self.request_buff = ""
def connectionLost(self, reason=failure.Failure(error.ConnectionDone())):
log.info("Reflector upload from %s finished" % self.peer.host)
def dataReceived(self, data):
if self.receiving_blob:
# log.debug('Writing data to blob')
self.blob_write(data)
else:
log.debug('Not yet recieving blob, data needs further processing')
self.request_buff += data
msg, extra_data = self._get_valid_response(self.request_buff)
if msg is not None:
self.request_buff = ''
d = self.handle_request(msg)
d.addCallbacks(self.send_response, self.handle_error)
if self.receiving_blob and extra_data:
log.debug('Writing extra data to blob')
self.blob_write(extra_data)
def _get_valid_response(self, response_msg):
extra_data = None
response = None
curr_pos = 0
while True:
next_close_paren = response_msg.find('}', curr_pos)
if next_close_paren != -1:
curr_pos = next_close_paren + 1
try:
response = json.loads(response_msg[:curr_pos])
except ValueError:
if curr_pos > 100:
raise Exception("error decoding response")
else:
pass
else:
extra_data = response_msg[curr_pos:]
break
else:
break
return response, extra_data
def handle_request(self, request_dict):
if self.received_handshake is False:
return self.handle_handshake(request_dict)
else:
return self.handle_normal_request(request_dict)
def handle_handshake(self, request_dict):
log.debug('Handling handshake')
if 'version' not in request_dict:
raise ValueError("Client should send version")
self.peer_version = int(request_dict['version'])
if self.peer_version != 0:
raise ValueError("I don't know that version!")
self.received_handshake = True
return defer.succeed({'version': 0})
def determine_blob_needed(self, blob):
if blob.is_validated():
return {'send_blob': False}
else:
self.incoming_blob = blob
self.blob_finished_d, self.blob_write, self.cancel_write = blob.open_for_writing(self.peer)
self.blob_finished_d.addCallback(lambda _ :self.blob_manager.blob_completed(blob))
return {'send_blob': True}
def close_blob(self):
self.blob_finished_d = None
self.blob_write = None
self.cancel_write = None
self.incoming_blob = None
self.receiving_blob = False
def handle_normal_request(self, request_dict):
if self.blob_write is None:
# we haven't opened a blob yet, meaning we must be waiting for the
# next message containing a blob hash and a length. this message
# should be it. if it's one we want, open the blob for writing, and
# return a nice response dict (in a Deferred) saying go ahead
if not 'blob_hash' in request_dict or not 'blob_size' in request_dict:
raise ValueError("Expected a blob hash and a blob size")
if not is_valid_blobhash(request_dict['blob_hash']):
raise ValueError("Got a bad blob hash: {}".format(request_dict['blob_hash']))
log.debug('Recieved info for blob: %s', request_dict['blob_hash'])
d = self.blob_manager.get_blob(
request_dict['blob_hash'],
True,
int(request_dict['blob_size'])
)
d.addCallback(self.determine_blob_needed)
else:
# we have a blob open already, so this message should have nothing
# important in it. to the deferred that fires when the blob is done,
# add a callback which returns a nice response dict saying to keep
# sending, and then return that deferred
log.debug('blob is already open')
self.receiving_blob = True
d = self.blob_finished_d
d.addCallback(lambda _: self.close_blob())
d.addCallback(lambda _: {'received_blob': True})
return d
def send_response(self, response_dict):
self.transport.write(json.dumps(response_dict))
def handle_error(self, err):
log.error(err.getTraceback())
self.transport.loseConnection()
class ReflectorServerFactory(ServerFactory):
protocol = ReflectorServer
def __init__(self, peer_manager, blob_manager):
self.peer_manager = peer_manager
self.blob_manager = blob_manager
def buildProtocol(self, addr):
log.debug('Creating a protocol for %s', addr)
return ServerFactory.buildProtocol(self, addr)
View File
Whitespace-only changes.
+75
View File
@@ -0,0 +1,75 @@
#!/bin/sh
if [ "$EUID" -ne 0 ]
then echo "Please run as sudo"
exit
fi
echo "**********************************"
echo "Installing LBRY and dependencies"
echo "**********************************"
if ! xcode-select -p &>/dev/null; then
echo
echo "You need to install xcode command line tools to install lbry."
echo "A popup to do so should appear, once you're done the installer will resume"
echo
xcode-select --install &>/dev/null
while ! xcode-select -p &>/dev/null; do
sleep 1
done
echo "Installed xcode command line tools"
else
echo "Xcode command line tools already installed..."
fi
if ! which brew &>/dev/null; then
echo "Installing brew..."
sudo -u ${SUDO_USER} ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null &>/dev/null
else
echo "Updating brew..."
sudo -u ${SUDO_USER} brew update &>/dev/null
fi
if ! brew list mpfr &>/dev/null; then
echo "Installing mpfr..."
sudo -u ${SUDO_USER} brew install mpfr &>/dev/null
else
echo "mpfr already installed..."
fi
if ! brew list libmpc &>/dev/null; then
echo "Installing libmpc..."
sudo -u ${SUDO_USER} brew install libmpc &>/dev/null
else
echo "libmpc already installed..."
fi
if ! which pip &>/dev/null; then
echo "Installing pip..."
sudo easy_install pip &>/dev/null
else
echo "pip already installed"
fi
echo "Cloning and installing lbryum..."
git clone --depth 1 https://github.com/lbryio/lbryum.git &>/dev/null
cd lbryum
sudo python setup.py install &>/dev/null
cd ..
rm -rf lbryum &>/dev/null
echo "Cloning and installing lbry..."
git clone --depth 1 https://github.com/lbryio/lbry.git &>/dev/null
cd lbry
sudo python setup.py install &>/dev/null
cd ..
rm -rf lbry &>/dev/null
sudo chmod -R 755 /Library/Python/2.7/site-packages/
echo "**********************************"
echo "All done!"
echo "**********************************"
echo " "
echo "run 'lbrynet-daemon' to start lbry"
+8
View File
@@ -10,3 +10,11 @@
*.iml
id.conf
lbrycrd-cli
lbrycrd-osx.zip
lbrycrd-tx
lbrycrdd
lbrynet.*.dmg
LBRY.app
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

@@ -0,0 +1,11 @@
badge_icon = 'app.icns'
icon_locations = {
'LBRY.app': (115, 164),
'Applications': (387, 164)
}
background='dmg_background.png'
default_view='icon-view'
symlinks = { 'Applications': '/Applications' }
window_rect=((200, 200), (500, 320))
files = [ 'LBRY.app' ]
icon_size=128
+21 -7
View File
@@ -1,16 +1,33 @@
import AppKit
import webbrowser
import sys
import os
import logging
import socket
import platform
import shutil
from appdirs import user_data_dir
from PyObjCTools import AppHelper
from twisted.internet import reactor
from twisted.web import server
from lbrynet.lbrynet_daemon.LBRYDaemonServer import LBRYDaemonServer
import Foundation
bundle = Foundation.NSBundle.mainBundle()
lbrycrdd_path = bundle.pathForResource_ofType_('lbrycrdd', None)
lbrycrdd_path_conf = os.path.join(os.path.expanduser("~"), ".lbrycrddpath.conf")
wallet_dir = user_data_dir("lbrycrd")
if not os.path.isdir(wallet_dir):
shutil.os.mkdir(wallet_dir)
if not os.path.isfile(lbrycrdd_path_conf):
f = open(lbrycrdd_path_conf, "w")
f.write(lbrycrdd_path)
f.close()
from lbrynet.lbrynet_daemon.LBRYDaemonServer import LBRYDaemonServer, LBRYDaemonRequest
from lbrynet.conf import API_PORT, API_INTERFACE, ICON_PATH, APP_NAME
from lbrynet.conf import UI_ADDRESS
@@ -57,16 +74,13 @@ class LBRYDaemonApp(AppKit.NSApplication):
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)
lbrynet_server = server.Site(lbry.root)
lbrynet_server.requestFactory = LBRYDaemonRequest
reactor.listenTCP(API_PORT, lbrynet_server, interface=API_INTERFACE)
def openui_(self, sender):
webbrowser.open(UI_ADDRESS)
Binary file not shown.
+48 -11
View File
@@ -5,27 +5,57 @@ set -o xtrace
DEST=`pwd`
tmp="${DEST}/build"
ON_TRAVIS=false
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
mkdir -p $tmp
cd $tmp
git clone --depth 1 http://github.com/lbryio/lbry.git
cd lbry
LBRY="${tmp}/lbry"
else
# building on travis
ON_TRAVIS=true
cd ${TRAVIS_BUILD_DIR}
LBRY=${TRAVIS_BUILD_DIR}
fi
pip install wheel
MODULES="pyobjc-core pyobjc-framework-Cocoa pyobjc-framework-CFNetwork pyobjc-framework-Quartz"
if [ ${ON_TRAVIS} = true ]; then
WHEEL_DIR="${TRAVIS_BUILD_DIR}/cache/wheel"
mkdir -p "${WHEEL_DIR}"
# mapping from the package name to the
# actual built wheel file is surprisingly
# hard so instead of checking for the existance
# of each wheel, we mark with a file when they've all been
# built and skip when that file exists
for MODULE in ${MODULES}; do
if [ ! -f "${WHEEL_DIR}"/${MODULE}.finished ]; then
pip wheel -w "${WHEEL_DIR}" ${MODULE}
touch "${WHEEL_DIR}"/${MODULE}.finished
fi
done
pip install "${WHEEL_DIR}"/*.whl
else
pip install $MODULES
fi
pip install dmgbuild
pip show dmgbuild
export PATH=${PATH}:/Library/Frameworks/Python.framework/Versions/2.7/bin
dmgbuild --help
pip install jsonrpc certifi
# 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
NAME=`python setup.py --name`
VERSION=`python setup.py -V`
pip install -r requirements.txt
@@ -45,8 +75,15 @@ codesign -s "${LBRY_DEVELOPER_ID}" -f "${DEST}/dist/LBRYURIHandler.app/Contents/
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
# add lbrycrdd as a resource. Following
# http://stackoverflow.com/questions/11370012/can-executables-made-with-py2app-include-other-terminal-scripts-and-run-them
# LBRYCRDD_URL="$(curl https://api.github.com/repos/lbryio/lbrycrd/releases/latest | grep 'browser_download_url' | grep osx | cut -d'"' -f4)"
LBRYCRDD_URL="https://github.com/lbryio/lbrycrd/releases/download/v0.3.15/lbrycrd-osx.zip"
wget "${LBRYCRDD_URL}" --output-document lbrycrd-osx.zip
unzip -o lbrycrd-osx.zip
python setup_app.py py2app --resources lbrycrdd
chmod +x "${DEST}/dist/LBRY.app/Contents/Resources/lbrycrdd"
echo "Removing i386 libraries"
@@ -74,5 +111,5 @@ 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
rm -rf dist "${NAME}.${VERSION}.dmg"
dmgbuild -s dmg_settings.py "LBRY" "${NAME}.${VERSION}.dmg"
@@ -38,9 +38,11 @@ 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/
pip install mock pylint
trial tests
# TODO: submit coverage report to coveralls
# Ignoring distutils because: https://github.com/PyCQA/pylint/issues/73
# TODO: as code quality improves, make pylint be more strict
pylint -E --disable=inherit-non-class --disable=no-member lbrynet
pylint -E --disable=inherit-non-class --disable=no-member --ignored-modules=distutils \
--enable=unused-import lbrynet
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

+25 -2
View File
@@ -2,6 +2,19 @@
set -euo pipefail
LBRYCRDDPATHCONF="$HOME/.lbrycrddpath.conf"
LBRYCRDDIR="$HOME/.lbrycrd"
LBRYCRDCONF="$LBRYCRDDIR/lbrycrd.conf"
if [ ! -f "$LBRYCRDDPATHCONF" ]; then
echo "/usr/bin/lbrycrdd" > "$LBRYCRDDPATHCONF"
fi
if [ ! -f "$LBRYCRDCONF" ]; then
mkdir -p "$LBRYCRDDIR"
echo -e "rpcuser=lbryrpc\nrpcpassword=$(env LC_CTYPE=C LC_ALL=C tr -dc A-Za-z0-9 < /dev/urandom | head -c 16 | xargs)" > "$LBRYCRDCONF"
fi
WEB_UI_BRANCH='master'
urlencode() {
@@ -16,10 +29,20 @@ urlencode() {
done
}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# find true dir of executable
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ -z "$(pgrep lbrynet-daemon)" ]; then
echo "running lbrynet-daemon..."
$DIR/lbrynet-daemon --branch="$WEB_UI_BRANCH" &
$DIR/lbrynet-daemon --no-launch --branch="$WEB_UI_BRANCH" &
sleep 3 # let the daemon load before connecting
fi
+2 -2
View File
@@ -1,8 +1,8 @@
[Desktop Entry]
Version=0.2.2
Version=0.4.2
Name=LBRY
Comment=The world's first user-owned content marketplace
Icon=/usr/share/python/lbrynet/lbrynet/lbrynet_gui/lbry.png
Icon=lbry
GenericName=Content Marketplace
Categories=Network;Internet;Filesharing
Terminal=false
+8 -21
View File
@@ -1,28 +1,15 @@
(
sleep 4
if hash zenity 2>/dev/null; then
sleep 3
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"
zenity --info --icon-name="system-software-install" \
--text="\
<span size=\"xx-large\">LBRY Installed</span>\n\nLBRY has been installed.\n\n\
Please start LBRY by running <b><tt>lbry</tt></b> from the command line or selecting <b>LBRY</b> from the application menu.\n\n\
If you need help or have any questions, join us on Slack (<tt>https://slack.lbry.io</tt>) or email <tt>hello@lbry.io</tt>.\
"
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
) &
+30 -3
View File
@@ -101,7 +101,7 @@ $SUDO apt-get ${QUIET} install -y --no-install-recommends \
# need a modern version of pip (more modern than ubuntu default)
$SUDO pip install --upgrade pip
$SUDO pip install make-deb
$SUDO pip install git+https://github.com/jobevers/make-deb
# build packages
#
@@ -148,14 +148,41 @@ function addfile() {
FILE="$1"
TARGET="$2"
mkdir -p "$(dirname "data/$TARGET")"
cp "$FILE" "data/$TARGET"
cp -d "$FILE" "data/$TARGET"
echo "$(md5sum "data/$TARGET" | cut -d' ' -f1) $TARGET" >> control/md5sums
}
addfile "$PACKAGING_DIR/lbry" usr/share/python/lbrynet/bin/lbry
# add icons
addfile "$PACKAGING_DIR/icons/lbry32.png" usr/share/icons/hicolor/32x32/apps/lbry.png
addfile "$PACKAGING_DIR/icons/lbry48.png" usr/share/icons/hicolor/48x48/apps/lbry.png
addfile "$PACKAGING_DIR/icons/lbry96.png" usr/share/icons/hicolor/96x96/apps/lbry.png
addfile "$PACKAGING_DIR/icons/lbry128.png" usr/share/icons/hicolor/128x128/apps/lbry.png
addfile "$PACKAGING_DIR/icons/lbry256.png" usr/share/icons/hicolor/256x256/apps/lbry.png
addfile "$PACKAGING_DIR/lbry.desktop" usr/share/applications/lbry.desktop
# add lbry executable script
BINPATH=usr/share/python/lbrynet/bin
addfile "$PACKAGING_DIR/lbry" "$BINPATH/lbry"
# symlink script into /usr/bin
ln -s "/$BINPATH/lbry" "$PACKAGING_DIR/lbry-temp-symlink"
addfile "$PACKAGING_DIR/lbry-temp-symlink" usr/bin/lbry
# add lbrycrdd and lbrycrd-cli
mkdir -p "$PACKAGING_DIR/bins"
wget "$(curl https://api.github.com/repos/lbryio/lbrycrd/releases/latest | grep 'browser_download_url' | grep linux | cut -d'"' -f4)" --output-document "$PACKAGING_DIR/bins.zip"
unzip "$PACKAGING_DIR/bins.zip" -d "$PACKAGING_DIR/bins/"
addfile "$PACKAGING_DIR/bins/lbrycrdd" usr/bin/lbrycrdd
addfile "$PACKAGING_DIR/bins/lbrycrd-cli" usr/bin/lbrycrd-cli
# add postinstall script
cat "$PACKAGING_DIR/postinst_append" >> control/postinst
# change package name from lbrynet to lbry
sed -i 's/^Package: lbrynet/Package: lbry/' control/control
echo "Conflicts: lbrynet (<< 0.3.5)" >> control/control
echo "Replaces: lbrynet (<< 0.3.5)" >> control/control
# repackage .deb
$SUDO chown -R root:root control data
tar -czf control.tar.gz -C control .
+90
View File
@@ -0,0 +1,90 @@
import os
import webbrowser
import subprocess
import sys
from time import sleep
from jsonrpc.proxy import JSONRPCProxy
from lbrynet.conf import UI_ADDRESS, API_CONNECTION_STRING
class LBRYURIHandler(object):
def __init__(self):
self.started_daemon = False
self.daemon = JSONRPCProxy.from_url(API_CONNECTION_STRING)
def handle_osx(self, lbry_name):
self.check_daemon()
if not self.started_daemon:
os.system("open /Applications/LBRY.app")
sleep(3)
lbry_name = self.parse_name(lbry_name)
self.open_address(lbry_name)
def handle_linux(self, lbry_name):
self.check_daemon()
if not self.started_daemon:
cmd = r'DIR = "$( cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"' \
r'if [-z "$(pgrep lbrynet-daemon)"]; then' \
r'echo "running lbrynet-daemon..."' \
r'$DIR / lbrynet - daemon &' \
r'sleep 3 # let the daemon load before connecting' \
r'fi'
subprocess.Popen(cmd, shell=True)
lbry_name = self.parse_name(lbry_name)
self.open_address(lbry_name)
def handle_win32(self, lbry_name):
# Opening LBRY.exe with lbry_name as arg prevents the need to
# make a separate call to open_address()
self.check_daemon()
lbry_name = self.parse_name(lbry_name)
if self.started_daemon:
self.open_address(lbry_name)
else:
lbry_path = os.path.join(os.environ["PROGRAMFILES"], "LBRY", "LBRY.exe ")
subprocess.call(lbry_path + lbry_name)
def check_daemon(self):
try:
self.started_daemon = self.daemon.is_running()
except:
self.started_daemon = False
@staticmethod
def parse_name(lbry_name):
if lbry_name[:7].lower() == "lbry://":
if lbry_name[-1] == "/":
return lbry_name[7:-1]
else:
return lbry_name[7:]
else:
if lbry_name[-1] == "/":
return lbry_name[:-1]
else:
return lbry_name[:]
@staticmethod
def open_address(lbry_name):
if lbry_name == "lbry" or lbry_name == "" or lbry_name is None:
webbrowser.open(UI_ADDRESS)
else:
webbrowser.open(UI_ADDRESS + "/?show=" + lbry_name)
def main(args):
if len(args) != 1:
args = ["lbry://lbry"]
name = args[0][7:]
if sys.platform == "darwin":
LBRYURIHandler().handle_osx(lbry_name=name)
elif os.name == "nt":
LBRYURIHandler().handle_win32(lbry_name=name)
else:
LBRYURIHandler().handle_linux(lbry_name=name)
if __name__ == "__main__":
main(sys.argv[1:])
View File
Whitespace-only changes.
@@ -0,0 +1,15 @@
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\lbry]
@="URL:LBRY Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\lbry\DefaultIcon]
@="LBRY.exe,1"
[HKEY_CLASSES_ROOT\lbry\shell]
[HKEY_CLASSES_ROOT\lbry\shell\open]
[HKEY_CLASSES_ROOT\lbry\shell\open\command]
@="\"C:\\Program Files (x86)\\LBRY\\LBRY.exe\" \"%1\""
Loaded 100 of 126 files, more files were not shown because too many files have changed in this diff. Show more