Beispiel #1
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)
Beispiel #2
0
#!/usr/bin/env python2.7
#:coding=utf-8
__author__ = 'allanche'
import yaml
import os
from lib.record_log import savelog
from lib.path_get import Path_change
import sys

s = savelog()


class Yamlconf:
    def __init__(self):
        p = Path_change()
        self.BASE_DIR = p.gain_profilePath()
        self.config = {}

    # 读取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
            s.error("etc_conf module yaml_read: %s" % error_info)
            sys.exit()


if __name__ == '__main__':
Beispiel #3
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')