# Path: lib/display/Message.py
# MESSAGE = Message()
# 
# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# Path: lib/utils/utils.py
# def encode(message):
#     return bytes(message,'UTF-8')
# 
# Path: lib/utils/pathutils.py
# def get_tss_path():
#     """ Return path to tss.js """
#     return os.path.join(package_path, 'bin', 'tss.js')
# 
# def find_tsconfigdir(rootdir):
#     """ Returns the normalized dir, in which the tsconfig.json file is located"""
#     rootdir = os.path.abspath(rootdir)
#     try:
#         if file_exists(os.path.join(rootdir, "tsconfig.json")):
#             return os.path.normcase(rootdir)
#     except FileNotFoundError:
#         pass
# 
#     parentdir = os.path.abspath(os.path.join(rootdir, os.pardir))
#     if parentdir == rootdir:
#         return None
#     else:
#         return find_tsconfigdir(parentdir)
# 
# def default_node_path(node_path, project=None):
#     if node_path == 'none':
#         Debug('notify', 'The setting node_path is set to "none". That is depreciated. Remove the setting.')
#         node_path = None
# 
#     if node_path == "" or node_path is None:
#         if sys.platform == "linux":
#             return "nodejs"
#         elif sys.platform == "nt":
#             return "node"
#         elif sys.platform == "darwin":
#             return "/usr/local/bin/node"
#         else:
#             return "node"
#     else:
#         return expand_variables(node_path, project)
# 
# Path: lib/utils/osutils.py
# def get_kwargs(stderr=True):
#     if os.name == 'nt':
#         startupinfo = subprocess.STARTUPINFO()
#         startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
#         if stderr:
#             #errorlog = open(os.devnull, 'w')
#             return {'stderr':subprocess.DEVNULL, 'startupinfo': startupinfo}
#         return {'startupinfo': startupinfo}
#     else:
#         return {}
# 
# Path: lib/utils/disabling.py
# def set_plugin_temporarily_disabled(folder=None):
#     """ Enables the plugin globally or for folder.
#         Folder can be a view """
#     if folder is None:
#         if not is_plugin_globally_disabled():
#             plugin_disabled_for_folders.append("*global")
#     else:
#         if isinstance(folder, sublime.View):
#             folder = os.path.dirname(folder.file_name())
#         folder = os.path.normcase(folder)
#         Debug('project', 'Disable ArcticTypescript for %s' % folder)
#         if folder not in plugin_disabled_for_folders:
#             plugin_disabled_for_folders.append(folder)


from subprocess import Popen, PIPE
from threading import Thread
    from queue import Queue, Empty
    from Queue import Queue, Empty
from ..display.Message import MESSAGE
from ..utils import encode, Debug
from ..utils.pathutils import get_tss_path, find_tsconfigdir, default_node_path
from ..utils.osutils import get_kwargs
from ..utils.disabling import set_plugin_temporarily_disabled
import sublime
import os
import time
                 % self.project.tsconfigfile)
        self.slow.kill_tssjs_queue_and_adapter()
        self.fast.kill_tssjs_queue_and_adapter()



    def _wait_for_finish_and_notify_user(self, i=1, dir=-1):
        """ Displays animated Message as long as TSS is initing. Is recoursive function. """

        if self.get_initialisation_error_message():
            sublime.error_message('Typescript initializion error for : %s\n >>> %s\n ArcticTypescript is disabled until you restart sublime.'
                         % (self.project.tsconfigfile, self.get_initialisation_error_message()))
            set_plugin_temporarily_disabled()
            return

        if not self.is_initialized():
            (i, dir) = self._display_animated_init_message(i, dir)
            # recursive:
            sublime.set_timeout(lambda: self._wait_for_finish_and_notify_user(i, dir), 100)
        else:
            # starting finished ->
            MESSAGE.show('Typescript project intialized for file : %s' % self.project.tsconfigfile, True, with_panel=False)
            self.project.on_services_started()

    def _display_animated_init_message(self, i, dir):
        if i in [1, 8]:
            dir *= -1
        i += dir
        anim_message = ' Typescript project is initializing [%s]' % '='.rjust(i).ljust(8)


# Path: lib/display/Message.py
# MESSAGE = Message()
# 
# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# Path: lib/utils/utils.py
# def encode(message):
#     return bytes(message,'UTF-8')
# 
# Path: lib/utils/pathutils.py
# def get_tss_path():
#     """ Return path to tss.js """
#     return os.path.join(package_path, 'bin', 'tss.js')
# 
# def find_tsconfigdir(rootdir):
#     """ Returns the normalized dir, in which the tsconfig.json file is located"""
#     rootdir = os.path.abspath(rootdir)
#     try:
#         if file_exists(os.path.join(rootdir, "tsconfig.json")):
#             return os.path.normcase(rootdir)
#     except FileNotFoundError:
#         pass
# 
#     parentdir = os.path.abspath(os.path.join(rootdir, os.pardir))
#     if parentdir == rootdir:
#         return None
#     else:
#         return find_tsconfigdir(parentdir)
# 
# def default_node_path(node_path, project=None):
#     if node_path == 'none':
#         Debug('notify', 'The setting node_path is set to "none". That is depreciated. Remove the setting.')
#         node_path = None
# 
#     if node_path == "" or node_path is None:
#         if sys.platform == "linux":
#             return "nodejs"
#         elif sys.platform == "nt":
#             return "node"
#         elif sys.platform == "darwin":
#             return "/usr/local/bin/node"
#         else:
#             return "node"
#     else:
#         return expand_variables(node_path, project)
# 
# Path: lib/utils/osutils.py
# def get_kwargs(stderr=True):
#     if os.name == 'nt':
#         startupinfo = subprocess.STARTUPINFO()
#         startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
#         if stderr:
#             #errorlog = open(os.devnull, 'w')
#             return {'stderr':subprocess.DEVNULL, 'startupinfo': startupinfo}
#         return {'startupinfo': startupinfo}
#     else:
#         return {}
# 
# Path: lib/utils/disabling.py
# def set_plugin_temporarily_disabled(folder=None):
#     """ Enables the plugin globally or for folder.
#         Folder can be a view """
#     if folder is None:
#         if not is_plugin_globally_disabled():
#             plugin_disabled_for_folders.append("*global")
#     else:
#         if isinstance(folder, sublime.View):
#             folder = os.path.dirname(folder.file_name())
#         folder = os.path.normcase(folder)
#         Debug('project', 'Disable ArcticTypescript for %s' % folder)
#         if folder not in plugin_disabled_for_folders:
#             plugin_disabled_for_folders.append(folder)


# Path: lib/server/Processes.py
from subprocess import Popen, PIPE
from threading import Thread
    from queue import Queue, Empty
    from Queue import Queue, Empty
from ..display.Message import MESSAGE
from ..utils import encode, Debug
from ..utils.pathutils import get_tss_path, find_tsconfigdir, default_node_path
from ..utils.osutils import get_kwargs
from ..utils.disabling import set_plugin_temporarily_disabled
import sublime
import os
import time

                 % self.project.tsconfigfile)
        self.slow.kill_tssjs_queue_and_adapter()
        self.fast.kill_tssjs_queue_and_adapter()



    def _wait_for_finish_and_notify_user(self, i=1, dir=-1):
        """ Displays animated Message as long as TSS is initing. Is recoursive function. """

        if self.get_initialisation_error_message():
            sublime.error_message('Typescript initializion error for : %s\n >>> %s\n ArcticTypescript is disabled until you restart sublime.'
                         % (self.project.tsconfigfile, self.get_initialisation_error_message()))
            set_plugin_temporarily_disabled()
            return

        if not self.is_initialized():
            (i, dir) = self._display_animated_init_message(i, dir)
            # recursive:
            sublime.set_timeout(lambda: self._wait_for_finish_and_notify_user(i, dir), 100)
        else:
            # starting finished ->
            MESSAGE.show('Typescript project intialized for file : %s' % self.project.tsconfigfile, True, with_panel=False)
            self.project.on_services_started()

    def _display_animated_init_message(self, i, dir):
        if i in [1, 8]:
            dir *= -1
        i += dir
        anim_message = ' Typescript project is initializing [%s]' % '='.rjust(i).ljust(8)


        MESSAGE.repeat(anim_message, with_panel=False)