Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
version 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mon-ius committed Dec 17, 2018
1 parent 3f0ad1b commit cc40ce6
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 78 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# flask-deploy
A simple scripts for deploying flask apps with Nginx, PostgreSQL , HTTPS and Systemd Daemon.

## Install

```
pip install flask-deploy
```


## Usage

change directory to your flask project

`flask-deploy` **or** `fd`

## Assumptions

- You're user : `www`
Expand Down
15 changes: 1 addition & 14 deletions flaskdeploy/__main__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import click
from flaskdeploy.scripts import deploy,gen


@click.group()
def cli():
"""A quick deploy script for productive flask app."""
pass


cli.add_command(deploy.cli, 'deploy', short_help='deploy the app')
cli.add_command(gen.cli, 'gen', short_help='gen the config')


from flaskdeploy.scripts.core import cli

# Enable ``python -m flask-deploy ...``.
if __name__ == '__main__': # pragma: no cover
Expand Down
13 changes: 13 additions & 0 deletions flaskdeploy/scripts/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from .deploy import cli as deploy
from .generation import cli as generation

import click

@click.group()
def cli():
"""A quick deploy script for productive flask app."""
pass


cli.add_command(deploy, 'deploy')
cli.add_command(generation, 'gen')
40 changes: 17 additions & 23 deletions flaskdeploy/scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

import click


@click.command()
@click.command(context_settings=dict(
allow_extra_args=True
))
@click.option('--email', prompt='Your email', help='Email,Apply ssl certification,CloudFlare.',
callback=validate_email)
@click.option('--key', prompt='Your secret key', help='Secret Key,Apply ssl certification,CloudFlare.')
def miss_tmp(email, key):
@click.pass_context
def miss_tmp(ctx,email, key):
ssl_file_gen(DOMAIN, USR, CUR_LOC, email, key)
return
raise JumpOutFuckingClick


@click.command()
Expand All @@ -26,8 +28,9 @@ def miss_tmp(email, key):
callback=validate_email
)
@click.option('--key', help='Key,Apply ssl certification,CloudFlare.')
@click.option('--docker', help='Confirm having database or not.')
@click.pass_context
def cli(ctx, domain, email, key):
def cli(ctx, domain, email, key,docker):
"""Deploy the flask app right now."""
global DOMAIN, USR, CUR_LOC
usr = getpass.getuser()
Expand All @@ -48,26 +51,17 @@ def cli(ctx, domain, email, key):
uwsgi_file_gen(DOMAIN, USR, CUR_LOC)
nginx_file_gen(DOMAIN, USR, CUR_LOC)
service_file_gen(DOMAIN, USR, CUR_LOC)

if not click.confirm('Do you have database already?'):
docker_file_gen(DOMAIN, USR, CUR_LOC)

if not docker:
if not click.confirm('Do you have database already?'):
docker_file_gen(DOMAIN, USR, CUR_LOC)
if not email or not key:
if not click.confirm('Do you have SSL certification?'):
miss_tmp()
try:
miss_tmp()
except JumpOutFuckingClick:
pass
else:
ssl_file_gen(DOMAIN, USR, CUR_LOC, email, key)

# click.echo(DOMAIN)
# click.echo(USR)
# click.echo(CUR_LOC)
# click.echo(DOMAIN,USR,CUR_LOC)
# if not click.confirm('Do you have database already?'):
# world()

# print("domain : ",domain)
# print("email : ",)
# print("key : ",)

if __name__ == '__main__':

cx()
script_files_gen(DOMAIN, USR, CUR_LOC)
43 changes: 17 additions & 26 deletions flaskdeploy/scripts/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@

import click


@click.command()
@click.command(context_settings=dict(
allow_extra_args=True
))
@click.option('--email', prompt='Your email', help='Email,Apply ssl certification,CloudFlare.',
callback=validate_email)
@click.option('--key', prompt='Your secret key', help='Secret Key,Apply ssl certification,CloudFlare.')
def miss_tmp(email, key):
@click.pass_context
def miss_tmp(ctx,email, key):
ssl_file_gen(DOMAIN, USR, CUR_LOC, email, key)
return

raise JumpOutFuckingClick

@click.command()
@click.option('--domain', prompt='Your domain', help='The domain to be configured.',
Expand All @@ -26,8 +27,10 @@ def miss_tmp(email, key):
callback=validate_email
)
@click.option('--key', help='Key,Apply ssl certification,CloudFlare.')
@click.option('--docker', help='Confirm having database or not.')
@click.pass_context
def cli(ctx, domain, email, key):
def cli(ctx, domain, email, key,docker):
"""Necessary config.(Just generating)"""
global DOMAIN, USR, CUR_LOC
usr = getpass.getuser()
loc = os.path.join(os.getcwd(), domain)
Expand All @@ -48,26 +51,14 @@ def cli(ctx, domain, email, key):
nginx_file_gen(DOMAIN, USR, CUR_LOC)
service_file_gen(DOMAIN, USR, CUR_LOC)

if not click.confirm('Do you have database already?'):
docker_file_gen(DOMAIN, USR, CUR_LOC)
if not docker:
if not click.confirm('Do you have database already?'):
docker_file_gen(DOMAIN, USR, CUR_LOC)
if not email or not key:
if not click.confirm('Do you have SSL certification?'):
miss_tmp()
try:
miss_tmp()
except JumpOutFuckingClick:
pass
else:
ssl_file_gen(DOMAIN, USR, CUR_LOC, email, key)

# click.echo(DOMAIN)
# click.echo(USR)
# click.echo(CUR_LOC)
# click.echo(DOMAIN,USR,CUR_LOC)
# if not click.confirm('Do you have database already?'):
# world()

# print("domain : ",domain)
# print("email : ",)
# print("key : ",)


# if __name__ == '__main__':

# hello()
ssl_file_gen(DOMAIN, USR, CUR_LOC, email, key)
66 changes: 57 additions & 9 deletions flaskdeploy/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@
def cx():
"""A quick deploy script for productive flask app."""

@cx.command()

@click.command(context_settings=dict(
allow_extra_args=True
))
@click.option('--email', prompt='Your email', help='Email,Apply ssl certification,CloudFlare.',
callback=validate_email)
@click.option('--key', prompt='Your secret key', help='Secret Key,Apply ssl certification,CloudFlare.')
def miss_tmp(email, key):
@click.pass_context
def miss_tmp(ctx,email, key):
ssl_file_gen(DOMAIN, USR, CUR_LOC, email, key)
raise JumpOutFuckingClick


@cx.command('deploy', short_help='deploy the app')

@click.command()
@click.option('--domain', prompt='Your domain', help='The domain to be configured.',
callback=validate_domain
)
Expand Down Expand Up @@ -49,19 +56,23 @@ def deploy(ctx, domain, email, key,docker):
uwsgi_file_gen(DOMAIN, USR, CUR_LOC)
nginx_file_gen(DOMAIN, USR, CUR_LOC)
service_file_gen(DOMAIN, USR, CUR_LOC)

if not docker:
if not click.confirm('Do you have database already?'):
docker_file_gen(DOMAIN, USR, CUR_LOC)
if not email or not key:
if not click.confirm('Do you have SSL certification?'):
miss_tmp()
try:
miss_tmp()
except JumpOutFuckingClick:
click.echo("2333")
else:
ssl_file_gen(DOMAIN, USR, CUR_LOC, email, key)

script_files_gen(DOMAIN, USR, CUR_LOC)

@cx.command('gen', short_help='gen the config')

@click.command()
@click.option('--domain', prompt='Your domain', help='The domain to be configured.',
callback=validate_domain
)
Expand All @@ -72,7 +83,7 @@ def deploy(ctx, domain, email, key,docker):
@click.option('--docker', help='Confirm having database or not.')
@click.pass_context
def gen(ctx, domain, email, key,docker):
"""Generates the necessary config.(Just generating)"""
"""Necessary config.(Just generating)"""
global DOMAIN, USR, CUR_LOC
usr = getpass.getuser()
loc = os.path.join(os.getcwd(), domain)
Expand All @@ -98,17 +109,54 @@ def gen(ctx, domain, email, key,docker):
docker_file_gen(DOMAIN, USR, CUR_LOC)
if not email or not key:
if not click.confirm('Do you have SSL certification?'):
miss_tmp()
try:
miss_tmp()
except JumpOutFuckingClick:
click.echo("2333")
else:
ssl_file_gen(DOMAIN, USR, CUR_LOC, email, key)



# @cx.command('gen', short_help='gen the config')
# def gen():
# """Generates the necessary config.(Just generating)"""
# """Generates the necessary config.(Just generating)"""

# @cx.command('deploy', short_help='deploy the app')
# def deploy():
# """Deploy the flask app right now."""




cli = click.Group()


@click.command(short_help='test',context_settings=dict(
allow_extra_args=True
))
@click.option('--count', prompt='count')
def test(count):
click.echo('Count: {}'.format(count))
raise JumpOutFuckingClick


@click.command(short_help='dist')
@click.option('--count')
@click.pass_context
def dist(ctx, count):
if not count:
try:
test()
except JumpOutFuckingClick:
click.echo("2333")

# cli.add_command(dist, 'dist')
# cli.add_command(test, 'test')

cx.add_command(gen, 'gen')
cx.add_command(deploy, 'deploy')

if __name__ == '__main__':
# cli()
cx()
5 changes: 4 additions & 1 deletion flaskdeploy/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import re
import click
import os
from config import *
from .config import *

class JumpOutFuckingClick(Exception):
"""Just to break out the unkown loop"""
pass

def ssl_file_gen(domain,usr,loc,email,key):
with open(SSL, "r") as fh:
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

import setuptools

with open('README.md', 'r', 'utf-8') as f:
with open('README.md', 'r') as f:
readme = f.read()

setuptools.setup(
name='flask-deploy',
version='0.1',
version='0.2.1',
description='A quick deploy script for productive flask app',
url='https://github.com/Mon-ius/flask-deploy',
author='Mon-ius',
Expand All @@ -21,9 +21,8 @@
long_description_content_type='text/markdown',
entry_points={
'console_scripts': [
'flask-deploy = flaskdeploy.scripts.deploy:info',
'fd gen = flaskdeploy.scripts.generation:cli',
'fd deploy = flaskdeploy.scripts.deploy:cli',
'flask-deploy =flaskdeploy.scripts.core:cli',
'fd = flaskdeploy.scripts.core:cli',
],
},
zip_safe=False,
Expand Down

0 comments on commit cc40ce6

Please sign in to comment.