Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MCViz
MCViz.web
Commits
e9e1beed
Commit
e9e1beed
authored
Dec 22, 2014
by
Tim Brooks
Browse files
Virtualenv bootstrapping
parent
20297fe9
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
e9e1beed
*.egg-info
dist
env
log
uploads
...
...
.gitmodules
0 → 100644
View file @
e9e1beed
[submodule "mcviz.standalone"]
path = mcviz.standalone
url = https://github.com/brookst/mcviz.git
bootstrap.py
0 → 100755
View file @
e9e1beed
This diff is collapsed.
Click to expand it.
mcviz.standalone
@
768e4314
Subproject commit 768e431403ca8a8dd7b6d3f3df8b86da38f7bc86
mcviz/utils/make_bootstrap.py
0 → 100755
View file @
e9e1beed
"""Make bootstrap script"""
import
virtualenv
,
textwrap
OUTPUT
=
virtualenv
.
create_bootstrap_script
(
textwrap
.
dedent
(
"""
import os, subprocess, textwrap
from os.path import join
def after_install(options, home_dir):
dirs = ['log', 'uploads', 'renders']
for folder in dirs:
if not os.path.exists(folder):
os.makedirs(folder)
ret = subprocess.call([join(home_dir, 'bin', 'pip'), 'install', '-e',
'mcviz.standalone'])
if ret:
print("Error installing mcviz")
return
ret = subprocess.call([join(home_dir, 'bin', 'pip'), 'install', '-e', '.'])
if ret:
print("Error installing mcviz.web")
return
print("")
print("Check the user running apache can access these folders")
print("e.g. > chown ${USER}:www-data log uploads renders")
print(" > chmod 775 .")
def adjust_options(options, args):
args[:] = ["env"]
"""
))
open
(
'bootstrap.py'
,
'w'
).
write
(
OUTPUT
)
mcviz/web/app.py
View file @
e9e1beed
...
...
@@ -8,11 +8,11 @@ from logging.handlers import RotatingFileHandler
from
flask
import
Flask
,
abort
,
request
,
send_from_directory
,
render_template
from
werkzeug
import
secure_filename
UPLOAD_FOLDER
=
os
.
path
.
dirname
(
'uploads/'
)
RENDER_FOLDER
=
os
.
path
.
dirname
(
'renders/'
)
UPLOAD_FOLDER
=
os
.
path
.
join
(
os
.
getcwd
(),
'uploads/'
)
RENDER_FOLDER
=
os
.
path
.
join
(
os
.
getcwd
(),
'renders/'
)
FILE_HANDLER
=
RotatingFileHandler
(
'log/flask.log'
)
APP
=
Flask
(
__name__
)
APP
=
Flask
(
__name__
,
template_folder
=
os
.
path
.
join
(
os
.
getcwd
(),
'templates/'
)
)
APP
.
logger
.
addHandler
(
FILE_HANDLER
)
APP
.
config
[
'UPLOAD_FOLDER'
]
=
UPLOAD_FOLDER
APP
.
config
[
'RENDER_FOLDER'
]
=
RENDER_FOLDER
...
...
@@ -98,16 +98,16 @@ def get_image(file_name):
workspace
.
run
()
APP
.
logger
.
info
(
"Rendering %s done"
,
name
)
return
send_from_directory
(
"renders/"
,
file_name
)
return
send_from_directory
(
APP
.
config
[
'RENDER_FOLDER'
]
,
file_name
)
if
__name__
==
"__main__"
:
from
logging
import
Formatter
TEMPLATE
=
"[%(asctime)s|%(levelname)-7s] %(message)s"
APP
.
debug
=
True
APP
.
logger
.
setLevel
(
logging
.
DEBUG
)
for
handler
in
APP
.
logger
.
handlers
:
handler
.
setLevel
(
logging
.
DEBUG
)
handler
.
setFormatter
(
Formatter
(
TEMPLATE
))
APP
.
run
(
host
=
'0'
)
from
logging
import
Formatter
TEMPLATE
=
"[%(asctime)s|%(levelname)-7s] %(message)s"
APP
.
logger
.
setLevel
(
logging
.
DEBUG
)
for
handler
in
APP
.
logger
.
handlers
:
handler
.
setLevel
(
logging
.
DEBUG
)
handler
.
setFormatter
(
Formatter
(
TEMPLATE
))
mcwebviz.wsgi
0 → 100644
View file @
e9e1beed
activate_this = 'env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
from mcviz.web.app import APP as application
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment