postupdate, pdf osx fixes
This commit is contained in:
parent
2c5fe9db09
commit
326a8f75c6
5 changed files with 70 additions and 37 deletions
8
ctl
8
ctl
|
@ -83,6 +83,8 @@ if [ "$1" == "ui" ]; then
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
if [ "$1" == "update" ]; then
|
if [ "$1" == "update" ]; then
|
||||||
|
cd $BASE/$NAME
|
||||||
|
OLD=`$0 version`
|
||||||
cd $BASE/platform
|
cd $BASE/platform
|
||||||
echo Update platform..
|
echo Update platform..
|
||||||
git pull
|
git pull
|
||||||
|
@ -90,8 +92,10 @@ if [ "$1" == "update" ]; then
|
||||||
cd $BASE/$NAME
|
cd $BASE/$NAME
|
||||||
git pull
|
git pull
|
||||||
find . -name '*.pyc' -exec rm "{}" \;
|
find . -name '*.pyc' -exec rm "{}" \;
|
||||||
python2 oml setup
|
$0 setup
|
||||||
python2 oml update_static > /dev/null
|
$0 update_static > /dev/null
|
||||||
|
NEW=`$0 version`
|
||||||
|
$0 postupdate -o $OLD -n $NEW
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [ "$1" == "python" ]; then
|
if [ "$1" == "python" ]; then
|
||||||
|
|
|
@ -45,6 +45,8 @@ manager.add_command('update', commands.Update)
|
||||||
#manager.add_command('start', commands.Start)
|
#manager.add_command('start', commands.Start)
|
||||||
#manager.add_command('stop', commands.Stop)
|
#manager.add_command('stop', commands.Stop)
|
||||||
manager.add_command('setup', commands.Setup)
|
manager.add_command('setup', commands.Setup)
|
||||||
|
manager.add_command('version', commands.Version)
|
||||||
|
manager.add_command('postupdate', commands.PostUpdate)
|
||||||
manager.add_command('shell', Shell)
|
manager.add_command('shell', Shell)
|
||||||
manager.add_command('update_static', commands.UpdateStatic)
|
manager.add_command('update_static', commands.UpdateStatic)
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,48 @@
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from os.path import join, exists, dirname
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from flask.ext.script import Command
|
from flask.ext.script import Command, Option
|
||||||
|
|
||||||
|
import settings
|
||||||
|
|
||||||
|
root_dir = dirname(settings.base_dir)
|
||||||
|
|
||||||
|
def run(*cmd):
|
||||||
|
p = subprocess.Popen(cmd)
|
||||||
|
p.wait()
|
||||||
|
return p.returncode
|
||||||
|
|
||||||
|
def get(*cmd):
|
||||||
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
stdout, error = p.communicate()
|
||||||
|
return stdout
|
||||||
|
|
||||||
def r(*cmd):
|
def r(*cmd):
|
||||||
print ' '.join(cmd)
|
print ' '.join(cmd)
|
||||||
return subprocess.call(cmd)
|
return subprocess.call(cmd)
|
||||||
|
|
||||||
|
def version(module):
|
||||||
|
os.chdir(join(root_dir, module))
|
||||||
|
version = get('git', 'log', '-1', '--format=%cd', '--date=iso').split(' ')[0].replace('-', '')
|
||||||
|
version += '-' + get('git', 'rev-list', 'HEAD', '--count').strip()
|
||||||
|
version += '-' + get('git', 'describe', '--always').strip()
|
||||||
|
os.chdir(root_dir)
|
||||||
|
return version
|
||||||
|
|
||||||
|
|
||||||
|
class Version(Command):
|
||||||
|
"""
|
||||||
|
Print current version
|
||||||
|
"""
|
||||||
|
def run(self):
|
||||||
|
print version('openmedialibrary')
|
||||||
|
|
||||||
class Debug(Command):
|
class Debug(Command):
|
||||||
"""
|
"""
|
||||||
Start Open Media Library in debug mode
|
Start in debug mode
|
||||||
"""
|
"""
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
pass
|
||||||
|
@ -39,25 +70,35 @@ class Update(Command):
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class PostUpdate(Command):
|
||||||
|
"""
|
||||||
|
Called by update to fix stuff
|
||||||
|
"""
|
||||||
|
def get_options(self):
|
||||||
|
return [
|
||||||
|
Option('-o', '--old', dest='old'),
|
||||||
|
Option('-n', '--new', dest='new'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def run(selfi, old, new):
|
||||||
|
pass
|
||||||
|
|
||||||
class Setup(Command):
|
class Setup(Command):
|
||||||
"""
|
"""
|
||||||
setup new node
|
Setup new node
|
||||||
"""
|
"""
|
||||||
def run(self):
|
def run(self):
|
||||||
r('./ctl', 'db', 'upgrade')
|
r('./ctl', 'db', 'upgrade')
|
||||||
import setup
|
import setup
|
||||||
import settings
|
|
||||||
setup.create_default_lists()
|
setup.create_default_lists()
|
||||||
settings.db.session.connection().execute("PRAGMA journal_mode=WAL")
|
settings.db.session.connection().execute("PRAGMA journal_mode=WAL")
|
||||||
settings.db.session.commit()
|
settings.db.session.commit()
|
||||||
|
|
||||||
class UpdateStatic(Command):
|
class UpdateStatic(Command):
|
||||||
"""
|
"""
|
||||||
update static files
|
Update static files
|
||||||
"""
|
"""
|
||||||
def run(self):
|
def run(self):
|
||||||
import settings
|
|
||||||
|
|
||||||
oxjs = os.path.join(settings.static_path, 'oxjs')
|
oxjs = os.path.join(settings.static_path, 'oxjs')
|
||||||
if not os.path.exists(oxjs):
|
if not os.path.exists(oxjs):
|
||||||
r('git', 'clone', 'https://git.0x2620.org/oxjs.git', oxjs)
|
r('git', 'clone', 'https://git.0x2620.org/oxjs.git', oxjs)
|
||||||
|
@ -68,39 +109,17 @@ class UpdateStatic(Command):
|
||||||
|
|
||||||
class Release(Command):
|
class Release(Command):
|
||||||
"""
|
"""
|
||||||
release new version
|
Release new version
|
||||||
"""
|
"""
|
||||||
def run(self):
|
def run(self):
|
||||||
print 'checking...'
|
print 'checking...'
|
||||||
import settings
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import ed25519
|
import ed25519
|
||||||
from os.path import join, exists, dirname
|
|
||||||
|
|
||||||
root_dir = dirname(settings.base_dir)
|
|
||||||
os.chdir(root_dir)
|
os.chdir(root_dir)
|
||||||
|
|
||||||
def run(*cmd):
|
|
||||||
p = subprocess.Popen(cmd)
|
|
||||||
p.wait()
|
|
||||||
return p.returncode
|
|
||||||
|
|
||||||
def get(*cmd):
|
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
stdout, error = p.communicate()
|
|
||||||
return stdout
|
|
||||||
|
|
||||||
def version(module):
|
|
||||||
os.chdir(join(root_dir, module))
|
|
||||||
version = get('git', 'log', '-1', '--format=%cd', '--date=iso').split(' ')[0].replace('-', '')
|
|
||||||
version += '-' + get('git', 'rev-list', 'HEAD', '--count').strip()
|
|
||||||
version += '-' + get('git', 'describe', '--always').strip()
|
|
||||||
os.chdir(root_dir)
|
|
||||||
return version
|
|
||||||
|
|
||||||
with open(os.path.expanduser('~/Private/openmedialibrary_release.key')) as fd:
|
with open(os.path.expanduser('~/Private/openmedialibrary_release.key')) as fd:
|
||||||
SIG_KEY=ed25519.SigningKey(fd.read())
|
SIG_KEY=ed25519.SigningKey(fd.read())
|
||||||
SIG_ENCODING='base64'
|
SIG_ENCODING='base64'
|
||||||
|
|
|
@ -37,13 +37,17 @@ def ql_cover(pdf):
|
||||||
]
|
]
|
||||||
p = subprocess.Popen(cmd)
|
p = subprocess.Popen(cmd)
|
||||||
p.wait()
|
p.wait()
|
||||||
image = glob('%s/*' % tmp)[0]
|
image = glob('%s/*' % tmp)
|
||||||
|
if image:
|
||||||
|
image = image[0]
|
||||||
with open(image, 'rb') as fd:
|
with open(image, 'rb') as fd:
|
||||||
data = fd.read()
|
data = fd.read()
|
||||||
|
else:
|
||||||
|
logger.debug('qlmanage did not create cover for %s', pdf)
|
||||||
|
data = None
|
||||||
shutil.rmtree(tmp)
|
shutil.rmtree(tmp)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def page(pdf, page):
|
def page(pdf, page):
|
||||||
image = tempfile.mkstemp('.jpg')[1]
|
image = tempfile.mkstemp('.jpg')[1]
|
||||||
cmd = [
|
cmd = [
|
||||||
|
@ -133,7 +137,10 @@ def extract_text(pdf):
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
|
if 'kMDItemTextContent' in stderr:
|
||||||
stdout = stderr.split('kMDItemTextContent = "')[-1].split('\n')[0][:-2]
|
stdout = stderr.split('kMDItemTextContent = "')[-1].split('\n')[0][:-2]
|
||||||
|
else:
|
||||||
|
stdout = ''
|
||||||
return stdout.strip()
|
return stdout.strip()
|
||||||
|
|
||||||
def extract_isbn(text):
|
def extract_isbn(text):
|
||||||
|
|
|
@ -232,6 +232,7 @@ def sortLists(data):
|
||||||
n += 1
|
n += 1
|
||||||
models.db.session.add(l)
|
models.db.session.add(l)
|
||||||
models.db.session.commit()
|
models.db.session.commit()
|
||||||
|
logger.debug('FIXME: broadcast orderlist event here')
|
||||||
return {}
|
return {}
|
||||||
actions.register(sortLists, cache=False)
|
actions.register(sortLists, cache=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue