#!python

"""
This will work in development on a relative folder basis
It will then work when installed in site-packages on a target system
where the runner script is in /usr/bin (or wherever)
"""
from sdk.softfire.main import start_manager
from eu.softfire.sec.SecurityManager import SecurityManager, UpdateStatusThread
import eu.softfire.sec.Api as api

from eu.softfire.sec.utils.utils import *
import os

def start():

    local_files_path = get_config("local-files", "path", config_path)
    tmp_files_path = "%s/tmp" % local_files_path
    if not os.path.exists(local_files_path):
        os.makedirs(local_files_path)
    if not os.path.exists(tmp_files_path):
        os.makedirs(tmp_files_path)

    sec_manager = SecurityManager(config_path)
    thread = UpdateStatusThread(sec_manager)
    thread.start()
    api.StartThread().start()

    start_manager(sec_manager)


if __name__ == '__main__':
    #os.environ["http_proxy"] = ""
    welcome = """
        `-::-`        `....`       -------``-------.  .......  `.`  `.....`    `......`     
        /yyssys-    ./ss+:-..`     `yyyyyyy-.yyyyyyyo `/+/////` -//  ./+////:`  :+/////-     
       `yh+``+o+  `+yho-:++/--`    `yh+````` ``+hy.`` `/+-````  -+/  .++.``/+:  /+:````      
       `shs.     `shhs-oy+..--::-` `yh+        /hy`   `/+-      -+/  .++.  :+:  /+:          
        .oyy/.   :hhh+oys.```..:+: `yhs++/`    /hy`   `/+:---   -+/  .++.`./+:  /+/---`      
         `-oyy/` /hhhssyy-    `:+/ `yhyooo`    /hy`   `/+/:::   -+/  .++///+:`  /+/:::`      
        `` `-sho -yhhhyyys:```./o- `yh+        /hy`   `/+-      -+/  .++.`/+/   /+:          
       .ss-  +hy` :yhhhhyyysooss:  `yh+        /hy`   `/+-      -+/  .++. .++.  /+:`         
        +yyooyy/   ./syhhhhyys/.   `yh+        /hy`   `/+-      -+/  .++.  /+/  /+/////.     
         .:++:.      `.-:::-.`      ::-        .::     .-`      `-.  `--`  `-.` .------`

    """
    print(welcome)
    start()

