예제 #1
0
파일: dispatch.py 프로젝트: mcruse/monotone
class CNEDispatch(CompositeNode):
    def __init__(self, *args, **kw):
        self.wsresponse = None
        self.soapnodes = None
        self.endnode = None
        self.startnode = None
        self.xmlnodes = None
        self.parseXML = False
        self.parseSOAP = True        
        self.serviceproxy = None
        self.currenttime = None
        self.password = None
        self.account = None
        self.namespace = None
        self.wsdlURL = None
        self.timeformat = '%Y-%m-%dT%H:%M:%S'
        super(CNEDispatch, self).__init__(*args, **kw)
    def configure(self, config):
        self.wsdlURL = config.get('WSDL', self.wsdlURL)
        self.account = config.get('account', self.account)
        self.password = config.get('password', self.password)
        self.namespace = config.get('namespace', self.namespace)
        self.timeformat = config.get('timeformat', self.timeformat)
        super(CNEDispatch, self).configure(config)
    def configuration(self):
        config = super(CNEDispatch, self).configuration()
        config['WSDL'] = self.wsdlURL
        config['account'] = self.account
        config['password'] = self.password
        config['namespace'] = self.namespace
        config['timeformat'] = self.timeformat
        return config
    def setup(self):
        dispatch = service.WSDLService(self.wsdlURL)
        namespace = dispatch.wsdlDocumentProxy.wsdl.targetNamespace
        if self.namespace is None:
            self.namespace = namespace
        dispatch.setNamespace(self.namespace)
        dispatch.disableNSPrefixing()
        dispatch.soapResultUnwrappingOff()
        dispatch.soapObjectSimplifyingOff()
        dispatch.debuggingOff()
        self.serviceproxy = dispatch
    def start(self):
        if not self.has_child('WS Response'):
            self.wsresponse = CompositeNode()
            self.wsresponse.configure({'parent': self, 
                                       'name': 'WS Response'})
            self.xmlnodes = xmldata.XMLDataNode()
            self.xmlnodes.configure({'name': 'XML Nodes', 
                                     'parent': self.wsresponse})
            self.soapnodes = soapdata.SOAPDataNode()
            self.soapnodes.configure({'name': 'SOAP Nodes', 
                                      'parent': self.wsresponse})
            

        else:
            self.wsresponse = self.get_child('WS Response')
            self.xmlnodes = self.wsresponse.get_child('XML Nodes')
            self.soapnodes = self.wsresponse.get_child('SOAP Nodes')
        if not self.has_child('Start time'):
            nodepath = path.join(as_node_url(self.soapnodes), 
                                 'GetAlertsResult/disp/emralert')
            self.startnode = AttributeNode()
            self.startnode.configure({'name': 'Start time', 
                                      'nodeurl': nodepath, 
                                      'attribute': 'start', 
                                      'parent': self})
            self.endnode = AttributeNode()
            self.endnode.configure({'name': 'End time', 
                                    'nodeurl': nodepath, 
                                    'attribute': 'end', 
                                    'parent': self})
        self.setup()
        super(CNEDispatch, self).start()
    def deprecated_start(self):
        if not self.has_child('WS Response'):
            self.wsresponse = xmldata.XMLDataNode()
            self.wsresponse.configure(
                {'name': 'WS Response', 'parent': self})
        else:
            self.wsresponse = self.get_child('WS Response')
        dispatch = service.SOAPService(self.serviceurl, self.namespace)
        dispatch.disableNSPrefixing()
        dispatch.setSoapAction(self.soapaction)
        dispatch.debuggingOff()
        dispatch.makeMethod('GetAlerts')
        dispatch.GetAlerts.appendArgument('UserName', 'string')
        dispatch.GetAlerts.appendArgument('Password', 'string')
        dispatch.GetAlerts.appendArgument('CurrentTime', 'string')
        self.serviceproxy = dispatch
        super(CNEDispatch, self).start()
    def deprecated_set(self, timestamp):
        if isinstance(timestamp, (int, float, long)):
            timetuple = time.localtime(timestamp)
            timestamp = time.strftime(self.timeformat, timetuple)
        elif timestamp in (None, 'None'):
            timestamp = time.strftime(self.timeformat)
        self.currenttime = timestamp
        self.serviceproxy.GetAlerts(self.account, 
                                    self.password, 
                                    self.currenttime)
        self.wsresponse.set(self.serviceproxy.GetAlerts.getResponseData())
    def set(self, timestamp = None):
        if isinstance(timestamp, (int, float, long)):
            timetuple = time.localtime(timestamp)
            timestamp = time.strftime(self.timeformat, timetuple)
        elif timestamp in (None, 'None'):
            timestamp = time.strftime(self.timeformat)
        self.currenttime = timestamp
        self.serviceproxy.GetAlerts(UserName=self.account, 
                                    Password=self.password, 
                                    CurrentTime=self.currenttime)
        if self.parseXML:
            self.xmlnodes.setValue(
                self.serviceproxy.GetAlerts.getResponseData())
        if self.parseSOAP:
            self.soapnodes.setValue(
                self.serviceproxy.GetAlerts.getResponse())
    def get(self):
        return self.currenttime
예제 #2
0
파일: pricing.py 프로젝트: mcruse/monotone
class CNEPricing(CompositeNode):
    def __init__(self, *args, **kw):
        self.effectivedate = None
        self.wsresponse = None
        self.soapnodes = None
        self.xmlnodes = None
        self.parseXML = False
        self.parseSOAP = True
        self.serviceproxy = None
        self.priceCurve = None
        self.password = None
        self.account = None
        self.namespace = None
        self.wsdlURL = None
        self.dateformat = '%m/%d/%Y'
        super(CNEPricing, self).__init__(*args, **kw)
    def configure(self, config):
        self.priceCurve = config.get('priceCurve', self.priceCurve)
        self.wsdlURL = config.get('WSDL', self.wsdlURL)
        self.account = config.get('account', self.account)
        self.password = config.get('password', self.password)
        self.namespace = config.get('namespace', self.namespace)
        self.dateformat = config.get('dateformat', self.dateformat)
        super(CNEPricing, self).configure(config)
    def configuration(self):
        config = super(CNEPricing, self).configuration()
        config['WSDL'] = self.wsdlURL
        config['priceCurve'] = self.priceCurve
        config['account'] = self.account
        config['password'] = self.password
        config['namespace'] = self.namespace
        config['dateformat'] = self.dateformat
        return config
    def setup(self):
        pricing = service.WSDLService(self.wsdlURL)
        namespace = pricing.wsdlDocumentProxy.wsdl.targetNamespace
        if self.namespace is None:
            self.namespace = namespace
        pricing.setNamespace(self.namespace)
        pricing.disableNSPrefixing()
        pricing.soapResultUnwrappingOff()
        pricing.soapObjectSimplifyingOff()
        pricing.debuggingOff()
        self.serviceproxy = pricing
    def deprecated_setup(self):
        pricing = service.WSDLService(self.wsdlURL)
        pricing.debuggingOff()
        pricing.disableNSPrefixing()
        pricing.GetPrice.namespace = self.namespace
        pricing.GetPrice.clearArguments()
        pricing.GetPrice.appendArgument('strCurve', 'string')
        pricing.GetPrice.appendArgument('strEffectiveDate', 'string')
        pricing.GetPrice.appendArgument('CustAccount', 'string')
        pricing.GetPrice.appendArgument('Pwd', 'string')
        self.serviceproxy = pricing
    def start(self):
        if not self.has_child('WS Response'):
            self.wsresponse = CompositeNode()
            self.wsresponse.configure({'parent': self, 
                                       'name': 'WS Response'})
            self.xmlnodes = xmldata.XMLDataNode()
            self.xmlnodes.configure({'name': 'XML Nodes', 
                                     'parent': self.wsresponse})
            self.soapnodes = soapdata.SOAPDataNode()
            self.soapnodes.configure({'name': 'SOAP Nodes', 
                                      'parent': self.wsresponse})
            

        else:
            self.wsresponse = self.get_child('WS Response')
            self.xmlnodes = self.wsresponse.get_child('XML Nodes')
            self.soapnodes = self.wsresponse.get_child('SOAP Nodes')
        self.setup()
        super(CNEPricing, self).start()
    def deprecated_set(self, timestamp):
        if isinstance(timestamp, (int, float, long)):
            timetuple = time.localtime(timestamp)
            timestamp = time.strftime(self.dateformat, timetuple)
        elif timestamp in (None, 'None'):
            timestamp = time.strftime(self.dateformat)
        self.effectivedate = timestamp
        self.serviceproxy.GetPrice(
            self.priceCurve, self.effectivedate, self.account, self.password)
        self.wsresponse.set(self.serviceproxy.GetPrice.getResponse())
    def set(self, timestamp = None):
        if isinstance(timestamp, (int, float, long)):
            timetuple = time.localtime(timestamp)
            timestamp = time.strftime(self.dateformat, timetuple)
        elif timestamp in (None, 'None'):
            timestamp = time.strftime(self.dateformat)
        self.effectivedate = timestamp
        self.serviceproxy.GetPrice(
            strCurve=self.priceCurve, strEffectiveDate=self.effectivedate, 
            CustAccount=self.account, Pwd=self.password)
        response = self.serviceproxy.GetPrice.getResponse()
        if self.parseXML:
            self.xmlnodes.setValue(response.GetPriceResult)
        if self.parseSOAP:
            self.soapnodes.setValue(response)
    def get(self):
        return self.effectivedate
예제 #3
0
class CNEDispatch(CompositeNode):
    def __init__(self, *args, **kw):
        self.wsresponse = None
        self.soapnodes = None
        self.endnode = None
        self.startnode = None
        self.xmlnodes = None
        self.parseXML = False
        self.parseSOAP = True
        self.serviceproxy = None
        self.currenttime = None
        self.password = None
        self.account = None
        self.namespace = None
        self.wsdlURL = None
        self.timeformat = '%Y-%m-%dT%H:%M:%S'
        super(CNEDispatch, self).__init__(*args, **kw)

    def configure(self, config):
        self.wsdlURL = config.get('WSDL', self.wsdlURL)
        self.account = config.get('account', self.account)
        self.password = config.get('password', self.password)
        self.namespace = config.get('namespace', self.namespace)
        self.timeformat = config.get('timeformat', self.timeformat)
        super(CNEDispatch, self).configure(config)

    def configuration(self):
        config = super(CNEDispatch, self).configuration()
        config['WSDL'] = self.wsdlURL
        config['account'] = self.account
        config['password'] = self.password
        config['namespace'] = self.namespace
        config['timeformat'] = self.timeformat
        return config

    def setup(self):
        dispatch = service.WSDLService(self.wsdlURL)
        namespace = dispatch.wsdlDocumentProxy.wsdl.targetNamespace
        if self.namespace is None:
            self.namespace = namespace
        dispatch.setNamespace(self.namespace)
        dispatch.disableNSPrefixing()
        dispatch.soapResultUnwrappingOff()
        dispatch.soapObjectSimplifyingOff()
        dispatch.debuggingOff()
        self.serviceproxy = dispatch

    def start(self):
        if not self.has_child('WS Response'):
            self.wsresponse = CompositeNode()
            self.wsresponse.configure({'parent': self, 'name': 'WS Response'})
            self.xmlnodes = xmldata.XMLDataNode()
            self.xmlnodes.configure({
                'name': 'XML Nodes',
                'parent': self.wsresponse
            })
            self.soapnodes = soapdata.SOAPDataNode()
            self.soapnodes.configure({
                'name': 'SOAP Nodes',
                'parent': self.wsresponse
            })

        else:
            self.wsresponse = self.get_child('WS Response')
            self.xmlnodes = self.wsresponse.get_child('XML Nodes')
            self.soapnodes = self.wsresponse.get_child('SOAP Nodes')
        if not self.has_child('Start time'):
            nodepath = path.join(as_node_url(self.soapnodes),
                                 'GetAlertsResult/disp/emralert')
            self.startnode = AttributeNode()
            self.startnode.configure({
                'name': 'Start time',
                'nodeurl': nodepath,
                'attribute': 'start',
                'parent': self
            })
            self.endnode = AttributeNode()
            self.endnode.configure({
                'name': 'End time',
                'nodeurl': nodepath,
                'attribute': 'end',
                'parent': self
            })
        self.setup()
        super(CNEDispatch, self).start()

    def deprecated_start(self):
        if not self.has_child('WS Response'):
            self.wsresponse = xmldata.XMLDataNode()
            self.wsresponse.configure({'name': 'WS Response', 'parent': self})
        else:
            self.wsresponse = self.get_child('WS Response')
        dispatch = service.SOAPService(self.serviceurl, self.namespace)
        dispatch.disableNSPrefixing()
        dispatch.setSoapAction(self.soapaction)
        dispatch.debuggingOff()
        dispatch.makeMethod('GetAlerts')
        dispatch.GetAlerts.appendArgument('UserName', 'string')
        dispatch.GetAlerts.appendArgument('Password', 'string')
        dispatch.GetAlerts.appendArgument('CurrentTime', 'string')
        self.serviceproxy = dispatch
        super(CNEDispatch, self).start()

    def deprecated_set(self, timestamp):
        if isinstance(timestamp, (int, float, long)):
            timetuple = time.localtime(timestamp)
            timestamp = time.strftime(self.timeformat, timetuple)
        elif timestamp in (None, 'None'):
            timestamp = time.strftime(self.timeformat)
        self.currenttime = timestamp
        self.serviceproxy.GetAlerts(self.account, self.password,
                                    self.currenttime)
        self.wsresponse.set(self.serviceproxy.GetAlerts.getResponseData())

    def set(self, timestamp=None):
        if isinstance(timestamp, (int, float, long)):
            timetuple = time.localtime(timestamp)
            timestamp = time.strftime(self.timeformat, timetuple)
        elif timestamp in (None, 'None'):
            timestamp = time.strftime(self.timeformat)
        self.currenttime = timestamp
        self.serviceproxy.GetAlerts(UserName=self.account,
                                    Password=self.password,
                                    CurrentTime=self.currenttime)
        if self.parseXML:
            self.xmlnodes.setValue(
                self.serviceproxy.GetAlerts.getResponseData())
        if self.parseSOAP:
            self.soapnodes.setValue(self.serviceproxy.GetAlerts.getResponse())

    def get(self):
        return self.currenttime
예제 #4
0
class CNEPricing(CompositeNode):
    def __init__(self, *args, **kw):
        self.effectivedate = None
        self.wsresponse = None
        self.soapnodes = None
        self.xmlnodes = None
        self.parseXML = False
        self.parseSOAP = True
        self.serviceproxy = None
        self.priceCurve = None
        self.password = None
        self.account = None
        self.namespace = None
        self.wsdlURL = None
        self.dateformat = '%m/%d/%Y'
        super(CNEPricing, self).__init__(*args, **kw)

    def configure(self, config):
        self.priceCurve = config.get('priceCurve', self.priceCurve)
        self.wsdlURL = config.get('WSDL', self.wsdlURL)
        self.account = config.get('account', self.account)
        self.password = config.get('password', self.password)
        self.namespace = config.get('namespace', self.namespace)
        self.dateformat = config.get('dateformat', self.dateformat)
        super(CNEPricing, self).configure(config)

    def configuration(self):
        config = super(CNEPricing, self).configuration()
        config['WSDL'] = self.wsdlURL
        config['priceCurve'] = self.priceCurve
        config['account'] = self.account
        config['password'] = self.password
        config['namespace'] = self.namespace
        config['dateformat'] = self.dateformat
        return config

    def setup(self):
        pricing = service.WSDLService(self.wsdlURL)
        namespace = pricing.wsdlDocumentProxy.wsdl.targetNamespace
        if self.namespace is None:
            self.namespace = namespace
        pricing.setNamespace(self.namespace)
        pricing.disableNSPrefixing()
        pricing.soapResultUnwrappingOff()
        pricing.soapObjectSimplifyingOff()
        pricing.debuggingOff()
        self.serviceproxy = pricing

    def deprecated_setup(self):
        pricing = service.WSDLService(self.wsdlURL)
        pricing.debuggingOff()
        pricing.disableNSPrefixing()
        pricing.GetPrice.namespace = self.namespace
        pricing.GetPrice.clearArguments()
        pricing.GetPrice.appendArgument('strCurve', 'string')
        pricing.GetPrice.appendArgument('strEffectiveDate', 'string')
        pricing.GetPrice.appendArgument('CustAccount', 'string')
        pricing.GetPrice.appendArgument('Pwd', 'string')
        self.serviceproxy = pricing

    def start(self):
        if not self.has_child('WS Response'):
            self.wsresponse = CompositeNode()
            self.wsresponse.configure({'parent': self, 'name': 'WS Response'})
            self.xmlnodes = xmldata.XMLDataNode()
            self.xmlnodes.configure({
                'name': 'XML Nodes',
                'parent': self.wsresponse
            })
            self.soapnodes = soapdata.SOAPDataNode()
            self.soapnodes.configure({
                'name': 'SOAP Nodes',
                'parent': self.wsresponse
            })

        else:
            self.wsresponse = self.get_child('WS Response')
            self.xmlnodes = self.wsresponse.get_child('XML Nodes')
            self.soapnodes = self.wsresponse.get_child('SOAP Nodes')
        self.setup()
        super(CNEPricing, self).start()

    def deprecated_set(self, timestamp):
        if isinstance(timestamp, (int, float, long)):
            timetuple = time.localtime(timestamp)
            timestamp = time.strftime(self.dateformat, timetuple)
        elif timestamp in (None, 'None'):
            timestamp = time.strftime(self.dateformat)
        self.effectivedate = timestamp
        self.serviceproxy.GetPrice(self.priceCurve, self.effectivedate,
                                   self.account, self.password)
        self.wsresponse.set(self.serviceproxy.GetPrice.getResponse())

    def set(self, timestamp=None):
        if isinstance(timestamp, (int, float, long)):
            timetuple = time.localtime(timestamp)
            timestamp = time.strftime(self.dateformat, timetuple)
        elif timestamp in (None, 'None'):
            timestamp = time.strftime(self.dateformat)
        self.effectivedate = timestamp
        self.serviceproxy.GetPrice(strCurve=self.priceCurve,
                                   strEffectiveDate=self.effectivedate,
                                   CustAccount=self.account,
                                   Pwd=self.password)
        response = self.serviceproxy.GetPrice.getResponse()
        if self.parseXML:
            self.xmlnodes.setValue(response.GetPriceResult)
        if self.parseSOAP:
            self.soapnodes.setValue(response)

    def get(self):
        return self.effectivedate