def __init__(self, conf): Sender.__init__(self) if not conf: return try: url = conf.get(SENDER_HTTP, SENDER_HTTP_URL) except ConfigParser.NoSectionError: pass except ConfigParser.NoOptionError: pass else: self.url = url try: by_gzip = conf.get(SENDER_HTTP, SENDER_HTTP_GZIP) except ConfigParser.NoSectionError: pass except ConfigParser.NoOptionError: pass else: self.by_gzip = by_gzip self.header = {} self.client = requests.Session() if self.by_gzip: self.header['Content-Type'] = 'application/gzip' self.header['Content-Encoding'] = 'gzip' else: self.header['Content-Type'] = 'application/json' self.header['Content-Encoding'] = 'json'
def __init__(self, cf): Sender.__init__(self) try: self.dst_path = cf.get('sender_dir', 'dst_path') except ConfigParser.NoSectionError: raise Exception('dst_path is empty') except ConfigParser.NoOptionError: raise Exception('dst_path is empty') if os.path.exists(self.dst_path): if os.path.isfile(self.dst_path): raise Exception('path %s is an exists file path' % (self.dst_path, )) else: os.makedirs(self.dst_path)
def __init__(self, cf): Sender.__init__(self) try: ak = cf.get('sender_kodo', 'ak') except ConfigParser.NoSectionError: raise Exception('ak is empty') except ConfigParser.NoOptionError: raise Exception('ak is empty') try: sk = cf.get('sender_kodo', 'sk') except ConfigParser.NoSectionError: raise Exception('sk is empty') except ConfigParser.NoOptionError: raise Exception('sk is empty') try: bucket = cf.get('sender_kodo', 'bucket') except ConfigParser.NoSectionError: raise Exception('bucket is empty') except ConfigParser.NoOptionError: raise Exception('bucket is empty') self.bucket = bucket self.q = qiniu.Auth(ak, sk)
def __init__(self, config, params=None): Sender.__init__(self, config, params) self.ip = config.config('ip') self.port = int(config.config('port')) self.sock = Socket(self.ip, self.port) self.sock.connect()
def __init__(self, config, params=None): Sender.__init__(self, config, params) self.ip = config.config('ip') self.port = int(config.config('port'))
def __init__(self, config, params=None): Sender.__init__(self, config, params) self.request_queue_name = config.config('request_queue') self.response_queue_name = config.config('response_queue') self.queue_address = config.config('queue_address')