From 8da87e598a7c878c803b9c631bf02e71f16b9fec Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 14 Sep 2020 16:53:33 +0300 Subject: [PATCH] Fixed an issue when Atom has become unresponsive // Resolve #2444 --- HISTORY.md | 8 +++-- lib/installer/python-prompt.js | 33 ++++++++++--------- .../stages/code-completion-engine.js | 2 +- lib/services/build.js | 4 +-- lib/utils.js | 2 +- package.json | 2 +- 6 files changed, 28 insertions(+), 23 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index c58ad85..58c9d72 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # Release Notes +# 2.7.2 + +* Fixed an issue when Atom has become unresponsive (issue [#2444](https://github.com/platformio/platformio-atom-ide/issues/2444)) + ## 2.7.1 (2020-06-14) * Fixed an error "ENOENT: no such file or directory, open '~/.platformio/homestate.json'" @@ -160,8 +164,8 @@ ## 2.0.0 (2018-01-23) * PlatformIO Home - - PIO Account - - Library Manager + - PIO Account + - Library Manager - Board Explorer - Platform Manager * New PlatformIO IDE Installer diff --git a/lib/installer/python-prompt.js b/lib/installer/python-prompt.js index 868c54c..f047429 100644 --- a/lib/installer/python-prompt.js +++ b/lib/installer/python-prompt.js @@ -8,9 +8,12 @@ * the root directory of this source tree. */ -import * as pioNodeHelpers from 'platformio-node-helpers'; +import * as config from '../config'; import * as utils from '../utils'; +import fs from 'fs-plus'; +import path from 'path'; + export default class PythonPrompt { @@ -19,15 +22,14 @@ export default class PythonPrompt { STATUS_CUSTOMEXE = 2; async prompt() { - let pythonExecutable = null; const selectedItem = atom.confirm({ - message: 'PlatformIO: Can not find Python 2.7 Interpreter', + message: 'PlatformIO: Can not find Python 3.5+ Interpreter', detailedMessage: 'PlatformIO Core is written in Python and depends on it. ' + - 'Please install Python 2.7 (PYTHON 3 IS NOT SUPPORTED YET) or ' + - 'if you have it, please choose a directory where "python/python.exe" program is located.', + 'Please install Python 3.5+ or ' + + 'if you have it, please choose a directory where "python3/python.exe" program is located.', buttons: [ - 'Install Python 2.7', - 'I have Python 2.7', + 'Install Python 3', + 'I have Python 3', 'Try again', 'Abort PlatformIO IDE Installation' ] @@ -39,15 +41,14 @@ export default class PythonPrompt { return { status: this.STATUS_TRY_AGAIN }; case 1: - pythonExecutable = await pioNodeHelpers.misc.getPythonExecutable( - atom.config.get('platformio-ide.useBuiltinPIOCore'), - await this.chooseCustomPythonDirs() - ); - if (pythonExecutable) { - return { - status: this.STATUS_CUSTOMEXE, - pythonExecutable - }; + for (const d in (await this.chooseCustomPythonDirs() || [])) { + const pythonExecutable = path.join(d, config.IS_WINDOWS ? 'python.exe' : 'python3'); + if (fs.isFileSync(pythonExecutable)) { + return { + status: this.STATUS_CUSTOMEXE, + pythonExecutable + }; + } } return { status: this.STATUS_TRY_AGAIN }; diff --git a/lib/installer/stages/code-completion-engine.js b/lib/installer/stages/code-completion-engine.js index 7e06929..4e8a78e 100644 --- a/lib/installer/stages/code-completion-engine.js +++ b/lib/installer/stages/code-completion-engine.js @@ -69,7 +69,7 @@ export default class CodeCompletionEngineStage extends BaseStage { async clangInstalled() { return new Promise(resolve => { - pioNodeHelpers.misc.runCommand('clang', ['--version'], code => resolve(code === 0)); + pioNodeHelpers.proc.runCommand('clang', ['--version'], code => resolve(code === 0)); }); } diff --git a/lib/services/build.js b/lib/services/build.js index 3112f22..cab54c8 100644 --- a/lib/services/build.js +++ b/lib/services/build.js @@ -14,8 +14,8 @@ import { getTerminalViews, runCmdsInTerminal } from './terminal'; import { TERMINAL_REOPEN_DELAY } from '../config'; import { debugProject } from './debugger'; -import { isPIOProject } from '../utils'; import fs from 'fs'; +import { isPIOProject } from '../utils'; export default class BuildProvider { @@ -33,7 +33,7 @@ export default class BuildProvider { async settings() { const pt = new pioNodeHelpers.project.ProjectTasks(this.projectDir, 'atom'); - return (await pt.getGenericTasks()) + return (await pt.getGeneralTasks()) .filter(task => !(task.coreTarget === 'upload' && task.args.includes('monitor'))) .map(task => { if (task.coreTarget === 'debug') { diff --git a/lib/utils.js b/lib/utils.js index 5946cce..dfc56de 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -57,7 +57,7 @@ export function runAPMCommand(args, callback, options = {}) { if (options.busyTitle) { beginBusy(options.busyTitle); } - pioNodeHelpers.misc.runCommand( + pioNodeHelpers.proc.runCommand( atom.packages.getApmPath(), ['--no-color', ...args], (code, stdout, stderr) => { diff --git a/package.json b/package.json index 39e7c9f..288ca8b 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "command-join": "^3.0.0", "etch": "^0.14.0", "fs-plus": "^3.0.1", - "platformio-node-helpers": "~7.0.1", + "platformio-node-helpers": "~7.2.0", "semver": "^6.2.0" }, "devDependencies": {