예제 #1
0
파일: serv.py 프로젝트: HackLinux/iceworld
    # init
    os.chdir(os.path.join(os.path.dirname(__file__), '..'))
    port = 8888
    includes = None
    opts, argvs = getopt.getopt(sys.argv[1:], "c:p:h")
    for op, value in opts:
        if op == '-c':
            includes = value
            path._ETC_PATH = os.path.dirname(os.path.abspath(value))
        elif op == '-p':
            port = int(value)
        elif op == '-h':
            print u'''使用参数启动:
                        usage: [-p|-c]
                        -p [prot] ******启动端口,默认端口:%d
                        -c <file> ******加载配置文件
                   ''' % port
            sys.exit(0)
    if not includes:
        includes = os.path.join(path._ETC_PATH, 'includes_dev.json')
        print "no configuration found!,will use [%s] instead" % includes
        # main
    init_application(includes)
    application = get_application()
    application.listen(port)
    logger = Log().getLog()
    logger.info("starting..., listen [%d], configurated by (%s)", port, includes)
    tornado.ioloop.IOLoop.instance().start()


예제 #2
0
except NoAnswer as e:
    log.error(message=e)
    raise ValueError("Error response: {message}".format(message=e))

mx_record = MxRecord()

for mx in records:
    mx_record.add(str(mx.preference), str(mx.exchange))

if mx_record is not None:
    mx_records = mx_record.get()

    # Get local server hostname
    host = socket.gethostname()

    log.info("connecting...")

    try:
        # SMTP lib setup (use debug level for full output)
        if server_name is not None and server_port is not None:
            server = smtplib.SMTP(server_name, server_port)
        else:
            server = smtplib.SMTP()

        server.set_debuglevel(debug_level)
    except Exception as e:
        log.error("Error: {message}".format(message=e))
        raise ValueError("Connecting error with the server")

    for mx in mx_records:
        try:
예제 #3
0
        print("Arguments ERROR.")
        print("opt:\t" + str(opt))
        print("val:\t" + str(val))
        sys.exit(1)

src_path = work_dir + "/src"
tools_path = src_path + "/tools"
sys.path.append(src_path)
sys.path.append(tools_path)
#Cumtomize Moduls
import settings
from tools.Platform import *
from tools.MD5 import *
from tools.Log import *
from tools.SeleniumSpider import *
from tools.BS4Spider import *
from tools.RequestsSpider import *
from tools.Proxy import *
from tools.ListTool import *
from tools.MultiProcess import *
from tools.StringTool import *
from tools.Network import *

script_path = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]

logger = Log("./", "./log.log")
logger.init()
logger.info("info")
logger.error("error")
logger.warning("war")
예제 #4
0
if __name__ == "__main__":
    # init
    os.chdir(os.path.join(os.path.dirname(__file__), '..'))
    port = 8888
    includes = None
    opts, argvs = getopt.getopt(sys.argv[1:], "c:p:h")
    for op, value in opts:
        if op == '-c':
            includes = value
            path._ETC_PATH = os.path.dirname(os.path.abspath(value))
        elif op == '-p':
            port = int(value)
        elif op == '-h':
            print u'''使用参数启动:
                        usage: [-p|-c]
                        -p [prot] ******启动端口,默认端口:%d
                        -c <file> ******加载配置文件
                   ''' % port
            sys.exit(0)
    if not includes:
        includes = os.path.join(path._ETC_PATH, 'includes_dev.json')
        print "no configuration found!,will use [%s] instead" % includes
        # main
    init_application(includes)
    application = get_application()
    application.listen(port)
    logger = Log().getLog()
    logger.info("starting..., listen [%d], configurated by (%s)", port,
                includes)
    tornado.ioloop.IOLoop.instance().start()