Beispiel #1
0
def create_visible_networks():
    """Find all broadcasting SSIDs and save in visible_networks file.  Return True if we got a good file"""

    network_good = False
    for do_resets in range(2):
        reset_networking()
        net_list = []
        if network_exists('wlan0'):
            if network_up('wlan0'):
                network_good = True
                for get_nets in range(2):
                    try:
                        net_list = collect_networks()
                        if len(net_list) == 0:
                            time.sleep(2)
                            continue
                        else:
                            logger.warning('Found valid wifi connection.')
                        break
                    except:
                        time.sleep(2)
                        continue
        # Dont support eth0 for now.


#        if network_up('eth0'):
#            network_good = True
#            logger.warning('Found valid ethernet connection.')
#            net_list.append('Irricloud valid eth0') # see sip_net_finish.py
        if len(net_list) == 0:
            network_good = False
            self.logger.warning('found no valid network.  Retrying')
            time.sleep(2)
            continue

        if len(net_list) == 0:
            net_list.append('No Networks Found')
            network_good = False
        else:
            network_good = True
            break

    with open('data/visible_networks', 'w') as f:
        json.dump(net_list, f)

    return network_good
Beispiel #2
0
def create_visible_networks():
    """Find all broadcasting SSIDs and save in visible_networks file.  Return True if we got a good file"""

    network_good = False
    for do_resets in range(2):
        reset_networking()
        net_list = []
        if network_exists('wlan0'):
            if network_up('wlan0'):
                network_good = True
                for get_nets in range(2):
                    try:
                        net_list = collect_networks()
                        if len(net_list) == 0:
                            time.sleep(2)
                            continue
                        else:
                            logger.warning('Found valid wifi connection.')
                        break
                    except:
                        time.sleep(2)
                        continue
         # Dont support eth0 for now.
#        if network_up('eth0'):
#            network_good = True
#            logger.warning('Found valid ethernet connection.')
#            net_list.append('Irricloud valid eth0') # see sip_net_finish.py
        if len(net_list) == 0:
            network_good = False
            self.logger.warning('found no valid network.  Retrying')
            time.sleep(2)
            continue

        if len(net_list) == 0:
            net_list.append('No Networks Found')
            network_good = False
        else:
            network_good = True
            break

    with open('data/visible_networks','w') as f:
        json.dump(net_list, f)

    return network_good
Beispiel #3
0
            if not config_mode:
                for cmd in ['hostapd', 'dnsmasq']:
                    try:
                        cmd_pid = program_pid(cmd)
                        if cmd_pid != 0:
                            logger.critical('found ' + cmd +
                                            ' running....kill it: ' +
                                            str(cmd_pid))
                            subprocess.call(['/bin/kill', '-9',
                                             str(cmd_pid)],
                                            stderr=subprocess.STDOUT)
                    except:
                        pass

            if not network_up('wlan0') and not network_up('eth0'):
                if reset_skip == 0:
                    logger.warning('sip_monitor: resetting network')
                    network_up('wlan0',
                               logger)  # save network info when resetting
                    reset_skip = 10  # throw in some delay
                    reset_networking(logger)
                elif reset_skip > 0:
                    reset_skip -= 1
            else:
                reset_skip = 10  # throw in some delay

        except Exception as ex:
            logger.exception('in except' + str(ex))

        time.sleep(5)
Beispiel #4
0
                            subprocess.call(['/etc/init.d/substation_proxy', 'start'], stderr=subprocess.STDOUT)
                except:
                    pass

            # kill any hostapd or dnsmasq processes hanging around
#            if not config_mode:
#                for cmd in ['hostapd', 'dnsmasq']:
#                    try:
#                        cmd_pid = program_pid(cmd)
#                        if cmd_pid != 0:
#                            logger.critical('found ' + cmd + ' running....kill it: ' + str(cmd_pid))
#                            subprocess.call(['/bin/kill', '-9', str(cmd_pid)], stderr=subprocess.STDOUT)
#                    except:
#                        pass

            if not gv.sd['remote_radio_substation'] and not network_up('wlan0') and not network_up('eth0'):
                if reset_skip == 0:
                    logger.warning('sip_monitor: resetting network')
                    network_up('wlan0', logger) # save network info when resetting
                    reset_skip = 10 # throw in some delay
                    reset_networking(logger)
                elif reset_skip > 0:
                    reset_skip -= 1
            else:
                reset_skip = 10 # throw in some delay

        except Exception as ex:
            logger.exception('in except' + str(ex))

        time.sleep(5)