@@ -1,32 +1,38 | |||||
1 | Prerequisites: |
|
1 | Prerequisites: | |
2 |
|
2 | |||
|
3 | Core: | |||
3 | -numpy 1.8.0 |
|
4 | -numpy 1.8.0 | |
4 | -scipy |
|
5 | -scipy | |
5 | -math |
|
6 | -math | |
6 | -matplotlib |
|
7 | -matplotlib | |
7 | -h5py |
|
8 | -h5py | |
8 | -ftplib |
|
9 | -ftplib | |
9 |
-paramiko |
|
10 | -paramiko (optional for SendTFilesToServer) | |
10 |
-stuffr (optional for |
|
11 | -stuffr (optional for jroIO_hf) | |
11 | -PyQt4 (for using GUI) |
|
|||
12 | -pyfits (Fits data) |
|
12 | -pyfits (Fits data) | |
|
13 | ||||
|
14 | GUI: | |||
|
15 | -PyQt4 | |||
|
16 | -wxPython | |||
|
17 | -msgpack-numpy | |||
|
18 | -cPickle | |||
13 |
|
19 | |||
14 | Signal Chain Installation: |
|
20 | Signal Chain Installation: | |
15 |
|
21 | |||
16 | 1. Install numpy, matplotlib, TKAgg |
|
22 | 1. Install numpy, matplotlib, TKAgg | |
17 | 2. Install digital_rf_hdf5 module (developed by Haystack Observatory) |
|
23 | 2. Install digital_rf_hdf5 module (developed by Haystack Observatory) | |
18 | if you want to use USRP data |
|
24 | if you want to use USRP data | |
19 | 3. untar schainpy-x.x.x.tar.gz |
|
25 | 3. untar schainpy-x.x.x.tar.gz | |
20 | 4. cd schainpy-x.x.x |
|
26 | 4. cd schainpy-x.x.x | |
21 | 5. execute: |
|
27 | 5. execute: | |
22 | [hostname]$ sudo pyhon setup.py install |
|
28 | [hostname]$ sudo pyhon setup.py install | |
23 | 6. testing gui: |
|
29 | 6. testing gui: | |
24 | [hostname]$ schainGUI (enter) |
|
30 | [hostname]$ schainGUI (enter) | |
25 |
|
31 | |||
26 | If you want to use serialization and zerorpc you will need to install the next packages: |
|
32 | If you want to use serialization and zerorpc you will need to install the next packages: | |
27 |
|
33 | |||
28 | 1. zerorpc |
|
34 | 1. zerorpc | |
29 | [hostname]$ sudo port install zerorpc |
|
35 | [hostname]$ sudo port install zerorpc | |
30 |
|
36 | |||
31 | 2. cPickle, msgpack and msgpack_numpy |
|
37 | 2. cPickle, msgpack and msgpack_numpy | |
32 | [hostname]$ sudo port install cPickle msgpack mspack_numpy No newline at end of file |
|
38 | [hostname]$ sudo port install cPickle msgpack mspack_numpy |
@@ -1,10 +1,7 | |||||
1 | from jroplot_voltage import * |
|
1 | from jroplot_voltage import * | |
2 | from jroplot_spectra import * |
|
2 | from jroplot_spectra import * | |
3 | from jroplot_heispectra import * |
|
3 | from jroplot_heispectra import * | |
4 | from jroplot_correlation import * |
|
4 | from jroplot_correlation import * | |
5 | from jroplot_parameters import * |
|
5 | from jroplot_parameters import * | |
6 | try: |
|
6 | from jroplotter import * | |
7 | from jroplotter import * |
|
|||
8 | except ImportError, e: |
|
|||
9 | print e |
|
|||
10 | No newline at end of file |
|
7 |
@@ -1,109 +1,111 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 9, 2014 |
|
2 | Created on Jul 9, 2014 | |
3 |
|
3 | |||
4 | @author: roj-idl71 |
|
4 | @author: roj-idl71 | |
5 | ''' |
|
5 | ''' | |
6 | import os |
|
6 | import os | |
7 | import datetime |
|
7 | import datetime | |
8 | import numpy |
|
8 | import numpy | |
9 |
|
9 | |||
10 | from time import sleep |
|
10 | from time import sleep | |
11 | from Queue import Queue |
|
11 | from Queue import Queue | |
12 | from threading import Thread |
|
12 | from threading import Thread | |
13 |
|
13 | |||
14 | from schainpy.model.proc.jroproc_base import Operation |
|
14 | from schainpy.model.proc.jroproc_base import Operation | |
15 | from schainpy.model.serializer.data import obj2Dict, dict2Obj |
|
15 | from schainpy.model.serializer.data import obj2Dict, dict2Obj | |
16 | from jroplot_correlation import * |
|
16 | from jroplot_correlation import * | |
17 | from jroplot_heispectra import * |
|
17 | from jroplot_heispectra import * | |
18 | from jroplot_parameters import * |
|
18 | from jroplot_parameters import * | |
19 | from jroplot_spectra import * |
|
19 | from jroplot_spectra import * | |
20 | from jroplot_voltage import * |
|
20 | from jroplot_voltage import * | |
21 |
|
21 | |||
22 |
|
22 | |||
23 | class Plotter(Operation): |
|
23 | class Plotter(Operation): | |
24 |
|
24 | |||
25 | isConfig = None |
|
25 | isConfig = None | |
26 | name = None |
|
26 | name = None | |
27 | __queue = None |
|
27 | __queue = None | |
28 |
|
28 | |||
29 | def __init__(self, plotter_name, plotter_queue=None): |
|
29 | def __init__(self, plotter_name, plotter_queue=None): | |
30 |
|
30 | |||
31 | Operation.__init__(self) |
|
31 | Operation.__init__(self) | |
32 |
|
32 | |||
33 | self.isConfig = False |
|
33 | self.isConfig = False | |
34 | self.name = plotter_name |
|
34 | self.name = plotter_name | |
35 | self.__queue = plotter_queue |
|
35 | self.__queue = plotter_queue | |
36 |
|
36 | |||
37 | def getSubplots(self): |
|
37 | def getSubplots(self): | |
38 |
|
38 | |||
39 | nrow = self.nplots |
|
39 | nrow = self.nplots | |
40 | ncol = 1 |
|
40 | ncol = 1 | |
41 | return nrow, ncol |
|
41 | return nrow, ncol | |
42 |
|
42 | |||
43 | def setup(self, **kwargs): |
|
43 | def setup(self, **kwargs): | |
44 |
|
44 | |||
45 | print "Initializing ..." |
|
45 | print "Initializing ..." | |
46 |
|
46 | |||
47 |
|
47 | |||
48 | def run(self, dataOut, id=None, **kwargs): |
|
48 | def run(self, dataOut, id=None, **kwargs): | |
49 |
|
49 | |||
50 | """ |
|
50 | """ | |
51 |
|
51 | |||
52 | Input: |
|
52 | Input: | |
53 | dataOut : |
|
53 | dataOut : | |
54 | id : |
|
54 | id : | |
55 | """ |
|
55 | """ | |
56 |
|
56 | |||
57 | packDict = {} |
|
57 | packDict = {} | |
58 |
|
58 | |||
59 | packDict['id'] = id |
|
59 | packDict['id'] = id | |
60 | packDict['name'] = self.name |
|
60 | packDict['name'] = self.name | |
61 | packDict['kwargs'] = kwargs |
|
61 | packDict['kwargs'] = kwargs | |
62 |
|
62 | |||
63 | packDict['data'] = obj2Dict(dataOut) |
|
63 | packDict['data'] = obj2Dict(dataOut) | |
64 |
|
64 | |||
65 | self.__queue.put(packDict) |
|
65 | self.__queue.put(packDict) | |
66 |
|
66 | |||
67 | class PlotterManager(Thread): |
|
67 | class PlotterManager(Thread): | |
68 |
|
68 | |||
69 | __stop = False |
|
69 | __stop = False | |
70 |
|
70 | |||
71 | def __init__(self, plotter_queue): |
|
71 | def __init__(self, plotter_queue): | |
72 |
|
72 | |||
73 | Thread.__init__(self) |
|
73 | Thread.__init__(self) | |
74 |
|
74 | |||
|
75 | self.setDaemon(True) | |||
|
76 | ||||
75 | self.__queue = plotter_queue |
|
77 | self.__queue = plotter_queue | |
76 |
|
78 | |||
77 | self.plotInstanceDict = {} |
|
79 | self.plotInstanceDict = {} | |
78 | self.__stop = False |
|
80 | self.__stop = False | |
79 |
|
81 | |||
80 | def run(self): |
|
82 | def run(self): | |
81 |
|
83 | |||
82 | while True: |
|
84 | while True: | |
83 |
|
85 | |||
84 | if self.__stop: |
|
86 | if self.__stop: | |
85 | break |
|
87 | break | |
86 |
|
88 | |||
87 | if self.__queue.empty(): |
|
89 | if self.__queue.empty(): | |
88 |
sleep(0. |
|
90 | sleep(0.1) | |
89 | continue |
|
91 | continue | |
90 |
|
92 | |||
91 | serial_data = self.__queue.get(True) |
|
93 | serial_data = self.__queue.get(True) | |
92 |
|
94 | |||
93 | plot_id = serial_data['id'] |
|
95 | plot_id = serial_data['id'] | |
94 | plot_name = serial_data['name'] |
|
96 | plot_name = serial_data['name'] | |
95 | kwargs = serial_data['kwargs'] |
|
97 | kwargs = serial_data['kwargs'] | |
96 | dataDict = serial_data['data'] |
|
98 | dataDict = serial_data['data'] | |
97 |
|
99 | |||
98 | dataPlot = dict2Obj(dataDict) |
|
100 | dataPlot = dict2Obj(dataDict) | |
99 |
|
101 | |||
100 | if plot_id not in self.plotInstanceDict.keys(): |
|
102 | if plot_id not in self.plotInstanceDict.keys(): | |
101 | className = eval(plot_name) |
|
103 | className = eval(plot_name) | |
102 | self.plotInstanceDict[plot_id] = className() |
|
104 | self.plotInstanceDict[plot_id] = className() | |
103 |
|
105 | |||
104 | plotter = self.plotInstanceDict[plot_id] |
|
106 | plotter = self.plotInstanceDict[plot_id] | |
105 | plotter.run(dataPlot, plot_id, **kwargs) |
|
107 | plotter.run(dataPlot, plot_id, **kwargs) | |
106 |
|
108 | |||
107 | def stop(self): |
|
109 | def stop(self): | |
108 |
|
110 | |||
109 | self.__stop = True No newline at end of file |
|
111 | self.__stop = True |
@@ -1,128 +1,115 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 15, 2014 |
|
2 | Created on Jul 15, 2014 | |
3 |
|
3 | |||
4 | @author: Miguel Urco |
|
4 | @author: Miguel Urco | |
5 | ''' |
|
5 | ''' | |
6 | from serializer import DynamicSerializer |
|
6 | from serializer import DynamicSerializer | |
7 |
|
7 | |||
8 | PICKLE_SERIALIZER = DynamicSerializer('cPickle') |
|
8 | DEFAULT_SERIALIZER = None #'cPickle', 'msgpack', "yaml" | |
9 | MSGPACK_SERIALIZER = DynamicSerializer('msgpack') |
|
|||
10 |
|
9 | |||
11 | from schainpy.model.data.jrodata import * |
|
10 | from schainpy.model.data.jrodata import * | |
12 |
|
11 | |||
13 | CLASSNAME_KEY = 'classname__' |
|
12 | CLASSNAME_KEY = 'classname__' | |
14 |
|
13 | |||
15 | def isNotClassVar(myObj): |
|
14 | def isNotClassVar(myObj): | |
16 |
|
15 | |||
17 | return not hasattr(myObj,'__dict__') |
|
16 | return not hasattr(myObj,'__dict__') | |
18 |
|
17 | |||
19 | def isDictFormat(thisValue): |
|
18 | def isDictFormat(thisValue): | |
20 |
|
19 | |||
21 | if type(thisValue) != type({}): |
|
20 | if type(thisValue) != type({}): | |
22 | return False |
|
21 | return False | |
23 |
|
22 | |||
24 | if CLASSNAME_KEY not in thisValue.keys(): |
|
23 | if CLASSNAME_KEY not in thisValue.keys(): | |
25 | return False |
|
24 | return False | |
26 |
|
25 | |||
27 | return True |
|
26 | return True | |
28 |
|
27 | |||
29 | def obj2Dict(myObj, keyList=[]): |
|
28 | def obj2Dict(myObj, keyList=[]): | |
30 |
|
29 | |||
31 | if not keyList: |
|
30 | if not keyList: | |
32 | keyList = myObj.__dict__.keys() |
|
31 | keyList = myObj.__dict__.keys() | |
33 |
|
32 | |||
34 | myDict = {} |
|
33 | myDict = {} | |
35 |
|
34 | |||
36 | myDict[CLASSNAME_KEY] = myObj.__class__.__name__ |
|
35 | myDict[CLASSNAME_KEY] = myObj.__class__.__name__ | |
37 |
|
36 | |||
38 | for thisKey, thisValue in myObj.__dict__.items(): |
|
37 | for thisKey, thisValue in myObj.__dict__.items(): | |
39 |
|
38 | |||
40 | if thisKey not in keyList: |
|
39 | if thisKey not in keyList: | |
41 | continue |
|
40 | continue | |
42 |
|
41 | |||
43 | if isNotClassVar(thisValue): |
|
42 | if isNotClassVar(thisValue): | |
44 | myDict[thisKey] = thisValue |
|
43 | myDict[thisKey] = thisValue | |
45 | continue |
|
44 | continue | |
46 |
|
45 | |||
47 | ## If this value is another class instance |
|
46 | ## If this value is another class instance | |
48 | myNewDict = obj2Dict(thisValue) |
|
47 | myNewDict = obj2Dict(thisValue) | |
49 | myDict[thisKey] = myNewDict |
|
48 | myDict[thisKey] = myNewDict | |
50 |
|
49 | |||
51 | return myDict |
|
50 | return myDict | |
52 |
|
51 | |||
53 | def dict2Obj(myDict): |
|
52 | def dict2Obj(myDict): | |
54 | ''' |
|
53 | ''' | |
55 | ''' |
|
54 | ''' | |
56 |
|
55 | |||
57 | if CLASSNAME_KEY not in myDict.keys(): |
|
56 | if CLASSNAME_KEY not in myDict.keys(): | |
58 | return None |
|
57 | return None | |
59 |
|
58 | |||
60 | className = eval(myDict[CLASSNAME_KEY]) |
|
59 | className = eval(myDict[CLASSNAME_KEY]) | |
61 |
|
60 | |||
62 | myObj = className() |
|
61 | myObj = className() | |
63 |
|
62 | |||
64 | for thisKey, thisValue in myDict.items(): |
|
63 | for thisKey, thisValue in myDict.items(): | |
65 |
|
64 | |||
66 | if thisKey == CLASSNAME_KEY: |
|
65 | if thisKey == CLASSNAME_KEY: | |
67 | continue |
|
66 | continue | |
68 |
|
67 | |||
69 | if not isDictFormat(thisValue): |
|
68 | if not isDictFormat(thisValue): | |
70 | setattr(myObj, thisKey, thisValue) |
|
69 | setattr(myObj, thisKey, thisValue) | |
71 | continue |
|
70 | continue | |
72 |
|
71 | |||
73 | myNewObj = dict2Obj(thisValue) |
|
72 | myNewObj = dict2Obj(thisValue) | |
74 | setattr(myObj, thisKey, myNewObj) |
|
73 | setattr(myObj, thisKey, myNewObj) | |
75 |
|
74 | |||
76 | return myObj |
|
75 | return myObj | |
77 |
|
76 | |||
78 |
def dict2Serial(myDict, serializer= |
|
77 | def dict2Serial(myDict, serializer=DEFAULT_SERIALIZER): | |
79 |
|
78 | |||
80 | if serializer == 'cPickle': |
|
79 | SERIALIZER = DynamicSerializer(serializer) | |
81 | SERIALIZER = PICKLE_SERIALIZER |
|
80 | ||
82 | else: |
|
|||
83 | SERIALIZER = MSGPACK_SERIALIZER |
|
|||
84 |
|
||||
85 | mySerial = SERIALIZER.dumps(myDict) |
|
81 | mySerial = SERIALIZER.dumps(myDict) | |
86 |
|
82 | |||
87 | return mySerial |
|
83 | return mySerial | |
88 |
|
84 | |||
89 |
def serial2Dict(mySerial, serializer= |
|
85 | def serial2Dict(mySerial, serializer=DEFAULT_SERIALIZER): | |
90 |
|
86 | |||
91 | if serializer == 'cPickle': |
|
87 | SERIALIZER = DynamicSerializer(serializer) | |
92 | SERIALIZER = PICKLE_SERIALIZER |
|
88 | ||
93 | else: |
|
|||
94 | SERIALIZER = MSGPACK_SERIALIZER |
|
|||
95 |
|
||||
96 | myDict = SERIALIZER.loads(mySerial) |
|
89 | myDict = SERIALIZER.loads(mySerial) | |
97 |
|
90 | |||
98 | return myDict |
|
91 | return myDict | |
99 |
|
92 | |||
100 |
def obj2Serial(myObj, serializer= |
|
93 | def obj2Serial(myObj, serializer=DEFAULT_SERIALIZER, **kwargs): | |
101 |
|
94 | |||
102 | if serializer == 'cPickle': |
|
95 | SERIALIZER = DynamicSerializer(serializer) | |
103 | SERIALIZER = PICKLE_SERIALIZER |
|
96 | ||
104 | else: |
|
|||
105 | SERIALIZER = MSGPACK_SERIALIZER |
|
|||
106 |
|
||||
107 | myDict = obj2Dict(myObj, **kwargs) |
|
97 | myDict = obj2Dict(myObj, **kwargs) | |
108 | mySerial = dict2Serial(myDict, serializer) |
|
98 | mySerial = dict2Serial(myDict, serializer) | |
109 |
|
99 | |||
110 | return mySerial |
|
100 | return mySerial | |
111 |
|
101 | |||
112 |
def serial2Obj(mySerial, metadataDict = {}, serializer= |
|
102 | def serial2Obj(mySerial, metadataDict = {}, serializer=DEFAULT_SERIALIZER): | |
113 |
|
103 | |||
114 | if serializer == 'cPickle': |
|
104 | SERIALIZER = DynamicSerializer(serializer) | |
115 | SERIALIZER = PICKLE_SERIALIZER |
|
105 | ||
116 | else: |
|
|||
117 | SERIALIZER = MSGPACK_SERIALIZER |
|
|||
118 |
|
||||
119 | myDataDict = serial2Dict(mySerial, serializer) |
|
106 | myDataDict = serial2Dict(mySerial, serializer) | |
120 |
|
107 | |||
121 | if not metadataDict: |
|
108 | if not metadataDict: | |
122 | myObj = dict2Obj(myDataDict) |
|
109 | myObj = dict2Obj(myDataDict) | |
123 | return myObj |
|
110 | return myObj | |
124 |
|
111 | |||
125 | metadataDict.update(myDataDict) |
|
112 | metadataDict.update(myDataDict) | |
126 | myObj = dict2Obj(metadataDict) |
|
113 | myObj = dict2Obj(metadataDict) | |
127 |
|
114 | |||
128 | return myObj |
|
115 | return myObj |
@@ -1,93 +1,108 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 17, 2014 |
|
2 | Created on Jul 17, 2014 | |
3 |
|
3 | |||
4 | @author: roj-idl71 |
|
4 | @author: roj-idl71 | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import cPickle |
|
7 | DEFAULT_SERIALIZER = None | |
8 | import msgpack_numpy |
|
|||
9 | import jsonpickle |
|
|||
10 | import yaml |
|
|||
11 |
|
8 | |||
12 | # import JROMsgpack |
|
9 | try: | |
13 |
|
|
10 | import cPickle | |
|
11 | DEFAULT_SERIALIZER = 'cPickle' | |||
|
12 | except: | |||
|
13 | pass | |||
|
14 | ||||
|
15 | try: | |||
|
16 | import msgpack_numpy | |||
|
17 | DEFAULT_SERIALIZER = 'msgpack' | |||
|
18 | except: | |||
|
19 | pass | |||
|
20 | ||||
|
21 | # import jsonpickle | |||
|
22 | # import yaml | |||
14 |
|
23 | |||
15 | class Serializer(object): |
|
24 | class Serializer(object): | |
16 |
|
25 | |||
17 | def __init__(self): |
|
26 | def __init__(self): | |
18 |
|
27 | |||
19 | self.serializer = None |
|
28 | self.serializer = None | |
20 |
|
29 | |||
21 | def dumps(self, obj, **kwargs): |
|
30 | def dumps(self, obj, **kwargs): | |
22 |
|
31 | |||
23 | return self.serializer.dumps(obj, **kwargs) |
|
32 | return self.serializer.dumps(obj, **kwargs) | |
24 |
|
33 | |||
25 | def loads(self, obj, **kwargs): |
|
34 | def loads(self, obj, **kwargs): | |
26 | return self.serializer.loads(obj, **kwargs) |
|
35 | return self.serializer.loads(obj, **kwargs) | |
27 |
|
36 | |||
28 | class cPickleSerializer(Serializer): |
|
37 | class cPickleSerializer(Serializer): | |
29 |
|
38 | |||
30 | def __init__(self): |
|
39 | def __init__(self): | |
31 | self.serializer = cPickle |
|
40 | self.serializer = cPickle | |
32 |
|
41 | |||
33 | def dumps(self, obj, **kwargs): |
|
42 | def dumps(self, obj, **kwargs): | |
34 | return self.serializer.dumps(obj, 2) |
|
43 | return self.serializer.dumps(obj, 2) | |
35 |
|
44 | |||
36 | def loads(self, obj, **kwargs): |
|
45 | def loads(self, obj, **kwargs): | |
37 | return self.serializer.loads(obj) |
|
46 | return self.serializer.loads(obj) | |
38 |
|
47 | |||
39 | class msgpackSerializer(Serializer): |
|
48 | class msgpackSerializer(Serializer): | |
40 |
|
49 | |||
41 | def __init__(self): |
|
50 | def __init__(self): | |
42 |
|
51 | |||
43 | self.serializer = msgpack_numpy |
|
52 | self.serializer = msgpack_numpy | |
44 |
|
53 | |||
45 | def dumps(self, obj, **kwargs): |
|
54 | def dumps(self, obj, **kwargs): | |
46 | return self.serializer.packb(obj) |
|
55 | return self.serializer.packb(obj) | |
47 |
|
56 | |||
48 | def loads(self, obj, **kwargs): |
|
57 | def loads(self, obj, **kwargs): | |
49 | return self.serializer.unpackb(obj) |
|
58 | return self.serializer.unpackb(obj) | |
50 |
|
59 | |||
51 | class jsonpickleSerializer(Serializer): |
|
60 | # class jsonpickleSerializer(Serializer): | |
52 |
|
61 | # | ||
53 | def __init__(self): |
|
62 | # def __init__(self): | |
54 |
|
63 | # | ||
55 | self.serializer = jsonpickle |
|
64 | # self.serializer = jsonpickle | |
56 |
|
65 | # | ||
57 | def dumps(self, obj, **kwargs): |
|
66 | # def dumps(self, obj, **kwargs): | |
58 | return self.serializer.encode(obj, **kwargs) |
|
67 | # return self.serializer.encode(obj, **kwargs) | |
59 |
|
68 | # | ||
60 | def loads(self, obj, **kwargs): |
|
69 | # def loads(self, obj, **kwargs): | |
61 | return self.serializer.decode(obj, **kwargs) |
|
70 | # return self.serializer.decode(obj, **kwargs) | |
62 |
|
71 | # | ||
63 | class yamlSerializer(Serializer): |
|
72 | # class yamlSerializer(Serializer): | |
64 |
|
73 | # | ||
65 | def __init__(self): |
|
74 | # def __init__(self): | |
66 |
|
75 | # | ||
67 | self.serializer = yaml |
|
76 | # self.serializer = yaml | |
68 |
|
77 | # | ||
69 | def dumps(self, obj, **kwargs): |
|
78 | # def dumps(self, obj, **kwargs): | |
70 | return self.serializer.dump(obj, **kwargs) |
|
79 | # return self.serializer.dump(obj, **kwargs) | |
71 |
|
80 | # | ||
72 | def loads(self, obj, **kwargs): |
|
81 | # def loads(self, obj, **kwargs): | |
73 | return self.serializer.load(obj, **kwargs) |
|
82 | # return self.serializer.load(obj, **kwargs) | |
74 |
|
83 | |||
75 | class DynamicSerializer(Serializer): |
|
84 | class DynamicSerializer(Serializer): | |
76 |
|
85 | |||
77 |
def __init__(self, mode = |
|
86 | def __init__(self, module = None): | |
78 |
|
87 | |||
|
88 | if not DEFAULT_SERIALIZER: | |||
|
89 | raise ImportError, "Install a python serializer like cPickle or msgpack" | |||
|
90 | ||||
|
91 | if not mode: | |||
|
92 | mode == DEFAULT_SERIALIZER | |||
|
93 | ||||
79 | if mode == 'cPickle': |
|
94 | if mode == 'cPickle': | |
80 | self.serializer = cPickleSerializer() |
|
95 | self.serializer = cPickleSerializer() | |
81 |
|
96 | # | ||
82 | if mode == 'jsonpickle': |
|
97 | # if mode == 'jsonpickle': | |
83 | self.serializer = jsonpickleSerializer() |
|
98 | # self.serializer = jsonpickleSerializer() | |
84 |
|
99 | # | ||
85 | if mode == 'yaml': |
|
100 | # if mode == 'yaml': | |
86 | self.serializer = yamlSerializer() |
|
101 | # self.serializer = yamlSerializer() | |
87 |
|
102 | |||
88 | if mode == 'msgpack': |
|
103 | if mode == 'msgpack': | |
89 | self.serializer = msgpackSerializer() |
|
104 | self.serializer = msgpackSerializer() | |
90 |
|
105 | |||
91 |
|
106 | |||
92 | if __name__ == '__main__': |
|
107 | if __name__ == '__main__': | |
93 | pass No newline at end of file |
|
108 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now