better organize apps
This commit is contained in:
parent
02d8dc22e9
commit
e4f23b3fce
9 changed files with 77 additions and 198 deletions
52
lbrynet/lbrynet_daemon/Apps/LBRYURIHandler.py
Normal file
52
lbrynet/lbrynet_daemon/Apps/LBRYURIHandler.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
import os
|
||||
import json
|
||||
import webbrowser
|
||||
import xmlrpclib, sys
|
||||
|
||||
def render_video(path):
|
||||
r = r'<center><video src="' + path + r'" controls autoplay width="960" height="720"></center>'
|
||||
return r
|
||||
|
||||
|
||||
def main(args):
|
||||
if len(args) == 0:
|
||||
args.append('lbry://wonderfullife')
|
||||
|
||||
daemon = xmlrpclib.ServerProxy('http://localhost:7080/')
|
||||
|
||||
try:
|
||||
daemon.is_running()
|
||||
|
||||
if len(args) > 1:
|
||||
exit(1)
|
||||
|
||||
if args[0][7:] == 'lbry':
|
||||
daemon.render_gui()
|
||||
|
||||
elif args[0][7:] == 'settings':
|
||||
r = daemon.get_settings()
|
||||
html = "<body>" + json.dumps(r) + "</body>"
|
||||
daemon.render_html(html)
|
||||
|
||||
else:
|
||||
r = daemon.get(args[0][7:])
|
||||
path = r['path']
|
||||
if path[0] != '/':
|
||||
path = '/' + path
|
||||
|
||||
filename = os.path.basename(path)
|
||||
extension = os.path.splitext(filename)[1]
|
||||
|
||||
if extension in ['mp4', 'flv', 'mov']:
|
||||
html = render_video(path)
|
||||
daemon.render_html(html)
|
||||
|
||||
else:
|
||||
webbrowser.open('file://' + str(path))
|
||||
|
||||
except:
|
||||
webbrowser.open('http://lbry.io/get')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
0
lbrynet/lbrynet_daemon/Apps/__init__.py
Normal file
0
lbrynet/lbrynet_daemon/Apps/__init__.py
Normal file
|
@ -152,8 +152,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
|||
d.addCallback(lambda _: self._setup_lbry_file_opener())
|
||||
d.addCallback(lambda _: self._setup_query_handlers())
|
||||
d.addCallback(lambda _: self._setup_server())
|
||||
d.addCallback(lambda _: self._update() if self.check_for_updates == "True" and sys.platform == "darwin"
|
||||
else defer.succeed(None))
|
||||
# d.addCallback(lambda _: self._update() if self.check_for_updates == "True" and sys.platform == "darwin"
|
||||
# else defer.succeed(None))
|
||||
d.addCallback(lambda _: self._setup_fetcher())
|
||||
d.addCallback(lambda _: _disp_startup())
|
||||
d.callback(None)
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
import os
|
||||
import json
|
||||
import webbrowser
|
||||
import xmlrpclib, sys
|
||||
|
||||
|
||||
def render_video(path):
|
||||
r = r'<center><video src="' + path + r'" controls autoplay width="960" height="720"></center>'
|
||||
return r
|
||||
|
||||
|
||||
def main(args):
|
||||
if len(args) == 0:
|
||||
args.append('lbry://wonderfullife')
|
||||
|
||||
daemon = xmlrpclib.ServerProxy('http://localhost:7080/')
|
||||
|
||||
try:
|
||||
balance = daemon.get_balance()
|
||||
is_running = True
|
||||
if len(args) > 1:
|
||||
print 'Too many args', args
|
||||
|
||||
elif is_running:
|
||||
if args[0][7:] == 'lbry':
|
||||
daemon.render_gui()
|
||||
|
||||
elif args[0][7:] == 'settings':
|
||||
r = daemon.get_settings()
|
||||
html = "<body>" + json.dumps(r) + "</body>"
|
||||
r = daemon.render_html(html)
|
||||
else:
|
||||
if float(balance) > 0.0:
|
||||
r = daemon.get(args[0][7:])
|
||||
print r
|
||||
path = r['path']
|
||||
if path[0] != '/':
|
||||
path = '/' + path
|
||||
|
||||
print path
|
||||
filename = path.split('/')[len(path.split('/')) - 1]
|
||||
extension = path.split('.')[len(path.split('.')) - 1]
|
||||
|
||||
if extension in ['mp4', 'flv', 'mov']:
|
||||
html = render_video(path)
|
||||
daemon.render_html(html)
|
||||
|
||||
else:
|
||||
webbrowser.open('file://' + str(path))
|
||||
|
||||
except:
|
||||
webbrowser.open('http://lbry.io/get')
|
||||
is_running = False
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
|
@ -1,117 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>LBRYURIHandler</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeOSTypes</key>
|
||||
<array>
|
||||
<string>****</string>
|
||||
<string>fold</string>
|
||||
<string>disk</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>LBRYURIHandler</string>
|
||||
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>LBRYURIHandler</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>lbry</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSUIElement</key>
|
||||
<true/>
|
||||
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>PythonApplet.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.pythonmac.unspecified.LBRYURIHandler</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>LBRYURIHandler</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.0.0</string>
|
||||
<key>LSHasLocalizedDisplayName</key>
|
||||
<false/>
|
||||
<key>NSAppleScriptEnabled</key>
|
||||
<false/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright not specified</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>PyMainFileNames</key>
|
||||
<array>
|
||||
<string>__boot__</string>
|
||||
</array>
|
||||
<key>PyOptions</key>
|
||||
<dict>
|
||||
<key>alias</key>
|
||||
<false/>
|
||||
<key>argv_emulation</key>
|
||||
<true/>
|
||||
<key>emulate_shell_environment</key>
|
||||
<false/>
|
||||
<key>no_chdir</key>
|
||||
<false/>
|
||||
<key>prefer_ppc</key>
|
||||
<false/>
|
||||
<key>site_packages</key>
|
||||
<false/>
|
||||
<key>use_faulthandler</key>
|
||||
<false/>
|
||||
<key>use_pythonpath</key>
|
||||
<false/>
|
||||
<key>verbose</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>PyResourcePackages</key>
|
||||
<array>
|
||||
</array>
|
||||
<key>PyRuntimeLocations</key>
|
||||
<array>
|
||||
<string>@executable_path/../Frameworks/Python.framework/Versions/2.7/Python</string>
|
||||
</array>
|
||||
<key>PythonInfoDict</key>
|
||||
<dict>
|
||||
<key>PythonExecutable</key>
|
||||
<string>/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python</string>
|
||||
<key>PythonLongVersion</key>
|
||||
<string>2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12)
|
||||
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]</string>
|
||||
<key>PythonShortVersion</key>
|
||||
<string>2.7</string>
|
||||
<key>py2app</key>
|
||||
<dict>
|
||||
<key>alias</key>
|
||||
<false/>
|
||||
<key>template</key>
|
||||
<string>app</string>
|
||||
<key>version</key>
|
||||
<string>0.9</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
|
@ -1,19 +0,0 @@
|
|||
"""
|
||||
This is a setup.py script generated by py2applet
|
||||
|
||||
Usage:
|
||||
python setup.py py2app
|
||||
"""
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
APP = ['LBRYURIHandler.py']
|
||||
DATA_FILES = []
|
||||
OPTIONS = {'argv_emulation': True}
|
||||
|
||||
setup(
|
||||
app=APP,
|
||||
data_files=DATA_FILES,
|
||||
options={'py2app': OPTIONS},
|
||||
setup_requires=['py2app'],
|
||||
)
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
from setuptools import setup
|
||||
|
||||
APP = [os.path.join('lbrynet', 'lbrynet_daemon', 'LBRYOSXStatusBar.py')]
|
||||
APP = [os.path.join('lbrynet', 'lbrynet_daemon', 'Apps', 'LBRYOSXStatusBar.py')]
|
||||
DATA_FILES = []
|
||||
OPTIONS = {
|
||||
'argv_emulation': True,
|
||||
|
|
22
setup_uri_handler.py
Normal file
22
setup_uri_handler.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from setuptools import setup
|
||||
import os
|
||||
|
||||
APP = [os.path.join('lbrynet', 'lbrynet_daemon', 'Apps', 'LBRYURIHandler.py')]
|
||||
DATA_FILES = []
|
||||
OPTIONS = {'argv_emulation': True,
|
||||
'plist': {
|
||||
'CFBundleURLTypes': [
|
||||
{
|
||||
'CFBundleURLTypes': 'LBRYURIHandler',
|
||||
'CFBundleURLSchemes': ['lbry']
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
setup(
|
||||
app=APP,
|
||||
data_files=DATA_FILES,
|
||||
options={'py2app': OPTIONS},
|
||||
setup_requires=['py2app'],
|
||||
)
|
Loading…
Reference in a new issue