Merge pull request #510 from lbryio/remove_jsonrpc_coms

Removing unuseful/unused commands from daemon API
This commit is contained in:
Umpei Kay Kurokawa 2017-03-07 21:23:33 -05:00 committed by GitHub
commit ac33663444
3 changed files with 2 additions and 154 deletions

View file

@ -22,6 +22,7 @@ at anytime.
### Fixed
* Added string comparison to ClaimOutpoint (needed to look things up by outpoint)
* Remove unused API commands from daemon
*
*

View file

@ -1,42 +1,7 @@
import os
import sys
import subprocess
from contextlib import contextmanager
def start(path):
"""
Open a file with the OS's default program. (Cross-platform equivalent of os.startfile() for
Windows)
"""
if not os.path.isfile(path):
raise(IOError, "No such file: '%s'" % path)
if sys.platform == 'darwin':
subprocess.Popen(['open', path])
elif os.name == 'posix':
subprocess.Popen(['xdg-open', path])
elif sys.platform == 'win32':
os.startfile(path)
def reveal(path):
"""
Reveal a file in file browser.
"""
if not os.path.isfile(path):
raise(IOError, "No such file: '%s'" % path)
if sys.platform == 'darwin':
subprocess.Popen(['open', '-R', path])
elif os.name == 'posix':
# No easy way to reveal specific files on Linux, so just open the containing directory
subprocess.Popen(['xdg-open', os.path.dirname(path)])
elif sys.platform == 'win32':
subprocess.Popen(['explorer', '/select', path])
@contextmanager
def get_read_handle(path):
"""

View file

@ -38,7 +38,7 @@ from lbrynet.lbrynet_daemon.Publisher import Publisher
from lbrynet.lbrynet_daemon.ExchangeRateManager import ExchangeRateManager
from lbrynet.lbrynet_daemon.auth.server import AuthJSONRPCServer
from lbrynet.core.PaymentRateManager import OnlyFreePaymentsManager
from lbrynet.core import log_support, utils, file_utils
from lbrynet.core import log_support, utils
from lbrynet.core import system_info
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob
from lbrynet.core.Session import Session
@ -2156,111 +2156,6 @@ class Daemon(AuthJSONRPCServer):
response = yield self._render_response("Deleted %s" % blob_hash)
defer.returnValue(response)
def jsonrpc_get_nametrie(self):
"""
Get the nametrie
Args:
None
Returns:
Name claim trie
"""
d = self.session.wallet.get_nametrie()
d.addCallback(lambda r: [i for i in r if 'txid' in i.keys()])
d.addCallback(lambda r: self._render_response(r))
return d
def jsonrpc_log(self, message):
"""
DEPRECATED. This method will be removed in a future release.
Log message
Args:
'message': message to be logged
Returns:
True
"""
log.info("API client log request: %s" % message)
return self._render_response(True)
def jsonrpc_upload_log(self, name_prefix=None, log_type=None, exclude_previous=True,
message=None, force=False):
"""
DEPRECATED. This method will be removed in a future release.
Upload log
Args, optional:
'name_prefix': prefix to indicate what is requesting the log upload
'exclude_previous': true/false, whether or not to exclude
previous sessions from upload, defaults on true
Returns:
True
"""
if name_prefix is not None:
log_type = name_prefix + '_api'
elif log_type is not None:
log_type += '_api'
else:
log_type = 'api'
if message is not None:
log.info("Upload log message: " + str(message))
d = self._upload_log(log_type=log_type, exclude_previous=exclude_previous, force=force)
d.addCallback(lambda _: self._render_response(True))
return d
@AuthJSONRPCServer.auth_required
@defer.inlineCallbacks
def jsonrpc_open(self, sd_hash):
"""
Instruct the OS to open a file with its default program.
Args:
'sd_hash': SD hash of file to be opened
Returns:
True, opens file
"""
lbry_file = yield self._get_lbry_file(FileID.SD_HASH, sd_hash)
if not lbry_file:
raise Exception('Unable to find file for {}'.format(sd_hash))
try:
file_utils.start(lbry_file['download_path'])
except IOError:
pass
defer.returnValue(True)
@defer.inlineCallbacks
@AuthJSONRPCServer.auth_required
def jsonrpc_reveal(self, sd_hash):
"""
Reveal a file or directory in file browser
Args:
'path': path to be revealed in file browser
Returns:
True, opens file browser
"""
lbry_file = yield self._get_lbry_file(FileID.SD_HASH, sd_hash)
if not lbry_file:
raise Exception('Unable to find file for {}'.format(sd_hash))
try:
file_utils.reveal(lbry_file['download_path'])
except IOError:
pass
defer.returnValue(True)
def jsonrpc_get_peers_for_hash(self, blob_hash):
"""
DEPRECATED. Use `peer_list` instead
@ -2398,19 +2293,6 @@ class Daemon(AuthJSONRPCServer):
d.addCallback(lambda r: self._render_response(r))
return d
def jsonrpc_get_mean_availability(self):
"""
Get mean blob availability
Args:
None
Returns:
Mean peers for a blob
"""
d = self._render_response(self.session.blob_tracker.last_mean_availability)
return d
@defer.inlineCallbacks
def jsonrpc_get_availability(self, name, sd_timeout=None, peer_timeout=None):
"""