--- a/.hgignore Tue Jan 06 17:43:23 2015 +0100
+++ b/.hgignore Tue Jan 06 17:48:50 2015 +0100
@@ -5,4 +5,7 @@
src/catedit/config.py
src/catedit/log/
run/log/
-run/files/
\ No newline at end of file
+run/files/
+dist/
+src/catedit.egg-info
+catedit.egg-info
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgtags Tue Jan 06 17:48:50 2015 +0100
@@ -0,0 +1,3 @@
+b196557df50929f1855e8fbc5f789be63fe3de89 V00.01.00
+b196557df50929f1855e8fbc5f789be63fe3de89 V00.01.00
+5d5a52230e286e9f5c32fb176133cb109294c9f9 V00.01.00
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MANIFEST.in Tue Jan 06 17:48:50 2015 +0100
@@ -0,0 +1,2 @@
+recursive-include src/catedit/static *
+recursive-include src/catedit/templates *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/sync/fabfile.py Tue Jan 06 17:48:50 2015 +0100
@@ -0,0 +1,72 @@
+from fabric.api import env, local, put, run, cd, lcd, task, prefix
+from fabric.contrib.files import exists
+from fabric.colors import green
+import tempfile
+import shutil
+import os
+import settings
+
+
+def __init():
+ if not env.get('temp_folder', None):
+ env['temp_folder'] = tempfile.mkdtemp()
+ print(green("working folder is %s" % env['temp_folder']))
+
+def __clean():
+ if env.get('temp_folder', None):
+ print(green("Removing %s" % env['temp_folder']))
+ shutil.rmtree(env['temp_folder'])
+
+def get_version_path():
+ return os.path.join(env['temp_folder'], env['version'])
+
+def export():
+ local('hg archive -r %s %s' % (env['version'], get_version_path()) )
+
+def pack():
+ # create a new source distribution as tarball
+ with lcd(get_version_path()):
+ local('python setup.py sdist --formats=gztar', capture=False)
+
+def create_virtualenv():
+ with lcd(get_version_path()):
+ tmpd = run('mktemp -d').strip()
+ put('virtualenv/*.txt', tmpd)
+ run('virtualenv -p /usr/bin/python3 %s' % env.srv_venv_path)
+ with prefix('source %s/bin/activate' % env.srv_venv_path):
+ run('pip install -r %s/requirements.txt' % tmpd)
+ run('pip install -r %s/requirements_srvr.txt' % tmpd)
+ run('rm -fr %s' % tmpd)
+
+
+def deploy():
+ # figure out the release name and version
+ with lcd(get_version_path()):
+ dist = local('python setup.py --fullname', capture=True).strip()
+ print(green("dist is %s" % dist))
+
+ # upload the source tarball to the temporary folder on the server
+ put('dist/%s.tar.gz' % dist, '/tmp/%s.tar.gz' % dist)
+ # create a place where we can unzip the tarball, then enter
+ # that directory and unzip it
+ # now setup the package with our virtual environment's
+ # python interpreter
+ with prefix('source %s/bin/activate' % env.srv_venv_path):
+ run('pip install -U --force-reinstall /tmp/%s.tar.gz' % dist)
+ # now that all is set up, delete the folder again
+
+ run('rm -rf /tmp/%s.tar.gz' % dist)
+ # # and finally touch the .wsgi file so that mod_wsgi triggers
+ # # a reload of the application
+ # run('touch /var/www/yourapplication.wsgi')
+
+@task(default=True)
+def deploy_version(version='tip'):
+ env['version'] = version
+ __init()
+ export()
+ pack()
+ if not exists(env.srv_venv_path):
+ create_virtualenv()
+ deploy()
+ __clean()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/sync/settings.py Tue Jan 06 17:48:50 2015 +0100
@@ -0,0 +1,8 @@
+from fabric.api import env
+
+
+# the user to use for the remote commands
+env.user = 'iri'
+# the servers where the commands are executed
+env.hosts = ['web.iri.centrepompidou.fr']
+env.srv_venv_path = '/iridata/virtualenv/catedit'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/sync/settings.py.tmpl Tue Jan 06 17:48:50 2015 +0100
@@ -0,0 +1,8 @@
+from fabric.api import env
+
+
+# the user to use for the remote commands
+env.user = 'user'
+# the servers where the commands are executed
+env.hosts = ['server']
+env.srv_venv_path = 'virtualenv folder path on host'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py Tue Jan 06 17:48:50 2015 +0100
@@ -0,0 +1,28 @@
+from setuptools import setup, find_packages
+
+setup(
+ name='catedit',
+ version="0.1.0",
+ url='http://www.iri.centrepompidou.fr',
+ author='I.R.I.',
+ author_email='dev@iri.centrepompidou.fr',
+ description='Category editor',
+ license='CECILL-B',
+ packages=find_packages('src'),
+ package_dir={'catedit':'src/catedit'},
+ include_package_data=True,
+# scripts=['src/catedit/bin/manage.py'],
+ zip_safe=False,
+ classifiers=[
+ 'Development Status :: 3 - Alpha',
+ 'Environment :: Web Environment',
+ 'Framework :: Flask',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: BSD License',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.4',
+ 'Topic :: Internet :: WWW/HTTP',
+ ],
+)
--- a/src/catedit/__init__.py Tue Jan 06 17:43:23 2015 +0100
+++ b/src/catedit/__init__.py Tue Jan 06 17:48:50 2015 +0100
@@ -4,20 +4,33 @@
"""
from logging import FileHandler, Formatter
+import os
from flask import Flask, session
from flask.ext.github import GitHub
from flask.ext.cache import Cache
from flask.ext.restful import Api
-from catedit.config import AppConfig
from catedit.settings import AppSettings
# set up app and database
app = Flask(__name__)
app.config.from_object(AppSettings)
cache = Cache(app, config={"CACHE_TYPE": "simple"})
-app.config.from_object(AppConfig)
+app_configured = False
+try:
+ from catedit.config import AppConfig
+ app.config.from_object(AppConfig)
+ app_configured = True
+except ImportError:
+ pass
+
+if 'CATEDIT_SETTINGS' in os.environ:
+ app.config.from_envvar('CATEDIT_SETTINGS')
+ app_configured = True
+
+if not app_configured:
+ raise Exception("Catedit not configured")
#github
github = GitHub(app)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/virtualenv/requirements_srvr.txt Tue Jan 06 17:48:50 2015 +0100
@@ -0,0 +1,1 @@
+uWSGI==2.0.9