# Path: persepolis/scripts/useful_tools.py
# def osAndDesktopEnvironment():
#     desktop_env = None
#     if os_type in OS.UNIX_LIKE:
#         # find desktop environment('KDE', 'GNOME', ...)
#         desktop_env = os.environ.get('XDG_CURRENT_DESKTOP')
# 
#     return os_type, desktop_env
# 
# Path: persepolis/scripts/logger.py
# def sendToLog(text="", type="INFO"):
# 
# Path: persepolis/constants/Os.py
# class OS:
#     LINUX = 'Linux'
#     WINDOWS = 'Windows'
#     FREE_BSD = 'FreeBSD'
#     OPEN_BSD = 'OpenBSD'
#     OSX = DARWIN = 'Darwin'
#     BSD_FAMILY = [FREE_BSD, OPEN_BSD]
#     UNIX_LIKE = BSD_FAMILY + [LINUX]
#     LIST = [LINUX, WINDOWS, FREE_BSD, OPEN_BSD, OSX]


import re
import subprocess
import requests
import urllib
import os
from persepolis.scripts.useful_tools import osAndDesktopEnvironment
from persepolis.scripts import logger
from persepolis.constants import OS
                proxy['http_proxy_ip'] = re.search(r"\'([\w0-9\.]+)\'" , process.stdout.decode('utf-8')).group(1)
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.http', 'port'], stdout=subprocess.PIPE)
                proxy['http_proxy_port'] = process.stdout.decode('utf-8')
            except:
                logger.sendToLog('no http proxy detected', 'INFO')

            try:
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.https', 'host'], stdout=subprocess.PIPE)
                proxy['https_proxy_ip'] = re.search(r"\'([\w0-9\.]+)\'" , process.stdout.decode('utf-8')).group(1)
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.https', 'port'], stdout=subprocess.PIPE)
                proxy['https_proxy_port'] = process.stdout.decode('utf-8')
            except:
                logger.sendToLog('no https proxy detected', 'INFO')

            try:
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.ftp', 'host'], stdout=subprocess.PIPE)
                proxy['ftp_proxy_ip'] = re.search(r"\'([\w0-9\.]+)\'" , process.stdout.decode('utf-8')).group(1)
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.ftp', 'port'], stdout=subprocess.PIPE)
                proxy['ftp_proxy_port'] = process.stdout.decode('utf-8')
            except:
                logger.sendToLog('no ftp proxy detected', 'INFO')
            
            try:
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.socks', 'host'], stdout=subprocess.PIPE)
                value = re.search(r"\'([\w0-9\.]+)\'" , process.stdout.decode('utf-8')).group(1)
                socks_proxy = True
            except:
                socks_proxy = False
        
        else:

# Path: persepolis/scripts/useful_tools.py
# def osAndDesktopEnvironment():
#     desktop_env = None
#     if os_type in OS.UNIX_LIKE:
#         # find desktop environment('KDE', 'GNOME', ...)
#         desktop_env = os.environ.get('XDG_CURRENT_DESKTOP')
# 
#     return os_type, desktop_env
# 
# Path: persepolis/scripts/logger.py
# def sendToLog(text="", type="INFO"):
# 
# Path: persepolis/constants/Os.py
# class OS:
#     LINUX = 'Linux'
#     WINDOWS = 'Windows'
#     FREE_BSD = 'FreeBSD'
#     OPEN_BSD = 'OpenBSD'
#     OSX = DARWIN = 'Darwin'
#     BSD_FAMILY = [FREE_BSD, OPEN_BSD]
#     UNIX_LIKE = BSD_FAMILY + [LINUX]
#     LIST = [LINUX, WINDOWS, FREE_BSD, OPEN_BSD, OSX]


# Path: persepolis/scripts/check_proxy.py
import re
import subprocess
import requests
import urllib
import os
from persepolis.scripts.useful_tools import osAndDesktopEnvironment
from persepolis.scripts import logger
from persepolis.constants import OS

                proxy['http_proxy_ip'] = re.search(r"\'([\w0-9\.]+)\'" , process.stdout.decode('utf-8')).group(1)
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.http', 'port'], stdout=subprocess.PIPE)
                proxy['http_proxy_port'] = process.stdout.decode('utf-8')
            except:
                logger.sendToLog('no http proxy detected', 'INFO')

            try:
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.https', 'host'], stdout=subprocess.PIPE)
                proxy['https_proxy_ip'] = re.search(r"\'([\w0-9\.]+)\'" , process.stdout.decode('utf-8')).group(1)
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.https', 'port'], stdout=subprocess.PIPE)
                proxy['https_proxy_port'] = process.stdout.decode('utf-8')
            except:
                logger.sendToLog('no https proxy detected', 'INFO')

            try:
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.ftp', 'host'], stdout=subprocess.PIPE)
                proxy['ftp_proxy_ip'] = re.search(r"\'([\w0-9\.]+)\'" , process.stdout.decode('utf-8')).group(1)
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.ftp', 'port'], stdout=subprocess.PIPE)
                proxy['ftp_proxy_port'] = process.stdout.decode('utf-8')
            except:
                logger.sendToLog('no ftp proxy detected', 'INFO')
            
            try:
                process = subprocess.run(['gsettings', 'get', 'org.gnome.system.proxy.socks', 'host'], stdout=subprocess.PIPE)
                value = re.search(r"\'([\w0-9\.]+)\'" , process.stdout.decode('utf-8')).group(1)
                socks_proxy = True
            except:
                socks_proxy = False
        
        else:

            logger.sendToLog('no manual proxy detected', 'INFO')