# Path: core/constants.py
# SESSION_CLOSE_REASON_API_CALL = "Session closed via API stop_session call"
# GET_ENDPOINT_ATTEMPTS = 10
# ENDPOINT_REBUILD_ATTEMPTS = 3
# CREATE_SESSION_REQUEST_TIMEOUT = 60
# REQUEST_TIMEOUT = 60
# MAKE_REQUEST_ATTEMPTS_AMOUNT = 3
# REQUEST_SLEEP_BASE_TIME = 5
# REQUEST_TIMEOUT_ON_CREATE_ENDPOINT = 60
# ANY = u'ANY'
# GET_SESSION_SLEEP_TIME = 2
# ER_SLEEP_TIME = 2
# EP_SLEEP_TIME = 2
# 
# Path: core/config.py
# def full_path(path_to_config):
# def _import(filename):
# def create_if_not_exist(directory):
#     def update(self, new_values):
# def setup_config(path_to_config):
# class Config(object):
# 
# Path: core/exceptions.py
# class RequestException(Exception):
#     pass
# 
# class RequestTimeoutException(Exception):
#     pass
# 
# Path: core/utils/system_utils.py
# def run_command(command, silent=False):


import time
import logging
import netifaces
import requests
import socket
from Queue import Queue
from threading import Thread
from core import constants, config
from core.exceptions import RequestException, RequestTimeoutException
from . import system_utils
    url = None
    headers = None
    data = None

    def __init__(self, method, url="/", headers=None, data=""):
        _headers = {}
        if headers:
            for key, value in headers.items():
                if value:
                    _headers[key] = value
        _headers["Content-Length"] = str(len(data))
        self.headers = _headers
        self.method = method
        self.url = url
        self.data = data

    def __repr__(self):
        return "<RequestHelper method:%s url:%s headers:%s body:%s>" % (
            self.method, self.url, self.headers, self.data)


def get_interface_subnet(inteface):
    ip = netifaces.ifaddresses(inteface)[2][0]["addr"]
    split_ip = ip.split(".")
    split_ip[-1] = "0"
    ip = ".".join(split_ip)
    return ip + "/24"


def nmap_ping_scan(subnet):

# Path: core/constants.py
# SESSION_CLOSE_REASON_API_CALL = "Session closed via API stop_session call"
# GET_ENDPOINT_ATTEMPTS = 10
# ENDPOINT_REBUILD_ATTEMPTS = 3
# CREATE_SESSION_REQUEST_TIMEOUT = 60
# REQUEST_TIMEOUT = 60
# MAKE_REQUEST_ATTEMPTS_AMOUNT = 3
# REQUEST_SLEEP_BASE_TIME = 5
# REQUEST_TIMEOUT_ON_CREATE_ENDPOINT = 60
# ANY = u'ANY'
# GET_SESSION_SLEEP_TIME = 2
# ER_SLEEP_TIME = 2
# EP_SLEEP_TIME = 2
# 
# Path: core/config.py
# def full_path(path_to_config):
# def _import(filename):
# def create_if_not_exist(directory):
#     def update(self, new_values):
# def setup_config(path_to_config):
# class Config(object):
# 
# Path: core/exceptions.py
# class RequestException(Exception):
#     pass
# 
# class RequestTimeoutException(Exception):
#     pass
# 
# Path: core/utils/system_utils.py
# def run_command(command, silent=False):


# Path: core/utils/network_utils.py
import time
import logging
import netifaces
import requests
import socket
from Queue import Queue
from threading import Thread
from core import constants, config
from core.exceptions import RequestException, RequestTimeoutException
from . import system_utils

    url = None
    headers = None
    data = None

    def __init__(self, method, url="/", headers=None, data=""):
        _headers = {}
        if headers:
            for key, value in headers.items():
                if value:
                    _headers[key] = value
        _headers["Content-Length"] = str(len(data))
        self.headers = _headers
        self.method = method
        self.url = url
        self.data = data

    def __repr__(self):
        return "<RequestHelper method:%s url:%s headers:%s body:%s>" % (
            self.method, self.url, self.headers, self.data)


def get_interface_subnet(inteface):
    ip = netifaces.ifaddresses(inteface)[2][0]["addr"]
    split_ip = ip.split(".")
    split_ip[-1] = "0"
    ip = ".".join(split_ip)
    return ip + "/24"


def nmap_ping_scan(subnet):

    return system_utils.run_command(["nmap", "-sP", "-T4", subnet])