0

I am getting a error while running it. The Error is :

File "binary_Light.py", 
           model_url^=project page

Traceback (most recent call last):
  File "binary_light.py", line 8, in <module>
    from brisa.upnp.device import Device, Service
  File "/usr/local/lib/python2.6/dist-packages/brisa/upnp/device/__init__.py", line 8, in <module>
    from brisa.upnp.device.device import Device
  File "/usr/local/lib/python2.6/dist-packages/brisa/upnp/device/device.py", line 10, in <module>
    from brisa.core import log, config, webserver, network
  File "/usr/local/lib/python2.6/dist-packages/brisa/core/webserver.py", line 39, in <module>
    raise RuntimeError('Network is down.')
RuntimeError: Network is down

Invalid syntax

It is pointing error ar url.

from brisa.core.reactors import install_default_reactor
reactor = install_default_reactor()
print reactor

import os

from brisa.upnp.device import Device, Service
from brisa.upnp.device.service import StateVariable


class SwitchPower(Service):

    def __init__(self):
        Service.__init__(self,
                         'SwitchPower',
                         'urn:schemas-upnp-org:service:SwitchPower:1',
                         '',
                         os.getcwd() + '/SwitchPower-scpd.xml')
        self.target = False
        self.status = False


    def SetTarget(self, *args, **kwargs):
        self.target = kwargs['NewTargetValue']
        self.status = self.target
        self.set_state_variable('Status', self.target)
        print 'Light switched ', {'1': 'on', '0': 'off'}.get(self.target, None)
        return {}

    def GetTarget(self, *args, **kwargs):
        return {'RetTargetValue': self.target}

    def soap_GetStatus(self, *args, **kwargs):
        return {'ResultStatus': self.status}


class BinaryLight(object):

    def __init__(self):
        self.server_name = 'Binary Light Device'
        self.device = None
    def _create_device(self):
        project_page = 'https://garage.maemo.org/projects/brisa'
        self.device = Device('urn:schemas=upnp-org:device:BinaryLight:1',
                            self.server_name,
                            manufacturer = 'Ankit',
                            model_name = 'Binary Light Device',
                            model_description = 'Test Device',
                            model_number = '1.0',
                            model_url= project_page)
    def _add_service(self):
        switch = SwitchPower()
        self.device.add_service(switch)
    def start(self):
        self._create_device()
        self._add_services()
        self.device.start()
        reactor.add_after_stop_func(self.device.stop)
        reactor.main()

if __name__ == '__main__':
    device = BinaryLight()
    device.start()

3 Answers 3

4

There is a comma missing at the end of model_number = '1.0'.

model_name = 'Binary Light Device',
model_description = 'Test Device',
model_number = '1.0'               <-
model_url= project_page)
Sign up to request clarification or add additional context in comments.

4 Comments

thanks....after removing it, I am getting a run time error which is same as my other question that I posted a little earlier. Do I need to put the question again, or directly modify that?
@user600790 If someone can help you on this problem, he will do it on the existing question.
I edited this question and also added error which I am getting. Please see and let me know my mistake.
I know, there is a problem with Network. But what kind of problem it is?? What Network it can be??
2

You are missing a comma:

model_description = 'Test Device',
model_number = '1.0',   # <- here
model_url= project_page)

1 Comment

I edited this question and also added error which I am getting now. Please see and let me know my mistake.
1

there should be comma after the line model_number = '1.0'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.