Compare commits

..

No commits in common. "74e89693ffa88ce054d598cc3fbcf7fbb088fdc8" and "3ec0930f5292424f13c39f2b3c4fc99275da93ae" have entirely different histories.

7 changed files with 27 additions and 50 deletions

View file

@ -7,30 +7,15 @@ from sqlalchemy.sql import operators
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):
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]
books = subprocess.check_output(cmd).decode().strip().split('\n')
books = [path[len(prefix):] for path in books]
return get_ids(books)
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)
ids = [b[0] for b in File.query.filter(operators.in_op(File.path, books)).values('sha1')]
return ids
def find_fulltext(query):
ids = []

View file

@ -10,10 +10,13 @@ def cover(path):
try:
from unrar import rarfile
rar = rarfile.RarFile(path)
files = rar.namelist()
if files:
cover = ox.sorted_strings(files)[0]
data = rar.read(cover)
for cover in ox.sorted_strings(rar.namelist()):
try:
data = rar.read(cover)
except:
data = None
finally:
return data
except:
data = None
return data

View file

@ -15,12 +15,14 @@ def cover(path):
return data
files = [f.filename for f in z.filelist]
if files:
cover = ox.sortedstrings(files)[0]
try:
data = z.read(cover)
except:
data = None
return data
for cover in ox.sortedstrings(files):
try:
data = z.read(cover)
except:
data = None
finally:
return data
def info(path):
data = {}

View file

@ -196,7 +196,7 @@ def install():
shutil.copy(os.path.join(settings.updates_path, 'release.json'), os.path.join(settings.data_path, 'release.json'))
upgrade_app()
# 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])
return True
return True
@ -253,7 +253,6 @@ def upgrade_app():
shutil.copytree(bundled_app, app)
except:
logger.debug('Failed to update Application', exc_info=True)
'''
elif sys.platform == 'win32':
current_version = get_trayicon_version()
if current_version != '0.2.0.0':
@ -263,7 +262,6 @@ def upgrade_app():
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
subprocess.Popen(cmd, cwd=settings.base_dir, start_new_session=True, startupinfo=startupinfo)
'''
def getVersion(data):
'''

View file

@ -369,23 +369,12 @@ def update_static():
)
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
try:
os.kill(pid, 0)
except:
return False
else:
try:
os.kill(pid, 0)
except:
return False
else:
return True
return True
def check_pidfile(pid):
try:

View file

@ -1,4 +1,5 @@
requests==2.21.0
tornado==5.1.1
chardet
html5lib
#ox>=2.0.666

View file

@ -6,4 +6,3 @@ pyopenssl>=0.15
pyCrypto>=2.6.1
pillow
netifaces
tornado==5.1.1