kopia lustrzana https://github.com/piku/piku
REPL
rodzic
50d16c3bdc
commit
3307bf281c
|
@ -23,6 +23,7 @@ From the bottom up:
|
|||
- [ ] nginx SSL optimization/cypher suites, own certificates
|
||||
- [ ] Let's Encrypt support
|
||||
- [ ] Review docs/CLI command documentation
|
||||
- [x] (experimental) REPL
|
||||
- [x] Python 3 support through `PYTHON_VERSION = 3`
|
||||
- [x] static URL mapping to arbitrary paths (hat tip to @carlosefr for `nginx` tuning)
|
||||
- [x] remote CLI (requires `ssh -t`)
|
||||
|
|
|
@ -38,7 +38,7 @@ Before running `piku` for the first time, you need to install the following Pyth
|
|||
|
||||
```bash
|
||||
sudo apt-get install git python-virtualenv python-pip
|
||||
sudo pip install -U click
|
||||
sudo pip install -U click click-repl
|
||||
```
|
||||
|
||||
### Raspbian Wheezy
|
||||
|
@ -46,7 +46,7 @@ sudo pip install -U click
|
|||
```bash
|
||||
sudo apt-get install git python2.7
|
||||
sudo easy_install -U pip
|
||||
sudo pip install -U click virtualenv
|
||||
sudo pip install -U click click-repl virtualenv
|
||||
```
|
||||
|
||||
These may or may not be installed already (`click` usually isn't). For Raspbian Wheezy this is the preferred approach, since current `apt` packages are fairly outdated.
|
|
@ -49,7 +49,7 @@ As of April 2016, the shipping versions with Raspbian are recent enough to run `
|
|||
```bash
|
||||
# as 'pi' user
|
||||
sudo apt install -y python-virtualenv python-pip git uwsgi uwsgi-plugin-python incron nginx
|
||||
sudo pip install -U click
|
||||
sudo pip install -U click click-repl
|
||||
sudo reboot
|
||||
```
|
||||
|
|
@ -7,7 +7,7 @@ sudo apt-get update
|
|||
sudo apt-get -y dist-upgrade
|
||||
sudo apt-get -y autoremove
|
||||
sudo apt-get install -y tmux vim htop fail2ban uwsgi uwsgi-plugin-python uwsgi-plugin-python3 uwsgi-plugin-asyncio-python3 uwsgi-plugin-gevent-python uwsgi-plugin-tornado-python nginx incron libxml2-dev libxslt1-dev python-dev zlib1g-dev build-essential git python-virtualenv python-pip
|
||||
sudo pip install -U click pip
|
||||
sudo pip install -U click click-repl pip
|
||||
sudo adduser --disabled-password --gecos 'PaaS access' --ingroup www-data piku
|
||||
|
||||
# move to /tmp and grab our distribution files
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
"Piku Micro-PaaS"
|
||||
|
||||
from click import argument, command, group, option, secho as echo
|
||||
from click import argument, command, group, get_current_context, option, secho as echo
|
||||
from click_repl import repl
|
||||
from collections import defaultdict, deque
|
||||
from datetime import datetime
|
||||
from fcntl import fcntl, F_SETFL, F_GETFL
|
||||
|
@ -12,6 +13,7 @@ from json import loads
|
|||
from multiprocessing import cpu_count
|
||||
from os import chmod, unlink, remove, stat, listdir, environ, makedirs, O_NONBLOCK
|
||||
from os.path import abspath, basename, dirname, exists, getmtime, join, realpath, splitext
|
||||
from prompt_toolkit.history import FileHistory
|
||||
from re import sub
|
||||
from shutil import copyfile, rmtree
|
||||
from socket import socket, AF_INET, SOCK_STREAM
|
||||
|
@ -953,15 +955,15 @@ def git_hook(app):
|
|||
@argument('app')
|
||||
def receive(app):
|
||||
"""INTERNAL: Handle git pushes for an app"""
|
||||
|
||||
|
||||
app = sanitize_app_name(app)
|
||||
hook_path = join(GIT_ROOT, app, 'hooks', 'post-receive')
|
||||
|
||||
|
||||
if not exists(hook_path):
|
||||
makedirs(dirname(hook_path))
|
||||
# Initialize the repository with a hook to this script
|
||||
call("git init --quiet --bare " + app, cwd=GIT_ROOT, shell=True)
|
||||
with open(hook_path,'w') as h:
|
||||
with open(hook_path, 'w') as h:
|
||||
h.write("""#!/usr/bin/env bash
|
||||
set -e; set -o pipefail;
|
||||
cat | PIKU_ROOT="%s" %s git-hook %s""" % (PIKU_ROOT, realpath(__file__), app))
|
||||
|
@ -969,7 +971,14 @@ cat | PIKU_ROOT="%s" %s git-hook %s""" % (PIKU_ROOT, realpath(__file__), app))
|
|||
chmod(hook_path, stat(hook_path).st_mode | S_IXUSR)
|
||||
# Handle the actual receive. We'll be called with 'git-hook' after it happens
|
||||
call('git-shell -c "%s" ' % (argv[1] + " '%s'" % app), cwd=GIT_ROOT, shell=True)
|
||||
|
||||
|
||||
|
||||
|
||||
@piku.command()
|
||||
def prompt():
|
||||
"""Starts an interactive prompt"""
|
||||
repl(get_current_context(),
|
||||
prompt_kwargs={'history': FileHistory(join(dirname(realpath(__file__)), '.piku_history'))},
|
||||
allow_system_commands=False)
|
||||
|
||||
if __name__ == '__main__':
|
||||
piku()
|
||||
piku()
|
||||
|
|
Ładowanie…
Reference in New Issue