Example #1
0
 def add_filehandler(self, level):
     p = Path_change()
     BASE_DIR = p.gain_profilePath()
     fmt = logging.Formatter(self.LOGFORMAT)
     file = BASE_DIR + '/log/server'
     header = logging.FileHandler(file)
     level = getattr(logging, level.upper(), logging.DEBUG)
     header.setLevel(level)
     header.setFormatter(fmt)
     self.Logger.addHandler(header)
Example #2
0
class Yamlconf:
    def __init__(self):
        self.p = Path_change()
        self.BASE_DIR = self.p.gain_profilePath()
        self.config = {}
        self.errLog = savelog(self.BASE_DIR+'/log/db_back_log')
    #读取yaml文件进行load
    def yaml_read(self):

        try:
            etc_file = os.path.abspath(self.BASE_DIR +'/etc/name.yaml')   #无论在windows下还是linux下自动转换路径分隔符
            self.config = yaml.load(file(etc_file,'r'))
            return self.config
        except Exception,e:
            error_info = e
            self.errLog.error(error_info)
            sys.exit()
Example #3
0
 def __init__(self):
     p = Path_change()
     self.BASE_DIR = p.gain_profilePath()
     self.config = {}
Example #4
0
#!/usr/bin/env python
#coding: utf-8
__author__ = 'allanche'
import socket
import optparse
import sys
from  lib.record_log import savelog
from lib.etc_conf import Yamlconf
from lib.path_get import Path_change
from lib.Authdeclient import Authdeclient
y = Yamlconf()
ip = y.yaml_read()['server_configure']['ip_address']  # server ip
sock = y.yaml_read()['server_configure']['socket']  # server socket
p = Path_change()
errLog = savelog(p.gain_profilePath()+'/log/db_back_log')

def Client(LIST,ip,sock):
    try:
        messages = ' '.join(LIST)
        print "Connect to the server"
        server_address = (ip,int(sock))        #Create a TCP/IP sock
        socks = []
        socks = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        socks.connect(server_address)
    except Exception,e:
        error_info = e
        errLog.error(error_info)
        sys.exit()
    try:
        #Sending message from different sockets
        print "  %s sending %s" % (socks.getpeername(),messages)
Example #5
0
 def __init__(self):
     self.p = Path_change()
     self.BASE_DIR = self.p.gain_profilePath()
     self.config = {}
     self.errLog = savelog(self.BASE_DIR+'/log/db_back_log')
Example #6
0
 def __init__(self, interval):
     multiprocessing.Process.__init__(self)
     self.interval = interval
     p = Path_change()
     self.BASE_DIR = p.gain_profilePath()