1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- from threading import Lock
- import logging
- class Handle:
- def __init__(self):
- self.lock = Lock()
- self.Q = []
- self.max_item_length = 1000
- def add_task(self, content):
- if not isinstance(content, dict):
- logging.warning('[HANDLE] add task content: %s but type is not dict', content)
- return
- self.lock.acquire()
- content = self.content_format(content)
- self.Q.append(content)
- self.lock.release()
- @staticmethod
- def content_format(content):
- if not content.__contains__('dev_ip'):
- content['dev_ip'] = ''
- if not content.__contains__('expr'):
- content['expr'] = 1
- if not content.__contains__('dev_id'):
- content['dev_id'] = ''
- if not content.__contains__('port'):
- content['port'] = ''
- if not content.__contains__('type'):
- content['type'] = ''
- if not content.__contains__('schema'):
- content['schema'] = ''
- if not content.__contains__('login_name'):
- content['login_name'] = ''
- if not content.__contains__('pwd'):
- content['pwd'] = ''
- if not content.__contains__('kpi'):
- content['kpi'] = {}
- return content
- def to_file(self):
- pass
- def to_temp_file(self):
- pass
- def ftp_upload(self):
- pass
|