Compare commits

..

No commits in common. "b4c4372394f63cac8c0f688070158ae7ab9590fa" and "5b4a58f2db6c2ee2bc0ad091cbe74775f99ad26c" have entirely different histories.

12 changed files with 42 additions and 64 deletions

View file

@ -3,12 +3,11 @@
import os import os
import sys import sys
from os.path import normpath, dirname, abspath, join
import site
base = normpath(dirname(dirname(dirname(abspath(__file__)))))
if sys.platform == 'win32': if sys.platform == 'win32':
from os.path import normpath, dirname, abspath, join
import site
base = normpath(dirname(dirname(dirname(abspath(__file__)))))
for site_packages in ( for site_packages in (
join(base, 'openmedialibrary'), join(base, 'openmedialibrary'),
join(base, 'platform', 'Shared', 'lib', 'python3.4', 'site-packages'), join(base, 'platform', 'Shared', 'lib', 'python3.4', 'site-packages'),
@ -21,7 +20,6 @@ if sys.platform == 'win32':
unrar_dll = join(base, 'platform_win32', 'unrar.dll') unrar_dll = join(base, 'platform_win32', 'unrar.dll')
if os.path.exists(unrar_dll): if os.path.exists(unrar_dll):
os.environ['UNRAR_LIB_PATH'] = unrar_dll os.environ['UNRAR_LIB_PATH'] = unrar_dll
os.environ['TCL_LIBRARY'] = join(base, 'platform_win32', 'tcl', 'tcl8.6')
import api import api
import commands import commands
@ -29,9 +27,6 @@ import server
if len(sys.argv) > 1 and sys.argv[1] == 'server': if len(sys.argv) > 1 and sys.argv[1] == 'server':
server.run() server.run()
if len(sys.argv) > 1 and sys.argv[1] == 'ui':
import ui
ui.main(sys.argv[2:])
else: else:
commands.main() commands.main()
if sys.platform == 'win32': if sys.platform == 'win32':

View file

@ -13,7 +13,6 @@ from oxtornado import actions
import item.api import item.api
import user.api import user.api
import update import update
import utils
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -21,8 +20,8 @@ logger = logging.getLogger(__name__)
def win32_ui(type): def win32_ui(type):
base = normpath(dirname(dirname(dirname(abspath(__file__))))) base = normpath(dirname(dirname(dirname(abspath(__file__)))))
cmd = [ cmd = [
join('..', 'platform_win32', 'pythonw.exe'), join(base, 'platform_win32', 'python.exe'),
join('oml', 'ui.py'), type join(base, 'openmediablirary', 'oml', 'ui.py'), type
] ]
return cmd return cmd
@ -32,7 +31,14 @@ def selectFolder(data):
path path
} }
''' '''
path = utils.ctl_output('ui', 'folder') cmd = ['./ctl', 'ui', 'folder']
if sys.platform == 'win32':
cmd = win32_ui('folder')
if 'base' in data:
cmd += [data['base']]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
stdout, stderr = p.communicate()
path = stdout.decode('utf-8').strip()
if path == 'None': if path == 'None':
path = None path = None
return { return {
@ -47,7 +53,14 @@ def selectFile(data):
path path
} }
''' '''
path = utils.ctl_output('ui', 'file') cmd = ['./ctl', 'ui', 'file']
if sys.platform == 'win32':
cmd = win32_ui('file')
if 'base' in data:
cmd += [data['base']]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
path = stdout.decode('utf-8').strip()
if path == 'None': if path == 'None':
path = None path = None
return { return {

View file

@ -844,7 +844,7 @@ def download_cover(id):
else: else:
url = None url = None
logger.debug('download cover %s %s', id, url) logger.debug('download cover %s %s', self.id, url)
ratio = None ratio = None
try: try:
cover = ox.net.read_url(url) cover = ox.net.read_url(url)

View file

@ -90,9 +90,11 @@ USER_AGENT = 'OpenMediaLibrary/%s' % VERSION
DEBUG_HTTP = server.get('debug_http', False) DEBUG_HTTP = server.get('debug_http', False)
DEBUG_API = server.get('debug_api', False) DEBUG_API = server.get('debug_api', False)
DB_VERSION = 13
FULLTEXT_SUPPORT = fulltext.platform_supported() FULLTEXT_SUPPORT = fulltext.platform_supported()
if not FULLTEXT_SUPPORT: if not FULLTEXT_SUPPORT:
config['itemKeys'] = [k for k in config['itemKeys'] if k['id'] != 'fulltext'] config['itemKeys'] = [k for k in config['itemKeys'] if k['id'] != 'fulltext']
DB_VERSION = 14

View file

@ -93,17 +93,6 @@ class TkUI:
filename = tkinter.filedialog.askopenfilename(parent=self.root, title=data.get("title", "Select File")) filename = tkinter.filedialog.askopenfilename(parent=self.root, title=data.get("title", "Select File"))
return short_home(filename) return short_home(filename)
def main(args):
base = '~'
if len(args) >= 2:
base = args[1]
base = os.path.expanduser(base)
if os.path.exists(base):
os.chdir(base)
if args and args[0] == 'folder':
print(ui.selectFolder({}))
else:
print(ui.selectFile({}))
if use_Gtk: if use_Gtk:
ui = GtkUI() ui = GtkUI()
@ -111,4 +100,13 @@ else:
ui = TkUI() ui = TkUI()
if __name__ == '__main__': if __name__ == '__main__':
main(sys.argv[1:]) base = '~'
if len(sys.argv) >= 3:
base = sys.argv[2]
base = os.path.expanduser(base)
if os.path.exists(base):
os.chdir(base)
if len(sys.argv) >= 2 and sys.argv[1] == 'folder':
print(ui.selectFolder({}))
else:
print(ui.selectFile({}))

View file

@ -617,11 +617,3 @@ def migrate_13():
if revision > -1: if revision > -1:
settings.server['revision'] = revision settings.server['revision'] = revision
return 13 return 13
def migrate_14():
from user.models import List
with db.session():
l = List.get(':Public')
if l and not len(l.items):
l.remove()
return 14

View file

@ -305,7 +305,7 @@ def addListItems(data):
if data['list'] == ':': if data['list'] == ':':
from item.models import Item from item.models import Item
for item_id in data['items']: for item_id in data['items']:
i = Item.get(item_id, for_update=True) i = Item.get(item_id)
i.queue_download() i.queue_download()
i.update() i.update()
elif data['list'] and (data['list'].startswith(':') or data['list'].endswith(':')): elif data['list'] and (data['list'].startswith(':') or data['list'].endswith(':')):

View file

@ -409,24 +409,6 @@ def ctl(*args):
subprocess.Popen([os.path.join(settings.base_dir, 'ctl')] + list(args), subprocess.Popen([os.path.join(settings.base_dir, 'ctl')] + list(args),
close_fds=True, start_new_session=True) close_fds=True, start_new_session=True)
def ctl_output(*args):
import settings
if sys.platform == 'win32':
platform_win32 = os.path.join('..', 'platform_win32')
python = os.path.join(platform_win32, 'python.exe')
cmd = [python, 'oml'] + list(args)
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
p = subprocess.Popen(cmd, cwd=settings.base_dir, startupinfo=startupinfo,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
p = subprocess.Popen([os.path.join(settings.base_dir, 'ctl')] + list(args),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
logger.debug('ctl_output%s -> %s [%s]', args, stdout, stderr)
return stdout.decode('utf-8').strip()
def user_sort_key(u): def user_sort_key(u):
return ox.sort_string(str(u.get('index', '')) + 'Z' + (u.get('name') or '')) return ox.sort_string(str(u.get('index', '')) + 'Z' + (u.get('name') or ''))

View file

@ -12,7 +12,7 @@ oml.ui.annotation = function(annotation, $iframe) {
} }
}) })
var notes = annotation.notes.length ? annotation.notes.map(function(note) { var notes = annotation.notes.length ? annotation.notes.map(function(note) {
note.editable = !note.user note.editable = note.user == ''
return note return note
}) : [{ }) : [{
id: 'A', id: 'A',

View file

@ -64,7 +64,7 @@ oml.ui.list = function() {
&& ui.find.conditions[0].key == 'list' && ui.find.conditions[0].key == 'list'
&& ui.find.conditions[0].operator == '==' && ui.find.conditions[0].operator == '=='
)) { )) {
oml.$ui.folders.updateItems(ui.find.conditions.length ? ui.find.conditions[0].value : "", data.items); oml.$ui.folders.updateItems(ui.find.conditions[0].value, data.items);
} }
oml.$ui.statusbar.set('total', data); oml.$ui.statusbar.set('total', data);
}, },

View file

@ -287,10 +287,8 @@
// FF3.6 document.body can be undefined here // FF3.6 document.body can be undefined here
window.onload = function() { window.onload = function() {
document.body.style.margin = 0; document.body.style.margin = 0;
if (!animationInterval) { document.body.appendChild(loadingScreen);
document.body.appendChild(loadingScreen); startAnimation();
startAnimation();
}
}; };
// IE8 does not call onload if already loaded before set // IE8 does not call onload if already loaded before set
document.body && window.onload(); document.body && window.onload();

View file

@ -121,10 +121,8 @@
// FF3.6 document.body can be undefined here // FF3.6 document.body can be undefined here
window.onload = function() { window.onload = function() {
document.body.style.margin = 0; document.body.style.margin = 0;
if (!animationInterval) { document.body.appendChild(loadingScreen);
document.body.appendChild(loadingScreen); startAnimation();
startAnimation();
}
}; };
// IE8 does not call onload if already loaded before set // IE8 does not call onload if already loaded before set
document.body && window.onload(); document.body && window.onload();