def run(self, message): ''' @message The message that will be displayed to the user when collecting their input. ''' v = self.window.active_view() project = PubPackage.from_path(v.file_name()) if not project: _logger.debug('no pubspec.yaml found - aborting') info = ErrorPanel() info.write('Could not locate pubspec.yaml file for: {}\n' .format(v.file_name())) info.write('Cannot run Polymer command.') info.show() return if not project.has_dependency('polymer'): _logger.debug('no polymer dep found - aborting') info = ErrorPanel() info.write("Polymer isn't a dependency in this project.") info.write('Cannot run Polymer command.') info.show() return if not project.path_to_web: _logger.debug('creating web directory') project.make_top_level_dir('web') self.window.show_input_panel(message, '', self.on_done, None, None)
def get_templates(self): sdk = SDK() try: out = check_output([sdk.path_to_pub, 'global', 'run', 'stagehand', '--machine'], startupinfo=supress_window()).decode('utf-8') except CalledProcessError as e: error_panel = ErrorPanel() error_panel.write('\n') error_panel.write('Could not run Stagehand.\n') error_panel.write('\n') error_panel.write('Stagehand is a tool to help you get started with new projects.\n') error_panel.write('\n') error_panel.write('To enable Stagehand, run the following command from a terminal:\n') error_panel.write('\n') error_panel.write('$ pub global activate stagehand') error_panel.show() msg = 'Could not run stagehand:\n {0}'.format(str(e)) _logger.debug(msg) return None decoded = json.loads(out) entries = [] for tpl in decoded: entry = [tpl['name'], tpl['description'], "entrypoint: {}".format(tpl['entrypoint'])] entries.append(entry) return entries