fix some cli bugs, update manifest, Fix #29
This commit is contained in:
parent
3be7ad1ab6
commit
2e38c6a34c
|
@ -1,6 +1,6 @@
|
|||
include requirements.txt VERSION LICENSE
|
||||
recursive-include realms/static/css *
|
||||
include requirements.txt VERSION LICENSE README.md
|
||||
recursive-include realms/static/fonts *
|
||||
recursive-include realms/static/css *
|
||||
recursive-include realms/static/js *
|
||||
recursive-include realms/static/vendor *
|
||||
recursive-include realms/templates *
|
|
@ -20,6 +20,7 @@ from werkzeug.exceptions import HTTPException
|
|||
|
||||
from realms.lib.util import to_canonical, remove_ext, mkdir_safe, gravatar_url, to_dict
|
||||
from realms.lib.hook import HookModelMeta
|
||||
from realms.lib.util import is_su, in_virtualenv
|
||||
|
||||
|
||||
class Application(Flask):
|
||||
|
@ -179,8 +180,15 @@ if app.config['RELATIVE_PATH']:
|
|||
|
||||
|
||||
@click.group()
|
||||
def cli():
|
||||
pass
|
||||
@click.pass_context
|
||||
def cli(ctx):
|
||||
# This could probably done better
|
||||
if ctx.invoked_subcommand in ['setup', 'setup_upstart', 'pip']:
|
||||
if not in_virtualenv() and not is_su():
|
||||
# This does not account for people the have user level python installs
|
||||
# that aren't virtual environments! Should be rare I think
|
||||
click.secho("This command requires root privileges, use sudo or run as root.", fg='red')
|
||||
sys.exit()
|
||||
|
||||
# Init plugins here if possible
|
||||
login_manager = LoginManager(app)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from realms import config, app, cli, db
|
||||
from realms.lib.util import random_string
|
||||
from realms import config, app, db, cli
|
||||
from realms.lib.util import random_string, in_virtualenv
|
||||
from subprocess import call, Popen
|
||||
from multiprocessing import cpu_count
|
||||
import click
|
||||
|
@ -8,15 +8,6 @@ import sys
|
|||
import os
|
||||
|
||||
|
||||
def check_su(f):
|
||||
if not in_virtualenv() and not is_su():
|
||||
# This does not account for people the have user level python installs
|
||||
# that aren't virtual environments! Should be rare I think
|
||||
red("This command requires root privileges, use sudo or run as root.")
|
||||
sys.exit()
|
||||
return f
|
||||
|
||||
|
||||
def get_user():
|
||||
for name in ('SUDO_USER', 'LOGNAME', 'USER', 'LNAME', 'USERNAME'):
|
||||
user = os.environ.get(name)
|
||||
|
@ -24,14 +15,6 @@ def get_user():
|
|||
return user
|
||||
|
||||
|
||||
def in_virtualenv():
|
||||
return hasattr(sys, 'real_prefix')
|
||||
|
||||
|
||||
def is_su():
|
||||
return os.geteuid() == 0
|
||||
|
||||
|
||||
def get_pid():
|
||||
try:
|
||||
with file(config.PIDFILE) as f:
|
||||
|
@ -63,7 +46,6 @@ def red(s):
|
|||
|
||||
|
||||
@cli.command()
|
||||
@check_su
|
||||
@click.option('--site-title',
|
||||
default=config.SITE_TITLE,
|
||||
prompt='Enter site title.')
|
||||
|
@ -154,7 +136,6 @@ def get_pip():
|
|||
|
||||
|
||||
@cli.command()
|
||||
@check_su
|
||||
@click.argument('cmd', nargs=-1)
|
||||
def pip(cmd):
|
||||
""" Execute pip commands, useful for virtualenvs
|
||||
|
@ -193,7 +174,6 @@ def setup_memcached(**kw):
|
|||
|
||||
|
||||
@cli.command()
|
||||
@check_su
|
||||
@click.option('--user',
|
||||
default=get_user(),
|
||||
type=click.STRING,
|
||||
|
|
|
@ -4,6 +4,7 @@ import hashlib
|
|||
import json
|
||||
import string
|
||||
import random
|
||||
import sys
|
||||
from jinja2 import Template
|
||||
|
||||
|
||||
|
@ -99,6 +100,15 @@ def to_canonical(s):
|
|||
def gravatar_url(email):
|
||||
return "//www.gravatar.com/avatar/" + hashlib.md5(email).hexdigest()
|
||||
|
||||
|
||||
def in_virtualenv():
|
||||
return hasattr(sys, 'real_prefix')
|
||||
|
||||
|
||||
def is_su():
|
||||
return os.geteuid() == 0
|
||||
|
||||
|
||||
def upstart_script(user='root', app_dir=None, port=5000, workers=2, path=None):
|
||||
script = """
|
||||
limit nofile 65335 65335
|
||||
|
|
Loading…
Reference in a new issue