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
def start(self): _logger.debug('running through observatory: %s' % self.path) self.proc = Popen([SDK().path_to_dart, '--checked', '--observe=0', self.path], stdout=PIPE, stderr=PIPE, cwd=self.cwd, startupinfo=supress_window()) # TODO(guillermooo): add names and log these threads. AsyncStreamReader(self.proc.stdout, self.on_data).start() AsyncStreamReader(self.proc.stderr, self.on_error).start()
def start(self): _logger.debug('running through observatory: %s' % self.path) self.proc = Popen([SDK().path_to_dart, '--checked', '--observe=0', self.path], stdout=PIPE, stderr=PIPE, cwd=self.cwd, startupinfo=supress_window()) # TODO(guillermooo): add names and log these threads. AsyncStreamReader(self.proc.stdout, self.on_data).start() AsyncStreamReader(self.proc.stderr, self.on_error).start()
def run(self): analyzer_path = os.path.join(self.dartsdk_path, 'bin', 'dartanalyzer') # Clear all regions self.clear_all() if is_windows(): analyzer_path += '.bat' options = '--machine' startupinfo = supress_window() pubspec = PubspecFile.from_path(self.fileName) if not pubspec: _logger.error('no pubspec found for %s', self.fileName) print('Dart: No pubspec found for {}'.format(self.fileName)) return proc = subprocess.Popen( [analyzer_path, options, self.fileName], stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=pubspec.parent, ) try: outs, errs = proc.communicate(timeout=15) except TimeoutExpired as e: _logger.debug("error running DartLintThread: %s", e) proc.kill() outs, errs = proc.communicate() pattern = (r'^(?P<severity>\w+)\|(?P<type>\w+)\|(?P<code>\w+)\|' + r'(?P<file_name>.+)\|(?P<line>\d+)\|(?P<col>\d+)\|' + r'(?P<err_length>\d+)\|(?P<message>.+)') msg_pattern_machine = re.compile(pattern) # Don't show any panel if there are no errors. if not errs.decode('utf-8').strip(): print('No errors.') self.view.set_status('dartlint', 'Dartlint: No errors') return # Don't bother if the buffer hasn't changed since the last analysis. with g_edits_lock: if ((not self.force) and DartLint.edits[self.view.buffer_id()] == 0): return # We've got a new linter result. with g_tokens_lock: now = datetime.now() g_result_tokens[self.view.buffer_id()] = (now.minute * 60 + now.second) lines = errs.decode('utf-8').split(os.linesep) g_linter_results.put((g_result_tokens[self.view.buffer_id()], self.view.buffer_id(), lines))
def start(self, *args): try: cmd = (self.path,) + self.args + args _logger.debug('Dartium cmd: %r' % (cmd,)) Popen(cmd, startupinfo=supress_window()) except Exception as e: _logger.error('=' * 80) _logger.error('could not start Dartium') _logger.error('-' * 80) _logger.error(e) _logger.error('=' * 80)
def start(self, *args): try: cmd = (self.path, ) + self.args + args _logger.debug('Dartium cmd: %r' % (cmd, )) Popen(cmd, startupinfo=supress_window()) except Exception as e: _logger.error('=' * 80) _logger.error('could not start Dartium') _logger.error('-' * 80) _logger.error(e) _logger.error('=' * 80)
def get_templates(self): sdk = SDK() out = check_output([sdk.path_to_pub, 'global', 'run', 'stagehand', '--machine'], startupinfo=supress_window()).decode('utf-8') decoded = json.loads(out) entries = [] for tpl in decoded: entry = [tpl['name'], tpl['description'], "entrypoint: {}".format(tpl['entrypoint'])] entries.append(entry) return entries
def run(self): analyzer_path = os.path.join(self.dartsdk_path, 'bin', 'dartanalyzer') # Clear all regions self.clear_all() if is_windows(): analyzer_path += '.bat' options = '--machine' startupinfo = supress_window() pubspec = PubspecFile.from_path(self.fileName) if not pubspec: _logger.error('no pubspec found for %s', self.fileName) print('Dart: No pubspec found for {}'.format(self.fileName)) return proc = subprocess.Popen([analyzer_path, options, self.fileName], stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=pubspec.parent, ) try: outs, errs = proc.communicate(timeout=15) except TimeoutExpired as e: _logger.debug("error running DartLintThread: %s", e) proc.kill() outs, errs = proc.communicate() pattern = (r'^(?P<severity>\w+)\|(?P<type>\w+)\|(?P<code>\w+)\|' + r'(?P<file_name>.+)\|(?P<line>\d+)\|(?P<col>\d+)\|' + r'(?P<err_length>\d+)\|(?P<message>.+)') msg_pattern_machine = re.compile(pattern) # Don't show any panel if there are no errors. if not errs.decode('utf-8').strip(): print('No errors.') self.view.set_status('dartlint', 'Dartlint: No errors') return # Don't bother if the buffer hasn't changed since the last analysis. with g_edits_lock: if ((not self.force) and DartLint.edits[self.view.buffer_id()] == 0): return # We've got a new linter result. with g_tokens_lock: now = datetime.now() g_result_tokens[self.view.buffer_id()] = (now.minute * 60 + now.second) lines = errs.decode('utf-8').split(os.linesep) g_linter_results.put((g_result_tokens[self.view.buffer_id()], self.view.buffer_id(), lines))
def get_templates(self): sdk = SDK() out = check_output( [sdk.path_to_pub, 'global', 'run', 'stagehand', '--machine'], startupinfo=supress_window()).decode('utf-8') decoded = json.loads(out) entries = [] for tpl in decoded: entry = [ tpl['name'], tpl['description'], "entrypoint: {}".format(tpl['entrypoint']) ] entries.append(entry) return entries
def start(self, working_dir='.'): with PipeServer.status_lock: if self.is_running: _logger.debug( 'tried to start an already running PipeServer; aborting') return with pushd(working_dir): _logger.debug('starting PipeServer with args: %s', self.args) self.proc = Popen(self.args, stdout=PIPE, stdin=PIPE, stderr=PIPE, startupinfo=supress_window())
def start(self, working_dir='.'): with PipeServer.status_lock: if self.is_running: _logger.debug( 'tried to start an already running PipeServer; aborting') return with pushd(working_dir): _logger.debug('starting PipeServer with args: %s', self.args) self.proc = Popen(self.args, stdout=PIPE, stdin=PIPE, stderr=PIPE, startupinfo=supress_window())
def create_sublime_project(self, path): parent, leaf = os.path.split(path) data = {'folders': [{'follow_symlinks': True, 'path': '.'}]} proj_file = os.path.join(path, leaf + '.sublime-project') with open(proj_file, 'wt') as f: f.write(json.dumps(data)) try: Popen([sublime.executable_path(), proj_file], startupinfo=supress_window()) except Exception as e: _logger.debug('could not open new project with subl[.exe]') _logger.debug(e)
def start(self): _logger.debug('running pub serve...') cmd = [] if not self.is_example: cmd = [SDK().path_to_pub, 'serve', '--port=0'] else: cmd = [SDK().path_to_pub, 'serve', 'example', '--port=0'] self.proc = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=self.cwd, startupinfo=supress_window()) # TODO(guillermooo): add names and log these threads. AsyncStreamReader(self.proc.stdout, self.on_data).start() AsyncStreamReader(self.proc.stderr, self.on_error).start()
def start(self): _logger.debug('running pub serve...') cmd = [] if not self.is_example: cmd = [SDK().path_to_pub, 'serve', '--port=0'] else: cmd = [SDK().path_to_pub, 'serve', 'example', '--port=0'] self.proc = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=self.cwd, startupinfo=supress_window() ) # TODO(guillermooo): add names and log these threads. AsyncStreamReader(self.proc.stdout, self.on_data).start() AsyncStreamReader(self.proc.stderr, self.on_error).start()
def create_sublime_project(self, path): parent, leaf = os.path.split(path) data = { 'folders': [{ 'follow_symlinks': True, 'path': '.' }] } proj_file = os.path.join(path, leaf + '.sublime-project') with open(proj_file, 'wt') as f: f.write(json.dumps(data)) try: Popen([sublime.executable_path(), proj_file], startupinfo=supress_window()) except Exception as e: _logger.debug('could not open new project with subl[.exe]') _logger.debug(e)
def run(self): working_directory = os.path.dirname(self.file_name) pub_path = join(self.dartsdk_path, 'bin', 'pub') if is_windows(): pub_path += '.bat' print('pub get %s' % self.file_name) proc = subprocess.Popen([pub_path, 'get'], cwd=working_directory, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, startupinfo=supress_window()) out, errs = proc.communicate() data = out.decode('utf-8') if proc.returncode != 0: errs = errs.decode('utf-8') _logger.error("error running pub: %s\n%s", self.file_name, errs) data = 'error running pub: %s\n%s' % (self.file_name, errs) after(50, lambda: self.callback(data))
def check_version(self): return check_output([self.path_to_dart, '--version'], stderr=STDOUT, universal_newlines=True, startupinfo=supress_window())
def check_version(self): return check_output([self.path_to_dart, '--version'], stderr=STDOUT, universal_newlines=True, startupinfo=supress_window())
def check_installed(self): sdk = SDK() out = check_output([sdk.path_to_pub, 'global', 'list'], startupinfo=supress_window()) return 'stagehand' in out.decode('utf-8')