Browse Source

Merge branch 'python' of github.com:rtCamp/easyengine into python

bugfixes
shital.rtcamp 10 years ago
parent
commit
d468468a29
  1. 24
      .travis.yml
  2. 51
      ee/cli/plugins/site.py
  3. 10
      ee/cli/plugins/stack.py
  4. 56
      ee/cli/templates/virtualconf.mustache
  5. 13
      ee/core/aptget.py
  6. 20
      ee/core/domainvalidate.py
  7. 9
      ee/core/fileutils.py

24
.travis.yml

@ -9,13 +9,25 @@ notifications:
language: bash
before_install:
- rm -rf ~/.gnupg
- rm -rf ~/.gnupg
before_script:
- sudo apt-get -qq purge mysql* graphviz*
- sudo apt-get -qq autoremove
- sudo apt-get -qq purge mysql* graphviz*
- sudo apt-get -qq autoremove
script:
- sudo echo -e "[user]\n\tname = Mitesh Shah\n\temail = root@localhost.com" > ~/.gitconfig
- sudo echo "Travis Banch = $TRAVIS_BRANCH"
- sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig
- sudo echo "Travis Banch = $TRAVIS_BRANCH"
- sudo apt-get install git python3-setuptools python3-dev python3-apt
- sudo easy_install3 pip
- sudo pip3 install virtualenv
- virtualenv ./env --system-site-packages
- source ./env/bin/activate
- sudo pip3 install -r requirements.txt
- sudo python3 setup.py develop
- mkdir ~/.ee
- ln -s /home/travis/build/rtCamp/easyengine/config/plugins.d ~/.ee/plugins.d
- ln -s /home/travis/build/rtCamp/easyengineee/cli/plugins ~/.ee/plugins
- ee --help
- sudo pip3 install nose coverage
- sudo nosetests

51
ee/cli/plugins/site.py

@ -1,6 +1,8 @@
"""EasyEngine site controller."""
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.domainvalidate import validate_domain
from ee.core.fileutils import EEFileUtils
import sys
@ -107,11 +109,15 @@ class EESiteCreateController(CementBaseController):
# TODO Default action for ee site command
# data = dict(foo='EESiteCreateController.default().')
# self.app.render((data), 'default.mustache')
# Check domain name validation
ee_domain_name = validate_domain(self.app.pargs.site_name)
# setup nginx configuration for site
if (self.app.pargs.html and not (self.app.pargs.php or
self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc or
self.app.pargs.wsubdir or self.app.pargs.wsubdomain)):
data = dict(site_name=self.app.pargs.site_name,
self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)):
data = dict(site_name=ee_domain_name,
static=True, basic=False, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False,
wpsubdir=False)
@ -120,7 +126,7 @@ class EESiteCreateController(CementBaseController):
self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc or
self.app.pargs.wsubdir or self.app.pargs.wsubdomain)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=True, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False,
wpsubdir=False)
@ -129,7 +135,7 @@ class EESiteCreateController(CementBaseController):
self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc or
self.app.pargs.wsubdir or self.app.pargs.wsubdomain)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=True, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False,
wpsubdir=False)
@ -140,25 +146,25 @@ class EESiteCreateController(CementBaseController):
self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)):
if (self.app.pargs.wp and not (self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=True, wp=True, w3tc=False,
wpfc=False, wpsc=False, multisite=False,
wpsubdir=False)
if (self.app.pargs.w3tc and not
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=False, wp=True, w3tc=True,
wpfc=False, wpsc=False, multisite=False,
wpsubdir=False)
if (self.app.pargs.wpfc and not
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=False, wp=True, w3tc=False,
wpfc=True, wpsc=False, multisite=False,
wpsubdir=False)
if (self.app.pargs.wpsc and not
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=False, wp=True, w3tc=False,
wpfc=False, wpsc=True, multisite=False,
wpsubdir=False)
@ -168,25 +174,25 @@ class EESiteCreateController(CementBaseController):
self.app.pargs.wpsubdomain or self.app.pargs.wp)):
if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=True, wp=True, w3tc=False,
wpfc=False, wpsc=False, multisite=True,
wpsubdir=True)
if (self.app.pargs.w3tc and not
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=False, wp=True, w3tc=True,
wpfc=False, wpsc=False, multisite=True,
wpsubdir=True)
if (self.app.pargs.wpfc and not
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=False, wp=True, w3tc=False,
wpfc=True, wpsc=False, multisite=True,
wpsubdir=True)
if (self.app.pargs.wpsc and not
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=False, wp=True, w3tc=False,
wpfc=False, wpsc=True, multisite=True,
wpsubdir=True)
@ -196,38 +202,47 @@ class EESiteCreateController(CementBaseController):
self.app.pargs.wpsubdir or self.app.pargs.wp)):
if (self.app.pargs.wpsubdomain and not (self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=True, wp=True, w3tc=False,
wpfc=False, wpsc=False, multisite=True,
wpsubdir=False)
if (self.app.pargs.w3tc and not
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=False, wp=True, w3tc=True,
wpfc=False, wpsc=False, multisite=True,
wpsubdir=False)
if (self.app.pargs.wpfc and not
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=False, wp=True, w3tc=False,
wpfc=True, wpsc=False, multisite=True,
wpsubdir=False)
if (self.app.pargs.wpsc and not
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
data = dict(site_name=self.app.pargs.site_name,
data = dict(site_name=ee_domain_name,
static=False, basic=False, wp=True, w3tc=False,
wpfc=False, wpsc=True, multisite=True,
wpsubdir=False)
try:
ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}.conf'
.format(self.app.pargs.site_name), 'w')
.format(ee_domain_name), 'w')
self.app.render((data), 'virtualconf.mustache',
out=ee_site_nginx_conf)
ee_site_nginx_conf.close()
except IOError as e:
print("Unable to create nginx conf for {2} ({0}): {1}"
.format(e.errno, e.strerror))
except Exception as e:
print("Select proper options for creating site")
print("{0}".format(e))
# create symbolic link
EEFileUtils.create_symlink(['/etc/nginx/sites-available/{0}.conf'
.format(ee_domain_name),
'/etc/nginx/sites-enabled/{0}.conf'
.format(ee_domain_name)])
class EESiteUpdateController(CementBaseController):

10
ee/cli/plugins/stack.py

@ -58,6 +58,11 @@ class EEStackController(CementBaseController):
dict(help='Install Utils stack', action='store_true')),
]
@expose(hide=True)
def package_check(self, packages=[]):
# Function for packages check
pass
@expose(hide=True)
def default(self):
# TODO Default action for ee stack command
@ -611,11 +616,8 @@ class EEStackController(CementBaseController):
"/htdocs/config/config.inc.php")
@expose()
def install(self):
def install(self, packages=[], apt_packages=[]):
pkg = EEAptGet()
apt_packages = []
packages = []
if self.app.pargs.web:
self.app.log.debug("Setting apt_packages variable for Nginx ,PHP"
" ,MySQL ")

56
ee/cli/templates/virtualconf.mustache

@ -1,32 +1,32 @@
server {
{{#multisite}}
# Uncomment the following line for domain mapping
# listen 80 default_server;
{{/multisite}}
server_name {{site_name}} {{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{site_name}};
{{#multisite}}
# Uncomment the following line for domain mapping
#server_name_in_redirect off;
{{/multisite}}
access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}};
error_log /var/log/nginx/{{site_name}}.error.log;
root /var/www/{{site_name}}/htdocs;
index {{^static}}index.php{{/static}} index.html index.htm;
{{#static}}
location / {
try_files $uri $uri/ /index.html;
}
{{/static}}
{{^static}}include{{/static}} {{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}
{{#wp}}include common/wpcommon.conf;{{/wp}}
include common/locations.conf;
{{#multisite}}
# Uncomment the following line for domain mapping
# listen 80 default_server;
{{/multisite}}
server_name {{site_name}} {{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{site_name}};
{{#multisite}}
# Uncomment the following line for domain mapping
#server_name_in_redirect off;
{{/multisite}}
access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}};
error_log /var/log/nginx/{{site_name}}.error.log;
root /var/www/{{site_name}}/htdocs;
index {{^static}}index.php{{/static}} index.html index.htm;
{{#static}}
location / {
try_files $uri $uri/ /index.html;
}
{{/static}}
{{^static}}include{{/static}} {{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}
{{#wp}}include common/wpcommon.conf;{{/wp}}
include common/locations.conf;
}

13
ee/core/aptget.py

@ -219,3 +219,16 @@ class EEAptGet:
.format(err=str(e)))
return(False)
return(True)
def is_installed(self, package):
# Cache Initialization
if not self.cache:
self.cache = apt.Cache()
# Cache Read
self.cache.open()
pkg = self.cache[package]
# Check Package Installed
if pkg.is_installed:
return True
else:
return False

20
ee/core/domainvalidate.py

@ -0,0 +1,20 @@
from urllib.parse import urlparse
def validate_domain(url):
# Check if http:// or https:// present remove it if present
domain_name = url.split('/')
if 'http:' in domain_name or 'https:' in domain_name:
domain_name = domain_name[2]
else:
domain_name = domain_name[0]
www_domain_name = domain_name.split('.')
final_domain = ''
if www_domain_name[0] == 'www':
final_domain = '.'.join(www_domain_name[1:])
return final_domain
else:
final_domain = domain_name
return final_domain

9
ee/core/fileutils.py

@ -1,6 +1,7 @@
"""EasyEngine file utils core classes."""
import shutil
import os
import glob
class EEFileUtils():
@ -28,3 +29,11 @@ class EEFileUtils():
self.app.log.info("Unable to remove file, [{err}]"
.format(err=str(e.reason)))
return False
def create_symlink(paths):
src = paths[0]
dst = paths[1]
try:
os.symlink(src, dst)
except Exception as e:
print("Unable to create sybolic link for {0}".format(e))

Loading…
Cancel
Save