diff --git a/RUNNING b/RUNNING index b6b64031f..1c5d29d4b 100644 --- a/RUNNING +++ b/RUNNING @@ -1,52 +1,97 @@ -To install LBRYnet and lbrynet-console, see INSTALL +How to watch It's a Wonderful Life via LBRY -lbrynet-console is a console application which makes use of the LBRYnet to share files. +Quickest quick guide +-------------------- -In particular, lbrynet-console splits files into encrypted chunks of data compatible with -LBRYnet, groups all metadata into a 'stream descriptor file' which can be sent directly to -others wishing to obtain the file, or can be itself turned into a chunk compatible with -LBRYnet and downloaded via LBRYnet by anyone knowing its sha384 hashsum. lbrynet-console -also acts as a client whichreads a stream descriptor file, downloads the chunks of data -specified by the hash sums found in the stream descriptor file, decrypts them according to -metadata found in the stream, and reconstructs the original file. lbrynet-console features -a server so that clients can connect to it and download the chunks and other data gotten -from files created locally and files that have been downloaded from LBRYnet. +Create a directory called lbry, and go into that directory +Download the file https://raw.githubusercontent.com/lbryio/lbry-setup/master/lbry_setup.sh and run it in that directory +Once it's done building, type: +./lbrycrd/src/lbrycrdd -server -daemon -gen +lbrynet-gui +A window should show up with an entry box +Type wonderfullife into the box, hit go, and choose to stream or save +To stop lbrycrdd: +./lbrycrd/src/lbrycrd-cli stop -lbrynet-console also has a plugin system. There are two plugins: a live stream proof of -concept which is currently far behind the development of the rest of the application and -therefore will not run, and a plugin which attempts to determine which chunks on the -network should be downloaded in order for the application to turn a profit. It will run, -but its usefulness is extremely limited. +Slightly longer install guide +----------------------------- -Passing '--help' to lbrynet-console will cause it to print out a quick help message -describing other command line options to the application. +Acquire the LBRYcrd source code from https://github.com/lbryio/lbrycrd +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 +make -Once the application has been started, the user is presented with a numbered list of -actions which looks something like this: +When make has completed, create the directory where LBRYcrd data will be stored. ~/.lbrycrd is where LBRYcrd will look by default and so is recommended. +mkdir ~/.lbrycrd +vim ~/.lbrycrd/lbrycrd.conf +Add the following lines to enable the RPC interface, which will be used by lbrynet-console. -... -[2] Toggle whether an LBRY File is running -[3] Create an LBRY File from file -[4] Publish a stream descriptor file to the DHT for an LBRY File -... +rpcuser=rpcuser +rpcpassword=rpcpassword -To perform an action, type the desired number and then hit enter. For example, if you wish -to create an LBRY file from a file as described in the beginning of this document, type 3 and -hit enter. +(use a long random password if your computer is on a network anyone else has access to) -If the application needs more input in order to for the action to be taken, the application -will continue to print prompts for input until it has received what it needs. +cd .. -For example, when creating an LBRY file from a file, the application needs to know which file -it's supposed to use to create the LBRY file, so the user will be prompted for it: +Acquire the LBRYnet source code from https://github.com/lbryio/lbry +cd lbry +sudo apt-get install libgmp3-dev build-essential python-dev python-pip -File name: +(with virtualenv) +python-virtualenv +virtualenv . +source bin/activate +python setup.py install -The user should input the desired file name and hit enter, at which point the application -will go about splitting the file and making it available on the network. +to deactivate the virtualenv later: +deactivate -Some actions will produce sub-menus of actions, which work the same way. +to reactivate it, go to the directory in which you created it and: +source bin/activate -A more detailed user guide is available at doc.lbry.io +(without virtualenv) +python setup.py build bdist_egg +sudo python setup.py install -Any issues may be reported to jimmy@lbry.io \ No newline at end of file +Slightly longer running guide +----------------------------- + +In order to use lbrynet, lbyrcrdd must be running. +If you ran the easy install script, the lbrycrd folder will be in the directory you ran lbry_setup.sh from. Otherwise it is the root of the cloned lbrycrd repository. Go to that directory. + +./src/lbrycrdd -server -daemon -gen + +It will take a few minutes for your client to download the whole block chain. +Once it has caught up, it will start mining coins. If you don't want to mine, leave off the '-gen' flag. +lbrycrdd must be running in order for lbrynet to function. +To shut lbrycrdd down: from the lbrycrd directory, run + + ./src/lbrycrd-cli stop + +Running lbrynet-console + +In your terminal: + +lbrynet-console + +You should now be presented with a list of options. +Watch It's a Wonderful Life via LBRY +Choose the option labeled Add a stream from a short name by typing the number next to it and pressing the enter key. +You will be prompted for a name. Type in "wonderfullife" and hit enter. +After a few seconds, you will prompted to choose what you want to do with the file. +Select the option labeled Open the file with VLC media player. +You will be shown some options related to the file which you do not care about. Type 'n' and hit enter. +You will be prompted to choose if you really want to download this file. Type 'y' and hit enter. +To shut it down, type ctrl-c at any time or enter the option to shut down from the main menu. + +Running lbrynet-gui +In your terminal: + +lbrynet-gui + +A window should pop up with an entry box. Type 'wonderfullife' into the box, hit go, and then choose to save it or stream it. +Enjoy! + +Any questions or problems, email jimmy@lbry.io \ No newline at end of file diff --git a/lbrynet/core/LBRYcrdWallet.py b/lbrynet/core/LBRYcrdWallet.py index d797d741f..a305f683e 100644 --- a/lbrynet/core/LBRYcrdWallet.py +++ b/lbrynet/core/LBRYcrdWallet.py @@ -39,8 +39,8 @@ class LBRYcrdWallet(object): """This class implements the LBRYWallet interface for the LBRYcrd payment system""" implements(ILBRYWallet) - def __init__(self, rpc_user, rpc_pass, rpc_url, rpc_port, start_lbrycrdd=False, - wallet_dir=None, wallet_conf=None): + def __init__(self, rpc_user, rpc_pass, rpc_url, rpc_port, wallet_dir=None, wallet_conf=None, + lbrycrdd_path=None): self.rpc_conn_string = "http://%s:%s@%s:%s" % (rpc_user, rpc_pass, rpc_url, str(rpc_port)) self.next_manage_call = None self.wallet_balance = Decimal(0.0) @@ -53,17 +53,17 @@ class LBRYcrdWallet(object): # incremental_amount(float)) self.max_expected_payment_time = datetime.timedelta(minutes=3) self.stopped = True - self.start_lbrycrdd = start_lbrycrdd self.started_lbrycrdd = False self.wallet_dir = wallet_dir self.wallet_conf = wallet_conf self.lbrycrdd = None self.manage_running = False + self.lbrycrdd_path = lbrycrdd_path def start(self): def make_connection(): - if self.start_lbrycrdd is True: + if self.lbrycrdd_path is not None: self._start_daemon() self._get_info() log.info("Connected!") @@ -91,7 +91,7 @@ class LBRYcrdWallet(object): d = self.manage() d.addErrback(log_stop_error) - if self.start_lbrycrdd is True: + if self.lbrycrdd_path is not None: d.addCallback(lambda _: self._stop_daemon()) d.addErrback(log_stop_error) return d @@ -296,16 +296,21 @@ class LBRYcrdWallet(object): def _start_daemon(self): - if os.name == "nt": - si = subprocess.STARTUPINFO - si.dwFlags = subprocess.STARTF_USESHOWWINDOW - si.wShowWindow = subprocess.SW_HIDE - self.lbrycrdd = subprocess.Popen(["lbrycrdd.exe", "-datadir=%s" % self.wallet_dir, - "-conf=%s" % self.wallet_conf], startupinfo=si) - else: - self.lbrycrdd = subprocess.Popen(["./lbrycrdd", "-datadir=%s" % self.wallet_dir, - "-conf=%s" % self.wallet_conf]) - self.started_lbrycrdd = True + try: + if os.name == "nt": + si = subprocess.STARTUPINFO + si.dwFlags = subprocess.STARTF_USESHOWWINDOW + si.wShowWindow = subprocess.SW_HIDE + self.lbrycrdd = subprocess.Popen([self.lbrycrdd_path, "-datadir=%s" % self.wallet_dir, + "-conf=%s" % self.wallet_conf], startupinfo=si) + else: + self.lbrycrdd = subprocess.Popen([self.lbrycrdd_path, "-datadir=%s" % self.wallet_dir, + "-conf=%s" % self.wallet_conf]) + self.started_lbrycrdd = True + except OSError: + import traceback + log.error("Couldn't launch lbrycrdd at path %s: %s", self.lbrycrdd_path, traceback.format_exc()) + raise ValueError("Couldn't launch lbrycrdd. Tried %s" % self.lbrycrdd_path) tries = 0 while tries < 5: diff --git a/lbrynet/lbrynet_gui/LBRYGui.py b/lbrynet/lbrynet_gui/LBRYGui.py index e62ed475f..646d08295 100644 --- a/lbrynet/lbrynet_gui/LBRYGui.py +++ b/lbrynet/lbrynet_gui/LBRYGui.py @@ -19,6 +19,7 @@ from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileSaverFactory, LBR from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier import os import requests +import shutil from twisted.internet import threads, defer, task @@ -51,7 +52,12 @@ class LBRYDownloader(object): self.stream_frames = [] self.default_blob_data_payment_rate = MIN_BLOB_DATA_PAYMENT_RATE self.use_upnp = False - self.start_lbrycrdd = True + if os.name == "nt": + self.start_lbrycrdd = True + self.lbrycrdd_path = "lbrycrdd.exe" + else: + self.start_lbrycrdd = False + self.lbrycrdd_path = "./lbrycrdd" self.delete_blobs_on_remove = True self.blob_request_payment_rate_manager = None @@ -111,15 +117,21 @@ class LBRYDownloader(object): def _load_configuration_file(self): def get_configuration(): - if not os.path.exists("lbry.conf"): - log.debug("Could not read lbry.conf") - return "" + 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 = open("lbry.conf") - log.debug("Loading configuration options from lbry.conf") - lines = lbry_conf.readlines() - log.debug("lbry.conf file contents:\n%s", str(lines)) - return lines + 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 = threads.deferToThread(get_configuration) @@ -209,6 +221,8 @@ class LBRYDownloader(object): 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 @@ -257,9 +271,12 @@ class LBRYDownloader(object): self.wallet_rpc_port = int(l[8:-1]) def _get_session(self): - wallet = LBRYcrdWallet(self.wallet_user, self.wallet_password, "127.0.0.1", self.wallet_rpc_port, - start_lbrycrdd=self.start_lbrycrdd, wallet_dir=self.wallet_dir, - wallet_conf=self.wallet_conf) + lbrycrdd_path = None + if self.start_lbrycrdd is True: + lbrycrdd_path = self.lbrycrdd_path + wallet = LBRYcrdWallet(self.wallet_user, self.wallet_password, "127.0.0.1", + self.wallet_rpc_port, 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 diff --git a/lbrynet/lbrynet_gui/lbry.conf b/lbrynet/lbrynet_gui/lbry.conf index 025b501c2..536c3c99e 100644 --- a/lbrynet/lbrynet_gui/lbry.conf +++ b/lbrynet/lbrynet_gui/lbry.conf @@ -30,15 +30,22 @@ # Turn on or off the server, which uploads encrypted chunks of data # to other clients on the network. # -# run_server = true +# 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 +# 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 diff --git a/setup.py b/setup.py index 10ffb16cc..32dae8153 100644 --- a/setup.py +++ b/setup.py @@ -38,6 +38,7 @@ setup(name='lbrynet', 'lbrynet/lbrynet_gui/drop_down.gif', 'lbrynet/lbrynet_gui/show_options.gif', 'lbrynet/lbrynet_gui/hide_options.gif', + 'lbrynet/lbrynet_gui/lbry.conf', ] ) ]