Compare commits
No commits in common. "74e89693ffa88ce054d598cc3fbcf7fbb088fdc8" and "3ec0930f5292424f13c39f2b3c4fc99275da93ae" have entirely different histories.
74e89693ff
...
3ec0930f52
7 changed files with 27 additions and 50 deletions
|
|
@ -7,30 +7,15 @@ from sqlalchemy.sql import operators
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_prefix():
|
|
||||||
import settings
|
|
||||||
return os.path.join(os.path.expanduser(settings.preferences['libraryPath']), 'Books/')
|
|
||||||
|
|
||||||
def get_ids(books):
|
|
||||||
from item.models import File
|
|
||||||
ids = [b[0] for b in File.query.filter(operators.in_op(File.path, books)).values('sha1')]
|
|
||||||
return ids
|
|
||||||
|
|
||||||
def find_fulltext_macos(query):
|
def find_fulltext_macos(query):
|
||||||
prefix = get_prefix()
|
import settings
|
||||||
|
from item.models import File
|
||||||
|
prefix = os.path.join(os.path.expanduser(settings.preferences['libraryPath']), 'Books/')
|
||||||
cmd = ["mdfind", "-onlyin", prefix, query]
|
cmd = ["mdfind", "-onlyin", prefix, query]
|
||||||
books = subprocess.check_output(cmd).decode().strip().split('\n')
|
books = subprocess.check_output(cmd).decode().strip().split('\n')
|
||||||
books = [path[len(prefix):] for path in books]
|
books = [path[len(prefix):] for path in books]
|
||||||
return get_ids(books)
|
ids = [b[0] for b in File.query.filter(operators.in_op(File.path, books)).values('sha1')]
|
||||||
|
return ids
|
||||||
def find_fulltext_windows(query):
|
|
||||||
prefix = get_prefix()
|
|
||||||
prefix = os.path.normpath(prefix)
|
|
||||||
cmd = ['findstr', '/i', '/c:' + query, '/d:' + prefix]
|
|
||||||
books = subprocess.check_output(cmd).decode().strip().split('\n')
|
|
||||||
books = [b.split(':')[0] for b in books]
|
|
||||||
return get_ids(books, prefix)
|
|
||||||
|
|
||||||
def find_fulltext(query):
|
def find_fulltext(query):
|
||||||
ids = []
|
ids = []
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,15 @@ def cover(path):
|
||||||
try:
|
try:
|
||||||
from unrar import rarfile
|
from unrar import rarfile
|
||||||
rar = rarfile.RarFile(path)
|
rar = rarfile.RarFile(path)
|
||||||
files = rar.namelist()
|
for cover in ox.sorted_strings(rar.namelist()):
|
||||||
if files:
|
try:
|
||||||
cover = ox.sorted_strings(files)[0]
|
|
||||||
data = rar.read(cover)
|
data = rar.read(cover)
|
||||||
except:
|
except:
|
||||||
data = None
|
data = None
|
||||||
|
finally:
|
||||||
|
return data
|
||||||
|
except:
|
||||||
|
data = None
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def info(path):
|
def info(path):
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,15 @@ def cover(path):
|
||||||
return data
|
return data
|
||||||
files = [f.filename for f in z.filelist]
|
files = [f.filename for f in z.filelist]
|
||||||
if files:
|
if files:
|
||||||
cover = ox.sortedstrings(files)[0]
|
for cover in ox.sortedstrings(files):
|
||||||
try:
|
try:
|
||||||
data = z.read(cover)
|
data = z.read(cover)
|
||||||
except:
|
except:
|
||||||
data = None
|
data = None
|
||||||
|
finally:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def info(path):
|
def info(path):
|
||||||
data = {}
|
data = {}
|
||||||
data['title'] = os.path.splitext(os.path.basename(path))[0]
|
data['title'] = os.path.splitext(os.path.basename(path))[0]
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ def install():
|
||||||
shutil.copy(os.path.join(settings.updates_path, 'release.json'), os.path.join(settings.data_path, 'release.json'))
|
shutil.copy(os.path.join(settings.updates_path, 'release.json'), os.path.join(settings.data_path, 'release.json'))
|
||||||
upgrade_app()
|
upgrade_app()
|
||||||
# FIXME: still needed?
|
# FIXME: still needed?
|
||||||
if old_version < '20160112-651-de984a3' and platform != 'win32':
|
if old_version < '20160112-651-de984a3':
|
||||||
subprocess.call(['./ctl', 'postupdate', '-o', old_version, '-n', new_version])
|
subprocess.call(['./ctl', 'postupdate', '-o', old_version, '-n', new_version])
|
||||||
return True
|
return True
|
||||||
return True
|
return True
|
||||||
|
|
@ -253,7 +253,6 @@ def upgrade_app():
|
||||||
shutil.copytree(bundled_app, app)
|
shutil.copytree(bundled_app, app)
|
||||||
except:
|
except:
|
||||||
logger.debug('Failed to update Application', exc_info=True)
|
logger.debug('Failed to update Application', exc_info=True)
|
||||||
'''
|
|
||||||
elif sys.platform == 'win32':
|
elif sys.platform == 'win32':
|
||||||
current_version = get_trayicon_version()
|
current_version = get_trayicon_version()
|
||||||
if current_version != '0.2.0.0':
|
if current_version != '0.2.0.0':
|
||||||
|
|
@ -263,7 +262,6 @@ def upgrade_app():
|
||||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
startupinfo.wShowWindow = subprocess.SW_HIDE
|
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||||
subprocess.Popen(cmd, cwd=settings.base_dir, start_new_session=True, startupinfo=startupinfo)
|
subprocess.Popen(cmd, cwd=settings.base_dir, start_new_session=True, startupinfo=startupinfo)
|
||||||
'''
|
|
||||||
|
|
||||||
def getVersion(data):
|
def getVersion(data):
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
11
oml/utils.py
11
oml/utils.py
|
|
@ -369,17 +369,6 @@ def update_static():
|
||||||
)
|
)
|
||||||
|
|
||||||
def check_pid(pid):
|
def check_pid(pid):
|
||||||
if sys.platform == 'win32':
|
|
||||||
import ctypes
|
|
||||||
kernel32 = ctypes.windll.kernel32
|
|
||||||
SYNCHRONIZE = 0x100000
|
|
||||||
process = kernel32.OpenProcess(SYNCHRONIZE, 0, pid)
|
|
||||||
if process != 0:
|
|
||||||
kernel32.CloseHandle(process)
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
os.kill(pid, 0)
|
os.kill(pid, 0)
|
||||||
except:
|
except:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
requests==2.21.0
|
requests==2.21.0
|
||||||
|
tornado==5.1.1
|
||||||
chardet
|
chardet
|
||||||
html5lib
|
html5lib
|
||||||
#ox>=2.0.666
|
#ox>=2.0.666
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,3 @@ pyopenssl>=0.15
|
||||||
pyCrypto>=2.6.1
|
pyCrypto>=2.6.1
|
||||||
pillow
|
pillow
|
||||||
netifaces
|
netifaces
|
||||||
tornado==5.1.1
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue