Ejemplo n.º 1
0
    def __connect_to_internet(self):
        self.connsm = self.wrapper.behaviour.current_sm
        # generate the configuration
        dialconf = DialerConf.from_config_dict(self.config)
        # configure dialer
        self.connsm.dialer.configure(dialconf, self.wrapper.device)
        # connect to Internet
        d = self.connsm.connect()

        def connect_eb(failure):
            log.err(failure)
            reactor.stop()

        def run_and_disconnect(result):
            executable = self.config['executable']
            if executable:
                log.msg("Running '%s'" % executable)
                returnVal = system(executable)
                log.msg("Executable end with status %d" % returnVal)

                d = self.connsm.close()

                def stop(*results):
                    reactor.callLater(2, reactor.stop)

                d.addCallback(stop)

        d.addCallback(run_and_disconnect)
        d.addErrback(connect_eb)
    def __connect_to_internet(self):
        self.connsm = self.wrapper.behaviour.current_sm
        # generate the configuration
        dialconf = DialerConf.from_config_dict(self.config)
        # configure dialer
        self.connsm.dialer.configure(dialconf, self.wrapper.device)
        # connect to Internet
        d = self.connsm.connect()
        
        def connect_eb(failure):
            log.err(failure)
            reactor.stop()

        def run_and_disconnect(result):
            executable = self.config['executable']
            if executable:
                log.msg("Running '%s'" % executable)
                returnVal = system(executable)
                log.msg("Executable end with status %d" % returnVal)

                d = self.connsm.close()

                def stop(*results):
                    reactor.callLater(2, reactor.stop)

                d.addCallback(stop)
        
        d.addCallback(run_and_disconnect)
        d.addErrback(connect_eb)
 def __connect_to_internet(self):
     self.connsm = self.wrapper.behaviour.current_sm
     # generate the configuration
     dialconf = DialerConf.from_config_dict(self.config)
     # configure dialer
     self.connsm.dialer.configure(dialconf, self.wrapper.device)
     # connect to Internet
     d = self.connsm.connect()
     
     def connect_eb(failure):
         log.err(failure)
         reactor.stop()
     
     d.addCallback(lambda _: log.msg("Connected to Internet!"))
     d.addErrback(connect_eb)
Ejemplo n.º 4
0
    def __connect_to_internet(self):
        self.connsm = self.wrapper.behaviour.current_sm
        # generate the configuration
        dialconf = DialerConf.from_config_dict(self.config)
        # configure dialer
        self.connsm.dialer.configure(dialconf, self.wrapper.device)
        # connect to Internet
        d = self.connsm.connect()

        def connect_eb(failure):
            log.err(failure)
            reactor.stop()

        d.addCallback(lambda _: log.msg("Connected to Internet!"))
        d.addErrback(connect_eb)
Ejemplo n.º 5
0
    def test_get_wvdial_conf_file(self):
        conf = dict(apn='ac.vodafone.es',
                    username='******',
                    password='******',
                    dialer_profile='default',
                    staticdns=False,
                    dns=None)
        expected = \
"""# wvdial template for VMC

[Dialer Defaults]

Phone = *99***1#
Username = vodafone
Password = vodafone
Stupid Mode = 1
Dial Command = ATDT
Check Def Route = on
Dial Attempts = 3

[Dialer connect]

Modem = /dev/ttyUSB0
Baud = 460800
Init2 = ATZ
Init3 = ATQ0 V1 E0 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,"IP","ac.vodafone.es"
ISDN = 0
Modem Type = Analog Modem
"""

        dialerconf = DialerConf.from_config_dict(conf)
        path = get_wvdial_conf_file(dialerconf, '/dev/ttyUSB0')
        data = get_file_data(path)
        self.assertEqual(data, expected)

        shutil.rmtree(os.path.dirname(path))
    def test_get_wvdial_conf_file(self):
        conf = dict(apn='ac.vodafone.es',
                    username='******',
                    password='******',
                    dialer_profile='default',
                    staticdns=False,
                    dns=None)
        expected = \
"""# wvdial template for VMC

[Dialer Defaults]

Phone = *99***1#
Username = vodafone
Password = vodafone
Stupid Mode = 1
Dial Command = ATDT
Check Def Route = on
Dial Attempts = 3

[Dialer connect]

Modem = /dev/ttyUSB0
Baud = 460800
Init2 = ATZ
Init3 = ATQ0 V1 E0 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,"IP","ac.vodafone.es"
ISDN = 0
Modem Type = Analog Modem
"""
        
        dialerconf = DialerConf.from_config_dict(conf)
        path = get_wvdial_conf_file(dialerconf, '/dev/ttyUSB0')
        data = get_file_data(path)
        self.assertEqual(data, expected)
        
        shutil.rmtree(os.path.dirname(path))