Package etl :: Package component :: Package input :: Module xmlrpc_in
[hide private]
[frames] | no frames]

Source Code for Module etl.component.input.xmlrpc_in

 1  # -*- encoding: utf-8 -*- 
 2  ############################################################################## 
 3  # 
 4  #    ETL system- Extract Transfer Load system 
 5  #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved 
 6  #    $Id$ 
 7  # 
 8  #    This program is free software: you can redistribute it and/or modify 
 9  #    it under the terms of the GNU General Public License as published by 
10  #    the Free Software Foundation, either version 3 of the License, or 
11  #    (at your option) any later version. 
12  # 
13  #    This program is distributed in the hope that it will be useful, 
14  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  #    GNU General Public License for more details. 
17  # 
18  #    You should have received a copy of the GNU General Public License 
19  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
20  # 
21  ############################################################################## 
22  """ 
23   To run xmlrpc server. 
24   
25   Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). 
26   GNU General Public License. 
27  """ 
28  from etl.component import component 
29   
30  # 
31 -class xmlrpc_in(component):
32 """ 33 To connect server with xmlrpc request. 34 35 """ 36 _register_functions=[] 37
38 - def __init__(self, xmlrpc_connector, name='component.input.xmlrpc_in', transformer=None, row_limit=0):
39 """ 40 To be update 41 """ 42 super(xmlrpc_in, self).__init__(name=name, connector=xmlrpc_connector, transformer=transformer, row_limit=0) 43 self._type = 'component.input.xmlrpc_in' 44 self.datas = [] 45 self.isStarted = False 46 self.register_functions(self.import_data)
47
48 - def __copy__(self):
49 res = xmlrpc_in(self.xmlrpc_connector, self.name, self.transformer, self.row_limit) 50 return res
51
52 - def register_functions(self, fun):
53 self._register_functions.append(fun)
54
55 - def process(self):
56 from SimpleXMLRPCServer import SimpleXMLRPCServer 57 from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler 58 import threading 59 self.connector.start(self.import_data) 60 for d in self.datas: 61 yield d, 'main'
62
63 - def iterator(self, datas=[]):
64 if self.transformer: 65 row = self.transformer.transform(self.datas) 66 for d in datas: 67 yield d, 'main'
68
69 - def data_iterator(self, datas):
70 pass
71
72 - def import_data(self, datas):
73 self.generator = self.data_iterator(datas) 74 return True
75
76 -def test():
77 from etl_test import etl_test 78 import etl 79 xmlrpc_conn=etl.connector.xmlrpc_connector('localhost', 8050) 80 conn = xmlrpc_conn.start('import_data') 81 test1 = etl_test.etl_component_test(xmlrpc_in(xmlrpc_conn)) 82 res = test1.output() 83 print res
84 85 if __name__ == '__main__': 86 test() 87