|
@@ -7,10 +7,10 @@ import os
|
|
|
import hashlib
|
|
|
import hmac
|
|
|
import subprocess
|
|
|
-import shutil
|
|
|
|
|
|
from flask import jsonify, abort, request, send_from_directory
|
|
|
from app import app
|
|
|
+from app.util import job
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
@@ -46,39 +46,8 @@ def tutorial_dist_png():
|
|
|
|
|
|
@app.route('/typeset', methods=['GET', 'POST'])
|
|
|
def typeset():
|
|
|
- """Show index page"""
|
|
|
- working_dir = os.getcwd()
|
|
|
- if os.path.basename(working_dir) == 'rr':
|
|
|
- os.chdir('rr_tutorial')
|
|
|
-
|
|
|
- book_toc_size = os.path.getsize('master_book.toc') \
|
|
|
- if os.path.isfile('master_book.toc') else 0
|
|
|
- article_toc_size = os.path.getsize('master_article.toc') \
|
|
|
- if os.path.isfile('master_article.toc') else 0
|
|
|
- dist_toc_size = os.path.getsize('master_dist.toc') \
|
|
|
- if os.path.isfile('master_dist.toc') else 0
|
|
|
-
|
|
|
- subprocess.check_output(['xelatex', '-halt-on-error', 'master_book.tex'])
|
|
|
- subprocess.check_output(['xelatex', '-halt-on-error', 'master_article.tex'])
|
|
|
- subprocess.check_output(['./set.sh'])
|
|
|
-
|
|
|
- if book_toc_size != os.path.getsize('master_book.toc'):
|
|
|
- subprocess.check_output(['xelatex', '-halt-on-error', 'master_book.tex'])
|
|
|
-
|
|
|
- if article_toc_size != os.path.getsize('master_article.toc'):
|
|
|
- subprocess.check_output(['xelatex', '-halt-on-error', 'master_article.tex'])
|
|
|
-
|
|
|
- if dist_toc_size != os.path.getsize('master_dist.toc'):
|
|
|
- subprocess.check_output(['./set.sh'])
|
|
|
-
|
|
|
- shutil.copyfile('master_book.pdf', '../app/static/tutorial/book.pdf')
|
|
|
- shutil.copyfile('master_article.pdf', '../app/static/tutorial/article.pdf')
|
|
|
- shutil.copyfile('master_dist.pdf', '../app/static/tutorial/dist.pdf')
|
|
|
-
|
|
|
- subprocess.check_output(['./convert.sh'])
|
|
|
- shutil.copyfile('master_dist.png', '../app/static/tutorial/dist.png')
|
|
|
-
|
|
|
- os.chdir(working_dir)
|
|
|
+ """Add job to schedeuler"""
|
|
|
+ job.add()
|
|
|
return jsonify(True)
|
|
|
|
|
|
|
|
@@ -91,7 +60,7 @@ def deploy():
|
|
|
if len(signature) < 2 or not hmac.compare_digest(signature, digest):
|
|
|
abort(400, 'Invalid signature')
|
|
|
|
|
|
- subprocess.call(['pipenv', 'sync'])
|
|
|
subprocess.call(['git', 'pull'])
|
|
|
+ subprocess.call(['pipenv', 'sync'])
|
|
|
subprocess.call(['touch', 'flask.wsgi'])
|
|
|
return jsonify(True)
|