예제 #1
0
        exec "from %s.models import *" % m
    except ImportError:
        pass
    except Exception, e:
        logging.error('from %s import table failed: %s' % (m, e))


from yweb.orm import db

from app.appliance.models import Appliance
from app.auth.models import User

from ytool.ini import ConfigINI

cf = ConfigINI(settings.sitecfg, catalog='base')
appdir = cf.get('appliance_top_dir', '/opt/LuoYun/data/appliance/')

def _save_upfile(fpath, fhash):

    global appdir

    if not os.path.exists(fpath):
        return _('%s not exist !') % fpath

    if not os.path.exists(appdir):
        try:
            os.mkdir(appdir)
        except OSError, emsg:
            return _('mkdir error: %s') % emsg

    # file exists ?
예제 #2
0
from email.Header import Header
from email.Utils import parseaddr, formataddr


admin_name     = 'Admin'
smtp_server    = None
smtp_port      = 25
email_from     = None
email_username = None
email_pass     = None

import settings

from ytool.ini import ConfigINI
cf = ConfigINI(settings.SITE_CONFIG, 'email')
smtp_server = cf.get('smtp_server', 'localhost')
try:
    smtp_port = int( cf.get('smtp_port', 25) )
except:
    smtp_port = 25
admin_name = cf.get('name', 'LuoYunCloud Admin')
email_from = cf.get('from', '*****@*****.**')
email_username = cf.get('username')
email_pass = cf.get('password')

if email_username and '@' in email_username:
    if not email_from:
        email_from = email_username


def send_email(toaddr, subject, body, cc = [], bcc = []):
예제 #3
0
    except ImportError:
        pass
    except Exception, e:
        logging.error('from %s import table failed: %s' % (m, e))

#from lyorm import dbsession as db
from lyorm import get_new_session
db = get_new_session()

from app.appliance.models import Appliance
from app.account.models import User

from ytool.ini import ConfigINI

cf = ConfigINI(settings.LUOYUN_CONFIG_PATH, catalog='base')
appdir = cf.get('appliance_top_dir', '/opt/LuoYun/data/appliance/')


def _save_upfile(fpath, fhash):

    global appdir

    if not os.path.exists(fpath):
        return _('%s not exist !') % fpath

    if not os.path.exists(appdir):
        try:
            os.mkdir(appdir)
        except OSError, emsg:
            return _('mkdir error: %s') % emsg