Beispiel #1
0
def send_mail(to_list,sub,content):
    """
    :param to_list: 要发送得邮箱,["*****@*****.**"]
    :param sub: 主题
    :param content: 内容
    :return:
    """
    assert not None and isinstance(to_list,list)
    assert isinstance(sub,str)
    assert content and isinstance(content,str)


    _conf=Config_INI('configs/email.ini')
    _dic_con=_conf.get_fields('hx_zx')
    mail_host=_dic_con.get('host') #设置服务器
    mail_user=_dic_con.get('user') #用户名
    mail_password=_dic_con.get('pwd') #口令
    mail_postfix=_dic_con.get('postfix') #发件箱的后缀

    me="装修之家"+"<"+mail_user+"@"+mail_postfix+">"
    msg = MIMEText(content,_subtype='plain',_charset='utf-8')
    msg['Subject'] = sub
    msg['From'] = me
    msg['To'] = ";".join(to_list)
    try:
        server = smtplib.SMTP()
        server.connect(mail_host)
        server.starttls()#启动TLS模式,Gmail要求
        server.login(mail_user,mail_password)
        server.sendmail(me, to_list, msg.as_string())
        server.close()
        return True
    except Exception, e:
        return False
Beispiel #2
0
def send_mail(to_list, sub, content):
    """
    :param to_list: 要发送得邮箱,["*****@*****.**"]
    :param sub: 主题
    :param content: 内容
    :return:
    """
    assert not None and isinstance(to_list, list)
    assert isinstance(sub, str)
    assert content and isinstance(content, str)

    _conf = Config_INI('configs/email.ini')
    _dic_con = _conf.get_fields('hx_zx')
    mail_host = _dic_con.get('host')  #设置服务器
    mail_user = _dic_con.get('user')  #用户名
    mail_password = _dic_con.get('pwd')  #口令
    mail_postfix = _dic_con.get('postfix')  #发件箱的后缀

    me = "装修之家" + "<" + mail_user + "@" + mail_postfix + ">"
    msg = MIMEText(content, _subtype='plain', _charset='utf-8')
    msg['Subject'] = sub
    msg['From'] = me
    msg['To'] = ";".join(to_list)
    try:
        server = smtplib.SMTP()
        server.connect(mail_host)
        server.starttls()  #启动TLS模式,Gmail要求
        server.login(mail_user, mail_password)
        server.sendmail(me, to_list, msg.as_string())
        server.close()
        return True
    except Exception, e:
        return False
Beispiel #3
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from tornado.web import RequestHandler
import simplejson
from py.common.config.config_ini import Config_INI
from py.common.response_entity import res_entity
from py.control.user_manager import UserManager
from py.common.myexception import MyException
from py.common.convert import bs2utf8
from py.common.redis.redis_client import Redis

redis_conf = Config_INI('configs/redis.ini')
redis_account = Redis(redis_conf.get('account', 'url'))

common_conf = Config_INI('configs/common.ini')


class AccountHandler(RequestHandler):
    """
    用户账号
    """
    def post(self, method):
        _user_man = UserManager()
        if method == 'login':
            # 登录redis.ini
            username = bs2utf8(self.get_argument('username'))
            pwd = bs2utf8(self.get_argument('pwd'))
            try:
                userinfo = _user_man.login(username, pwd)
                result = res_entity.getSuccessEntity(userinfo)
                if userinfo:
Beispiel #4
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from py.common.config.config_ini import Config_INI
import torndb

_conf=Config_INI('configs/mysql/mysql.ini')
_dic_con=_conf.get_fields('hx_zx')

mysql_db = torndb.Connection(**_dic_con)

class DALC(object):#数据操作类
    def __init__(self):
        self.table = ""#子类中必须定义table
        self.view = ""
        self.columns = ()
        self._init()

    def _init(self):
        if not self.view:
            self.view = self.table


    def exec_query(self,query, *parameters, **kwparameters):
        #执行一个查询语句
        return mysql_db.query(query, *parameters, **kwparameters)

    def getMaxValue(self,column,pre=""):
        if not column.strip():
            column="sCode"#如果为空,取默认sCode列
        if not pre.strip():
            sql = "select max({0}) from {1}".format(column,self.view)
Beispiel #5
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from py.common.config.config_ini import Config_INI
import torndb

_conf = Config_INI("configs/mysql/mysql.ini")
_dic_con = _conf.get_fields("hf_zx")

mysql_db = torndb.Connection(**_dic_con)


class DALC(object):  # 数据操作类
    def __init__(self):
        self.table = ""  # 子类中必须定义table
        self.view = ""
        self.columns = ()
        self._init()

    def _init(self):
        if not self.view:
            self.view = self.table

    def exec_query(self, query, *parameters, **kwparameters):
        # 执行一个查询语句
        return mysql_db.query(query, *parameters, **kwparameters)

    def getMaxValue(self, column, pre=""):
        if not column.strip():
            column = "sCode"  # 如果为空,取默认sCode列
        if not pre.strip():
            sql = "select max({0}) from {1}".format(column, self.view)