Commit afbe5dd3 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Migrate code to be a package

parent aa630b17
......@@ -2,8 +2,8 @@
**/.directory
*/*.pyc
.idea
srv/database.sqlite
dgenies/database.sqlite
application.properties
logs/*
!logs/README
srv/.local_scheduler_pid
dgenies/.local_scheduler_pid
include dgenies/templates/*.html
......@@ -55,7 +55,7 @@ minimap2_cluster = ###DEFAULT###
[database]
type = sqlite
url = ###PROGRAM###/srv/database.sqlite
url = ###USER###/.dgenies/database.sqlite
# Not used for sqlite:
port =
db =
......
src/dgenies/bin
\ No newline at end of file
../srv/config_reader.py
\ No newline at end of file
src/dgenies/lib
\ No newline at end of file
src/dgenies/logs
\ No newline at end of file
from setuptools import setup, find_packages
from pip.req import parse_requirements
install_reqs = parse_requirements('requirements.txt', session='hack')
# reqs is a list of requirement
# e.g. ['django==1.5.1', 'mezzanine==1.4.6']
reqs = [str(ir.req) for ir in install_reqs]
setup(
name='dgenies',
version='0.9',
packages=find_packages('src'),
package_dir={'dgenies': 'src/dgenies'},
include_package_data=True,
zip_safe=False,
install_requires=reqs,
data_files=[('/etc/dgenies', {'application.properties':'application.properties.example'})]
)
from setuptools import setup, find_packages
from pip.req import parse_requirements
install_reqs = parse_requirements('requirements.txt', session='hack')
# reqs is a list of requirement
# e.g. ['django==1.5.1', 'mezzanine==1.4.6']
reqs = [str(ir.req) for ir in install_reqs]
setup(
name='dgenies',
version='0.9',
packages=find_packages('src'),
package_dir={'dgenies': 'src/dgenies'},
include_package_data=True,
zip_safe=False,
install_requires=reqs,
package_data={"dgenies": ["bin/*.py", "static/*/*.css", "static/*/*.js", "templates/*.html"]},
data_files=[('/etc/dgenies', {'application.properties':'application.properties.example'})]
)
include dgenies/templates/*.html
#!/usr/bin/env python3
import os
from flask import Flask
from .config_reader import AppConfigReader
from .lib.mailer import Mailer
from .lib.crons import Crons
import sys
app_folder = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, app_folder)
os.environ["PATH"] = os.path.join(app_folder, "bin") + ":" + os.environ["PATH"]
sqlite_file = os.path.join(app_folder, "database.sqlite")
# Init config reader:
config_reader = AppConfigReader()
UPLOAD_FOLDER = config_reader.upload_folder
APP_DATA = config_reader.app_data
app_title = "D-GENIES - Dotplot for Genomes Interactive, E-connected and Speedy"
# Init Flask:
app = Flask(__name__, static_url_path='/static')
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['MAX_CONTENT_LENGTH'] = config_reader.max_upload_file_size
app.config['SECRET_KEY'] = 'dsqdsq-255sdA-fHfg52-25Asd5'
# Init mail:
mailer = Mailer(app)
if config_reader.debug and config_reader.log_dir != "stdout" and not os.path.exists(config_reader.log_dir):
os.makedirs(config_reader.log_dir)
# Crons:
if os.getenv('DISABLE_CRONS') != "True":
print("Starting crons...")
crons = Crons(app_folder)
crons.start_all()
from dgenies import views
if __name__ == '__main__':
app.run()
......@@ -8,7 +8,7 @@ from _datetime import datetime, timedelta
import traceback
import argparse
app_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "srv")
app_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "dgenies")
sys.path.insert(0, app_folder)
from config_reader import AppConfigReader
......
......@@ -3,7 +3,7 @@
import os
from lib.crons import Crons
app_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "srv")
app_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "dgenies")
crons = Crons(app_folder)
crons.clear()
......@@ -4,7 +4,7 @@ import os
import sys
from glob import glob
app_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "srv")
app_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "dgenies")
sys.path.insert(0, app_folder)
from config_reader import AppConfigReader
......
../config_reader.py
\ No newline at end of file
......@@ -83,4 +83,4 @@ if [ "$LOCAL" == "True" ]; then
host="127.0.0.1"
fi
DISABLE_CRONS=${DISABLE_CRONS} FLASK_DEBUG=${debug} FLASK_APP=${SCRIPTPATH}/../srv/main.py flask run --host=${host} --port=${PORT}
DISABLE_CRONS=${DISABLE_CRONS} FLASK_DEBUG=${debug} FLASK_APP=dgenies flask run --host=${host} --port=${PORT}
......@@ -12,7 +12,7 @@ import argparse
# Allow only one instance:
me = singleton.SingleInstance()
app_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "srv")
app_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "dgenies")
os.environ["PATH"] = os.path.join(app_folder, "bin") + ":" + os.environ["PATH"]
sys.path.insert(0, app_folder)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment