diff --git a/oml/__main__.py b/oml/__main__.py index 9bb7491..3c54ef6 100644 --- a/oml/__main__.py +++ b/oml/__main__.py @@ -3,12 +3,11 @@ import os import sys -from os.path import normpath, dirname, abspath, join -import site - -base = normpath(dirname(dirname(dirname(abspath(__file__))))) 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 ( join(base, 'openmedialibrary'), 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') if os.path.exists(unrar_dll): os.environ['UNRAR_LIB_PATH'] = unrar_dll - os.environ['TCL_LIBRARY'] = join(base, 'platform_win32', 'tcl', 'tcl8.6') import api import commands @@ -29,9 +27,6 @@ import server if len(sys.argv) > 1 and sys.argv[1] == 'server': server.run() -if len(sys.argv) > 1 and sys.argv[1] == 'ui': - import ui - ui.main(sys.argv[2:]) else: commands.main() if sys.platform == 'win32': diff --git a/oml/api.py b/oml/api.py index 1975c7d..bf44566 100644 --- a/oml/api.py +++ b/oml/api.py @@ -13,7 +13,6 @@ from oxtornado import actions import item.api import user.api import update -import utils import logging logger = logging.getLogger(__name__) @@ -21,8 +20,8 @@ logger = logging.getLogger(__name__) def win32_ui(type): base = normpath(dirname(dirname(dirname(abspath(__file__))))) cmd = [ - join('..', 'platform_win32', 'pythonw.exe'), - join('oml', 'ui.py'), type + join(base, 'platform_win32', 'python.exe'), + join(base, 'openmediablirary', 'oml', 'ui.py'), type ] return cmd @@ -32,7 +31,14 @@ def selectFolder(data): 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': path = None return { @@ -47,7 +53,14 @@ def selectFile(data): 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': path = None return { diff --git a/oml/item/models.py b/oml/item/models.py index a2b200a..a104506 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -844,7 +844,7 @@ def download_cover(id): else: url = None - logger.debug('download cover %s %s', id, url) + logger.debug('download cover %s %s', self.id, url) ratio = None try: cover = ox.net.read_url(url) diff --git a/oml/settings.py b/oml/settings.py index 23b0f35..f70b930 100644 --- a/oml/settings.py +++ b/oml/settings.py @@ -90,9 +90,11 @@ USER_AGENT = 'OpenMediaLibrary/%s' % VERSION DEBUG_HTTP = server.get('debug_http', False) DEBUG_API = server.get('debug_api', False) +DB_VERSION = 13 + + FULLTEXT_SUPPORT = fulltext.platform_supported() if not FULLTEXT_SUPPORT: config['itemKeys'] = [k for k in config['itemKeys'] if k['id'] != 'fulltext'] -DB_VERSION = 14 diff --git a/oml/ui.py b/oml/ui.py index 40e79b8..5b9dc26 100644 --- a/oml/ui.py +++ b/oml/ui.py @@ -93,17 +93,6 @@ class TkUI: filename = tkinter.filedialog.askopenfilename(parent=self.root, title=data.get("title", "Select File")) 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: ui = GtkUI() @@ -111,4 +100,13 @@ else: ui = TkUI() 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({})) diff --git a/oml/update.py b/oml/update.py index 8dab498..8e533d9 100644 --- a/oml/update.py +++ b/oml/update.py @@ -617,11 +617,3 @@ def migrate_13(): if revision > -1: settings.server['revision'] = revision 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 diff --git a/oml/user/api.py b/oml/user/api.py index be190ad..87185c2 100644 --- a/oml/user/api.py +++ b/oml/user/api.py @@ -305,7 +305,7 @@ def addListItems(data): if data['list'] == ':': from item.models import Item for item_id in data['items']: - i = Item.get(item_id, for_update=True) + i = Item.get(item_id) i.queue_download() i.update() elif data['list'] and (data['list'].startswith(':') or data['list'].endswith(':')): diff --git a/oml/utils.py b/oml/utils.py index c080426..6e6d924 100644 --- a/oml/utils.py +++ b/oml/utils.py @@ -409,24 +409,6 @@ def ctl(*args): subprocess.Popen([os.path.join(settings.base_dir, 'ctl')] + list(args), 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): return ox.sort_string(str(u.get('index', '')) + 'Z' + (u.get('name') or '')) diff --git a/static/js/annotation.js b/static/js/annotation.js index bf69252..98066ea 100644 --- a/static/js/annotation.js +++ b/static/js/annotation.js @@ -12,7 +12,7 @@ oml.ui.annotation = function(annotation, $iframe) { } }) var notes = annotation.notes.length ? annotation.notes.map(function(note) { - note.editable = !note.user + note.editable = note.user == '' return note }) : [{ id: 'A', diff --git a/static/js/list.js b/static/js/list.js index 431d7d9..3c159ae 100644 --- a/static/js/list.js +++ b/static/js/list.js @@ -64,7 +64,7 @@ oml.ui.list = function() { && ui.find.conditions[0].key == 'list' && 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); }, diff --git a/static/js/oml.js b/static/js/oml.js index 9f14921..182c825 100644 --- a/static/js/oml.js +++ b/static/js/oml.js @@ -287,10 +287,8 @@ // FF3.6 document.body can be undefined here window.onload = function() { document.body.style.margin = 0; - if (!animationInterval) { - document.body.appendChild(loadingScreen); - startAnimation(); - } + document.body.appendChild(loadingScreen); + startAnimation(); }; // IE8 does not call onload if already loaded before set document.body && window.onload(); diff --git a/static/js/oml.update.js b/static/js/oml.update.js index 14961ad..aec6d55 100644 --- a/static/js/oml.update.js +++ b/static/js/oml.update.js @@ -121,10 +121,8 @@ // FF3.6 document.body can be undefined here window.onload = function() { document.body.style.margin = 0; - if (!animationInterval) { - document.body.appendChild(loadingScreen); - startAnimation(); - } + document.body.appendChild(loadingScreen); + startAnimation(); }; // IE8 does not call onload if already loaded before set document.body && window.onload();