def __init__(self, port): super().__init__("localhost", port) self.hsdev_process = None hsdev_ver = hsdev_version() if hsdev_ver is None: Common.output_error_async( sublime.active_window(), "\n".join(HsDevLocalAgent.hsdev_not_found)) elif not check_version(hsdev_ver, HSDEV_MIN_VER): Common.output_error_async( sublime.active_window(), "\n".join(HsDevLocalAgent.hsdev_wrong_version(hsdev_ver))) else: hsdev_log_settings = Settings.PLUGIN.hsdev_log_config if patch_simple_log(hsdev_ver): hsdev_log_settings = Settings.PLUGIN.hsdev_log_level self.hsdev_process = HsDevProcess( port, hsdev_ver, cache=os.path.join(Common.sublime_haskell_cache_path(), 'hsdev'), log_file=os.path.join(Common.sublime_haskell_cache_path(), 'hsdev', 'hsdev.log'), log_config=hsdev_log_settings)
def __init__(self, backend_mgr, local=True, port=HSDEV_DEFAULT_PORT, host=HSDEV_DEFAULT_HOST, local_base_dir=None, remote_base_dir=None, **kwargs): super().__init__(backend_mgr) Logging.log( '{0}.__init__({1}, {2})'.format(type(self).__name__, host, port), Logging.LOG_INFO) # Sanity checking: exec_with = kwargs.get('exec-with') install_dir = kwargs.get('install-dir') if exec_with is not None and install_dir is None: sublime.error_message('\n'.join([ '\'exec_with\' requires an \'install_dir\'.', '', 'Please check your \'backends\' configuration and retry.' ])) raise RuntimeError('\'exec_with\' requires an \'install_dir\'.') elif exec_with is not None and exec_with not in ['stack', 'cabal']: sublime.error_message('\n'.join([ 'Invalid backend \'exec_with\': {0}'.format(exec_with), '', 'Valid values are "cabal" or "stack".', 'Please check your \'backends\' configuration and retry.' ])) raise RuntimeError( 'Invalid backend \'exec_with\': {0}'.format(exec_with)) # Local hsdev server process and params self.is_local_hsdev = local self.hsdev_process = None self.cache = os.path.join(Common.sublime_haskell_cache_path(), 'hsdev') self.log_file = os.path.join(Common.sublime_haskell_cache_path(), 'hsdev', 'hsdev.log') self.exec_with = exec_with self.install_dir = Utils.normalize_path( install_dir) if install_dir is not None else None # Keep track of the hsdev version early. Needed to patch command line arguments later. self.version = HsDevBackend.hsdev_version(self.exec_with, self.install_dir) self.drain_stdout = None self.drain_stderr = None # Connection params self.port = port self.hostname = host self.local_base_dir = local_base_dir self.remote_base_dir = remote_base_dir if self.is_local_hsdev: self.hostname = self.HSDEV_DEFAULT_HOST self.client = None
def __init__(self, backend_mgr, local=True, port=HSDEV_DEFAULT_PORT, host=HSDEV_DEFAULT_HOST, **kwargs): super().__init__(backend_mgr) Logging.log('{0}.__init__({1}, {2})'.format(type(self).__name__, host, port), Logging.LOG_INFO) # Sanity checking: exec_with = kwargs.get('exec-with') install_dir = kwargs.get('install-dir') if bool(exec_with) ^ bool(install_dir): if install_dir is None: sublime.error_message('\n'.join(['\'exec_with\' requires an \'install_dir\'.', '', 'Please check your \'backends\' configuration and retry.'])) raise RuntimeError('\'exec_with\' requires an \'install_dir\'.') else: sublime.error_message('\n'.join(['\'install_dir\' requires an \'exec_with\'.', '', 'Please check your \'backends\' configuration and retry.'])) raise RuntimeError('\'install_dir\' requires an \'exec_with\'.') elif exec_with and exec_with not in ['stack', 'cabal', 'cabal-new-build']: sublime.error_message('\n'.join(['Invalid backend \'exec_with\': {0}'.format(exec_with), '', 'Valid values are "cabal", "cabal-new-build" or "stack".', 'Please check your \'backends\' configuration and retry.'])) raise RuntimeError('Invalid backend \'exec_with\': {0}'.format(exec_with)) # Local hsdev server process and params self.is_local_hsdev = local self.hsdev_process = None self.cache = os.path.join(Common.sublime_haskell_cache_path(), 'hsdev') self.log_file = os.path.join(Common.sublime_haskell_cache_path(), 'hsdev', 'hsdev.log') self.exec_with = exec_with self.install_dir = Utils.normalize_path(install_dir) if install_dir is not None else None # Keep track of the hsdev version early. Needed to patch command line arguments later. self.version = HsDevBackend.hsdev_version(self.exec_with, self.install_dir) self.drain_stdout = None self.drain_stderr = None # Connection params self.port = port self.hostname = host if self.is_local_hsdev: self.hostname = self.HSDEV_DEFAULT_HOST self.client = None self.serial_lock = threading.RLock() self.request_serial = 1
def plugin_loaded(): '''All of the good stuff that happens when SublimeHaskell is loaded. ''' cache_path = Common.sublime_haskell_cache_path() backend_mgr = BackendManager.BackendManager() if not os.path.exists(cache_path): os.makedirs(cache_path) # Probably already loaded... doesn't hurt to reload. Refresh the backend manager's list of backends, while we're at it. Settings.load_settings() backend_mgr.get_backends() # Register change detection: Settings.PLUGIN.add_change_callback('add_to_PATH', ProcHelper.ProcHelper.update_environment) Settings.PLUGIN.add_change_callback('add_standard_dirs', ProcHelper.ProcHelper.update_environment) Settings.PLUGIN.add_change_callback('backends', backend_mgr.updated_settings)
def plugin_loaded(): cache_path = Common.sublime_haskell_cache_path() if not os.path.exists(cache_path): os.makedirs(cache_path) # Probably already loaded... doesn't hurt to reload. Settings.PLUGIN.load() # Register change detection: Settings.PLUGIN.add_change_callback( 'add_to_PATH', ProcHelper.ProcHelper.update_environment) Settings.PLUGIN.add_change_callback( 'add_standard_dirs', ProcHelper.ProcHelper.update_environment) # Deprecate? HDevTools.start_hdevtools()
def __init__(self, port): super().__init__("localhost", port) self.hsdev_process = HsDevProcess(cache=os.path.join(Common.sublime_haskell_cache_path(), 'hsdev'), log_file=os.path.join(Common.sublime_haskell_cache_path(), 'hsdev', 'hsdev.log'), log_config=Settings.PLUGIN.hsdev_log_config)