def run_nimcheck(file_path, callback, verbosity=2): # Prepare the regex's run_process( (configuration.nim_executable, 'check', '--verbosity:2', file_path), callback, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, )
def run(self): this = yield window = sublime.active_window() view = window.active_view() # Setup the loading notice frames = ['Updating Nimble package list' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the main command process, stdout, _, error = yield run_process( (configuration.nimble_exe, '-y', 'update'), callback=this.send, timeout=self.timeout, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) yield stop_status_loop(get_next_method(this)) # Handle possible errors if handle_process_error(error, 'Nimble Update Failed', 'Nimble'): yield # Write output self.write_to_output(stdout, window, view) if process.poll() == 0: sublime.status_message('Nimble Package List Updated') else: sublime.status_message('Nimble Update Failed') yield
def run(self): this = yield window = sublime.active_window() view = window.active_view() # Setup the loading notice frames = ['Updating Nimble package list' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the main command process, stdout, _, error = yield run_process( (configuration.nimble_exe, '-y', 'update'), callback=this.send, timeout=self.timeout, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) yield stop_status_loop(get_next_method(this)) # Handle possible errors if handle_process_error(error, 'Nimble Update Failed', 'Nimble'): yield # Write output self.write_to_output(stdout, window, view) if process.poll() == 0: sublime.status_message('Nimble Package List Updated') else: sublime.status_message('Nimble Update Failed') yield
def run_nimcheck(file_path, callback, verbosity=2): """ Run the Nim compiler in 'check' mode. :type file_path: str :type callback: (tuple) -> None :type verbosity: int :rtype: Any """ # Prepare the regex's verbosity_str = '--verbosity:' + str(verbosity) return run_process( (configuration.nim_exe, 'check', verbosity_str, file_path), callback, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, )
def run(self): this = yield window = sublime.active_window() view = window.active_view() # Get user input search_term = yield window.show_input_panel( 'Package Search Term?', '', this.send, None, None ) # Setup the loading notice frames = ['Searching Package List' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the main command process, stdout, _, error = yield run_process( (configuration.nimble_exe, '-y', 'search', search_term), callback=this.send, timeout=self.timeout, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) yield stop_status_loop(get_next_method(this)) # Handle errors if handle_process_error(error, 'Nimble Search Failed', 'Nimble'): yield # List output if self.send_to_quickpanel: items = [] packages = parse_package_descriptions(stdout) for package in packages: items.append([ package['name'], package.get('description', ''), package.get('url', '') ]) window.show_quick_panel(items, None) # Show output self.write_to_output(stdout, window, view) if process.poll() == 0: sublime.status_message('Listing Nimble Packages') else: sublime.status_message('Nimble Package List Retrieval Failed') yield
def run(self): this = yield window = sublime.active_window() view = window.active_view() # Get user input search_term = yield window.show_input_panel('Package Search Term?', '', this.send, None, None) # Setup the loading notice frames = ['Searching Package List' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the main command process, stdout, _, error = yield run_process( (configuration.nimble_exe, '-y', 'search', search_term), callback=this.send, timeout=self.timeout, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) yield stop_status_loop(get_next_method(this)) # Handle errors if handle_process_error(error, 'Nimble Search Failed', 'Nimble'): yield # List output if self.send_to_quickpanel: items = [] packages = parse_package_descriptions(stdout) for package in packages: items.append([ package['name'], package.get('description', ''), package.get('url', '') ]) window.show_quick_panel(items, None) # Show output self.write_to_output(stdout, window, view) if process.poll() == 0: sublime.status_message('Listing Nimble Packages') else: sublime.status_message('Nimble Package List Retrieval Failed') yield
def run(self): this = yield window = sublime.active_window() # Retrieve and check the destination path for the Nimsuggest executable exe_output_dir = yield window.show_input_panel( 'Path to copy nimsuggest to? (Blank for home directory)', '', this.send, None, None ) exe_output_dir = exe_output_dir or os.path.expanduser('~') debug_print('exe_dir: ', exe_output_dir) if not (os.path.exists(exe_output_dir) or not os.path.isdir( exe_output_dir)): sublime.error_message('Invalid path for nimsuggest executable.') yield # Signal that we are compiling Nimsuggest frames = ['Compiling Internal Nimsuggest' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Generate the paths needed to extract and compile Nimsuggest temp_dir = mkdtemp() nimsuggest_source_dir = os.path.join(temp_dir, 'nimsuggest') nimlime_dir = os.path.dirname(NimLime.__file__) exe_output_file = os.path.join(exe_output_dir, 'nimsuggest') if configuration.on_windows: exe_output_file += '.exe' debug_print('temp_dir: ', temp_dir) debug_print('nimlime_dir: ', nimlime_dir) debug_print('exe_output_file: ', exe_output_file) # Extract the Nimsuggest source if configuration.is_zipped: # We're in a zipped package, so we need to extract the tarball # from our package file, then extract the tarball debug_print('Extracting nimsuggest tarball to temp_dir') ZipFile(nimlime_dir).extractall(temp_dir) else: # We're an actual directory, so we just need to copy the source # tree to the temp directory. debug_print('Copying nimsuggest source to', temp_dir) copytree( os.path.join(nimlime_dir, 'nimsuggest'), nimsuggest_source_dir ) # Compile the nimsuggest source debug_print('Compiling with Nim exe: ', configuration.nim_exe) process, stdout, _, error = yield run_process( [configuration.nim_exe, 'c', '--out:' + exe_output_file, '-d:release', 'nimsuggest.nim'], cwd=nimsuggest_source_dir, callback=this.send, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) yield stop_status_loop(get_next_method(this)) # Handle possible errors if handle_process_error(error, 'Nimsuggest setup failed', 'Nim'): yield elif process.poll() != 0: sublime.error_message(setup_error_msg) debug_print('Compilation unsuccessful.') print(stdout) yield # Tell the user the process was successful, and remind them # to set the nimsuggest settings. sublime.status_message('Nimsuggest compiled and copied.') sublime.run_command('open_file', { 'file': '${packages}/User/NimLime/NimLime.sublime-settings' }) sublime.message_dialog( 'Please make sure to set the \'nimsuggest.executable\' setting!' ) start_file(exe_output_dir) yield
def run(self): this = yield window = sublime.active_window() view = window.active_view() # Setup the loading notice frames = ['Loading package list' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the search/list command process, stdout, stderr, error = yield run_process( [configuration.nimble_exe, '-y', 'list', '-i'], this.send, self.timeout ) yield stop_status_loop(get_next_method(this)) # Handle errors if handle_process_error(error, 'Nimble Package Uninstall Failed', 'Nimble'): yield elif process.poll() != 0: sublime.status_message('Nimble Installed Package Listing Failed') yield # Parse the package descriptions packages = parse_package_descriptions(stdout) if len(packages) == 0: sublime.status_message('No Installed Packages Found') yield items = [] for package in packages: items.append([ package['name'], package.get('description', ''), package.get('url', '') ]) # Display packages and retrieve the selection selection = yield window.show_quick_panel(items, this.send) if selection == -1: yield target_name = items[selection][0] # Setup the loading notice frames = ['Uninstalling Package' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the install command process, stdout, stderr, error = yield run_process( [configuration.nimble_exe, '-y', 'uninstall', target_name], this.send, self.timeout ) yield stop_status_loop(get_next_method(this)) # Handle errors if handle_process_error(error, 'Nimble Package Uninstallation Failed', 'Nimble'): yield # Write output self.write_to_output(stdout, window, view) if process.poll() == 0: sublime.status_message('Uninstalled Nimble Package') else: sublime.status_message( 'Nimble Package Uninstallation Failed') yield
def run(self): this = yield window = sublime.active_window() view = window.active_view() if self.preemptive_search: # Get user input search_term = yield window.show_input_panel( 'Package to install?', '', this.send, None, None ) loading_notice = 'Searching Package List' process_args = ( configuration.nimble_exe, '-y', 'search', escape_shell(search_term) ) else: loading_notice = 'Loading Package List' process_args = (configuration.nimble_exe, '-y', 'list ') # Setup the loading notice frames = [loading_notice + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the search/list command process, stdout, _, error = yield run_process( process_args, callback=this.send, timeout=self.timeout ) stop_status_loop(get_next_method(this)) # Handle errors if handle_process_error(error, 'Loading Nimble Packages Failed', 'Nimble'): yield if process.poll() != 0: sublime.status_message('Nimble Package Load Failed') yield # Parse the package list items = [] packages = parse_package_descriptions(stdout) if len(packages) == 0: sublime.status_message('No Matching Packages Found') yield # Display the list and get the selected package. for package in packages: items.append([ package['name'], package.get('description', ''), package.get('url', '') ]) selection = yield window.show_quick_panel(items, this.send) if selection == -1: yield target_name = items[selection][0] # Setup the loading notice frames = ['Installing Package' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the install command process, stdout, _, error = yield run_process( [configuration.nimble_exe, '-y', 'install', escape_shell(target_name)], this.send, self.timeout ) yield stop_status_loop(get_next_method(this)) if handle_process_error(error, 'Nimble Package Install Failed', 'Nimble'): yield self.write_to_output(stdout, window, view) if process.poll() == 0: sublime.status_message('Installed Nimble Package') else: sublime.status_message('Nimble Package Installation Failed') yield
def run(self): this = yield window = sublime.active_window() view = window.active_view() # Setup the loading notice frames = ['Loading package list' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the search/list command process, stdout, stderr, error = yield run_process( [configuration.nimble_exe, '-y', 'list', '-i'], this.send, self.timeout) yield stop_status_loop(get_next_method(this)) # Handle errors if handle_process_error(error, 'Nimble Package Uninstall Failed', 'Nimble'): yield elif process.poll() != 0: sublime.status_message('Nimble Installed Package Listing Failed') yield # Parse the package descriptions packages = parse_package_descriptions(stdout) if len(packages) == 0: sublime.status_message('No Installed Packages Found') yield items = [] for package in packages: items.append([ package['name'], package.get('description', ''), package.get('url', '') ]) # Display packages and retrieve the selection selection = yield window.show_quick_panel(items, this.send) if selection == -1: yield target_name = items[selection][0] # Setup the loading notice frames = ['Uninstalling Package' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the install command process, stdout, stderr, error = yield run_process( [configuration.nimble_exe, '-y', 'uninstall', target_name], this.send, self.timeout) yield stop_status_loop(get_next_method(this)) # Handle errors if handle_process_error(error, 'Nimble Package Uninstallation Failed', 'Nimble'): yield # Write output self.write_to_output(stdout, window, view) if process.poll() == 0: sublime.status_message('Uninstalled Nimble Package') else: sublime.status_message('Nimble Package Uninstallation Failed') yield
def run(self): this = yield window = sublime.active_window() view = window.active_view() if self.preemptive_search: # Get user input search_term = yield window.show_input_panel( 'Package to install?', '', this.send, None, None) loading_notice = 'Searching Package List' process_args = (configuration.nimble_exe, '-y', 'search', escape_shell(search_term)) else: loading_notice = 'Loading Package List' process_args = (configuration.nimble_exe, '-y', 'list ') # Setup the loading notice frames = [loading_notice + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the search/list command process, stdout, _, error = yield run_process(process_args, callback=this.send, timeout=self.timeout) stop_status_loop(get_next_method(this)) # Handle errors if handle_process_error(error, 'Loading Nimble Packages Failed', 'Nimble'): yield if process.poll() != 0: sublime.status_message('Nimble Package Load Failed') yield # Parse the package list items = [] packages = parse_package_descriptions(stdout) if len(packages) == 0: sublime.status_message('No Matching Packages Found') yield # Display the list and get the selected package. for package in packages: items.append([ package['name'], package.get('description', ''), package.get('url', '') ]) selection = yield window.show_quick_panel(items, this.send) if selection == -1: yield target_name = items[selection][0] # Setup the loading notice frames = ['Installing Package' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the install command process, stdout, _, error = yield run_process([ configuration.nimble_exe, '-y', 'install', escape_shell(target_name) ], this.send, self.timeout) yield stop_status_loop(get_next_method(this)) if handle_process_error(error, 'Nimble Package Install Failed', 'Nimble'): yield self.write_to_output(stdout, window, view) if process.poll() == 0: sublime.status_message('Installed Nimble Package') else: sublime.status_message('Nimble Package Installation Failed') yield
def run_nimble(cmd, callback, timeout): run_process( cmd, callback, timeout, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
def run(self): window = sublime.active_window() view = window.active_view() this = yield # Setup the loading notice frames = ['Loading package list' + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the search/list command process, output, errors = run_process( [configuration.nimble_executable, '-y', 'list', '-i'], this.send, self.timeout ) return_code = process.poll() # Set the status to show we've finished searching yield stop_status_loop(get_next_method(this)) if return_code != 0: sublime.status_message( "Nimble Installed Package Listing Failed") else: items = [] packages = parse_package_descriptions(output) if len(packages) == 0: sublime.status_message("No Installed Packages Found") else: for package in packages: items.append([ package['name'], package.get('description', ''), package.get('url', '') ]) selection = yield window.show_quick_panel(items, this.send) if selection != -1: target_name = items[selection][0] # Setup the loading notice loading_notice = "Uninstalling package" frames = [loading_notice + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the install command process, output, errors = run_process( [configuration.nimble_executable, '-y', 'uninstall'], this.send, self.timeout ) return_code = process.poll() yield stop_status_loop(get_next_method(this)) self.write_to_output(output, window, view) if return_code == 0: sublime.status_message( "Uninstalled Nimble Package") else: sublime.status_message( 'Nimble Package Uninstallation Failed' ) yield
def run(self): this = yield window = sublime.active_window() view = window.active_view() if self.preemptive_search: # Get user input search_term = yield window.show_input_panel( "Package to install?", '', this.send, None, None ) loading_notice = 'Searching package list' process_args = ( configuration.nimble_executable, '-y', 'search', escape_shell(search_term) ) else: loading_notice = 'Loading package list' process_args = (configuration.nimble_executable, '-y', 'list ') # Setup the loading notice frames = [loading_notice + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the search/list command process, output, errors = run_process( process_args, this.send, self.timeout ) return_code = process.poll() # Set the status to show we've finished searching yield stop_status_loop(get_next_method(this)) if return_code != 0: sublime.status_message("Nimble Package Load Failed") else: items = [] packages = parse_package_descriptions(output) if len(packages) == 0: sublime.status_message("No Matching Packages Found") else: for package in packages: items.append([ package['name'], package.get('description', ''), package.get('url', '') ]) selection = yield window.show_quick_panel(items, this.send) if selection != -1: target_name = items[selection][0] # Setup the loading notice loading_notice = "Installing package" frames = [loading_notice + f for f in busy_frames] stop_status_loop = loop_status_msg(frames, 0.15) # Run the install command process, output, errors = run_process( [configuration.nimble_executable, '-y', 'install', escape_shell(target_name)], this.send, self.timeout ) # Stop the status notice yield stop_status_loop(get_next_method(this)) self.write_to_output(output, window, view) if return_code == 0: sublime.status_message("Installed Nimble Package") else: sublime.status_message( 'Nimble Package Installation Failed' ) yield