Refactor lbrycrdd path function for osx
This commit is contained in:
parent
9a9b540701
commit
0ba0426591
1 changed files with 19 additions and 8 deletions
|
@ -320,14 +320,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
else:
|
else:
|
||||||
self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbryum")
|
self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbryum")
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
# use the path from the bundle if its available.
|
self.lbrycrdd_path = get_darwin_lbrycrdd_path()
|
||||||
try:
|
|
||||||
import Foundation
|
|
||||||
bundle = Foundation.NSBundle.mainBundle()
|
|
||||||
self.lbrycrdd_path = bundle.pathForResource_ofType_('lbrycrdd', None)
|
|
||||||
except Exception:
|
|
||||||
log.exception('Failed to get path from bundle, falling back to default')
|
|
||||||
self.lbrycrdd_path = "./lbrycrdd"
|
|
||||||
if self.wallet_type == "lbrycrd":
|
if self.wallet_type == "lbrycrd":
|
||||||
self.wallet_dir = user_data_dir("lbrycrd")
|
self.wallet_dir = user_data_dir("lbrycrd")
|
||||||
else:
|
else:
|
||||||
|
@ -2384,6 +2377,24 @@ def get_output_callback(params):
|
||||||
return callback
|
return callback
|
||||||
|
|
||||||
|
|
||||||
|
def get_darwin_lbrycrdd_path():
|
||||||
|
# use the path from the bundle if its available.
|
||||||
|
default = "./lbrycrdd"
|
||||||
|
try:
|
||||||
|
import Foundation
|
||||||
|
except ImportError:
|
||||||
|
log.warning('Foundation module not installed, falling back to default lbrycrdd path')
|
||||||
|
return default
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
bundle = Foundation.NSBundle.mainBundle()
|
||||||
|
return bundle.pathForResource_ofType_('lbrycrdd', None)
|
||||||
|
except Exception:
|
||||||
|
log.exception('Failed to get path from bundle, falling back to default')
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class _DownloadNameHelper(object):
|
class _DownloadNameHelper(object):
|
||||||
def __init__(self, daemon, name, timeout=DEFAULT_TIMEOUT, download_directory=None,
|
def __init__(self, daemon, name, timeout=DEFAULT_TIMEOUT, download_directory=None,
|
||||||
file_name=None, wait_for_write=True):
|
file_name=None, wait_for_write=True):
|
||||||
|
|
Loading…
Reference in a new issue