Skip to content

Commit

Permalink
Fix telemetry not getting picked up for Terminal REPL (microsoft#23958)
Browse files Browse the repository at this point in the history
microsoft#23941 
Having no blank spaces in front of plain 'python' or 'python3' were
returning falsey value.
  • Loading branch information
anthonykim1 authored Aug 16, 2024
1 parent 59a8d03 commit e9f1071
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
95 changes: 48 additions & 47 deletions python_files/Notebooks intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"1. Open the command palette with the shortcut: `Ctrl/Command` + `Shift` + `P`\r\n",
"1. Open the command palette with the shortcut: `Ctrl/Command` + `Shift` + `P`\n",
"2. Search for the command `Create New Blank Notebook`"
]
},
Expand All @@ -26,8 +26,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"1. Open the command palette with the shortcut: `Ctrl/Command` + `Shift` + `P`\r\n",
"\r\n",
"1. Open the command palette with the shortcut: `Ctrl/Command` + `Shift` + `P`\n",
"\n",
"2. Search for the command `Python: Open Start Page`"
]
},
Expand All @@ -42,10 +42,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You are currently viewing what we call our Notebook Editor. It is an interactive document based on Jupyter Notebooks that supports the intermixing of code, outputs and markdown documentation. \r\n",
"\r\n",
"This cell is a markdown cell. To edit the text in this cell, simply double click on the cell to change it into edit mode.\r\n",
"\r\n",
"You are currently viewing what we call our Notebook Editor. It is an interactive document based on Jupyter Notebooks that supports the intermixing of code, outputs and markdown documentation. \n",
"\n",
"This cell is a markdown cell. To edit the text in this cell, simply double click on the cell to change it into edit mode.\n",
"\n",
"The next cell below is a code cell. You can switch a cell between code and markdown by clicking on the code ![code icon](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/codeIcon.PNG) /markdown ![markdown icon](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/markdownIcon.PNG) icons or using the keyboard shortcut `M` and `Y` respectively."
]
},
Expand All @@ -55,16 +55,16 @@
"metadata": {},
"outputs": [],
"source": [
"print('hello world')"
"print(\"hello world\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* To execute the code in the cell above, click on the cell to select it and then either press the play ![play](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/playIcon.PNG) button in the cell toolbar, or use the keyboard shortcut `Ctrl/Command` + `Enter`.\r\n",
"* To edit the code, just click in cell and start editing.\r\n",
"* To add a new cell below, click the `Add Cell` icon ![add cell](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/addIcon.PNG) at the bottom left of the cell or enter command mode with the `ESC` Key and then use the keyboard shortcut `B` to create the new cell below.\r\n"
"* To execute the code in the cell above, click on the cell to select it and then either press the play ![play](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/playIcon.PNG) button in the cell toolbar, or use the keyboard shortcut `Ctrl/Command` + `Enter`.\n",
"* To edit the code, just click in cell and start editing.\n",
"* To add a new cell below, click the `Add Cell` icon ![add cell](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/addIcon.PNG) at the bottom left of the cell or enter command mode with the `ESC` Key and then use the keyboard shortcut `B` to create the new cell below.\n"
]
},
{
Expand All @@ -78,40 +78,40 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**Variable explorer**\r\n",
"\r\n",
"To view all your active variables and their current values in the notebook, click on the variable explorer icon ![variable explorer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/variableExplorerIcon.PNG) in the top toolbar.\r\n",
"\r\n",
"![Variable Explorer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/variableexplorer.png)\r\n",
"\r\n",
"**Data Viewer**\r\n",
"\r\n",
"To view your data frame in a more visual \"Excel\" like format, open the variable explorer and to the left of any dataframe object, you will see the data viewer icon ![data viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/dataViewerIcon.PNG) which you can click to open the data viewer.\r\n",
"\r\n",
"![Data Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/dataviewer.gif)\r\n",
"\r\n",
"**Convert to Python File**\r\n",
"\r\n",
"To export your notebook to a Python file (.py), click on the `Convert to Python script` icon ![Export icon](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/exportIcon.PNG) in the top toolbar \r\n",
"\r\n",
"![Export](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/savetopythonfile.png)\r\n",
"\r\n",
"**Plot Viewer**\r\n",
"\r\n",
"If you have a graph (such as matplotlib) in your output, you'll notice if you hover over the graph, the `Plot Viewer` icon ![Plot Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/plotViewerIcon.PNG) will appear in the top left. Click the icon to open up the graph in the Plotviewer which allows you to zoom on your plots and export it in formats such as png and jpeg.\r\n",
"\r\n",
"![Plot Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/plotviewer.gif)\r\n",
"\r\n",
"**Switching Kernels**\r\n",
"\r\n",
"The notebook editor will detect all kernels in your system by default. To change your notebook kernel, click on the kernel status in the top toolbar at the far right. For example, your kernel status may say \"Python 3: Idle\". This will open up the kernel selector where you can choose your desired kernel.\r\n",
"\r\n",
"![Switching Kernels](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/kernelchange.gif)\r\n",
"\r\n",
"**Remote Jupyter Server**\r\n",
"\r\n",
"To connect to a remote Jupyter server, open the command prompt and search for the command `Specify remote or local Jupyter server for connections`. Then select `Existing` and enter the remote Jupyter server URL. Afterwards, you'll be prompted to reload the window and the Notebook will be opened connected to the remote Jupyter server.\r\n",
"\r\n",
"**Variable explorer**\n",
"\n",
"To view all your active variables and their current values in the notebook, click on the variable explorer icon ![variable explorer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/variableExplorerIcon.PNG) in the top toolbar.\n",
"\n",
"![Variable Explorer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/variableexplorer.png)\n",
"\n",
"**Data Viewer**\n",
"\n",
"To view your data frame in a more visual \"Excel\" like format, open the variable explorer and to the left of any dataframe object, you will see the data viewer icon ![data viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/dataViewerIcon.PNG) which you can click to open the data viewer.\n",
"\n",
"![Data Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/dataviewer.gif)\n",
"\n",
"**Convert to Python File**\n",
"\n",
"To export your notebook to a Python file (.py), click on the `Convert to Python script` icon ![Export icon](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/exportIcon.PNG) in the top toolbar \n",
"\n",
"![Export](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/savetopythonfile.png)\n",
"\n",
"**Plot Viewer**\n",
"\n",
"If you have a graph (such as matplotlib) in your output, you'll notice if you hover over the graph, the `Plot Viewer` icon ![Plot Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/plotViewerIcon.PNG) will appear in the top left. Click the icon to open up the graph in the Plotviewer which allows you to zoom on your plots and export it in formats such as png and jpeg.\n",
"\n",
"![Plot Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/plotviewer.gif)\n",
"\n",
"**Switching Kernels**\n",
"\n",
"The notebook editor will detect all kernels in your system by default. To change your notebook kernel, click on the kernel status in the top toolbar at the far right. For example, your kernel status may say \"Python 3: Idle\". This will open up the kernel selector where you can choose your desired kernel.\n",
"\n",
"![Switching Kernels](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/kernelchange.gif)\n",
"\n",
"**Remote Jupyter Server**\n",
"\n",
"To connect to a remote Jupyter server, open the command prompt and search for the command `Specify remote or local Jupyter server for connections`. Then select `Existing` and enter the remote Jupyter server URL. Afterwards, you'll be prompted to reload the window and the Notebook will be opened connected to the remote Jupyter server.\n",
"\n",
"![Remote](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/remoteserver.gif)"
]
},
Expand All @@ -129,7 +129,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"- [Data science tutorial for Visual Studio Code](https://code.visualstudio.com/docs/python/data-science-tutorial)\r\n",
"- [Data science tutorial for Visual Studio Code](https://code.visualstudio.com/docs/python/data-science-tutorial)\n",
"- [Jupyter Notebooks in Visual Studio Code documentation](https://code.visualstudio.com/docs/python/jupyter-support)"
]
}
Expand All @@ -145,9 +145,10 @@
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.8.6-final"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
}
2 changes: 1 addition & 1 deletion src/client/terminals/codeExecution/terminalReplWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EventName } from '../../telemetry/constants';

function checkREPLCommand(command: string): boolean {
const lower = command.toLowerCase().trimStart();
return lower.startsWith('python ') || lower.startsWith('py ');
return lower.startsWith('python') || lower.startsWith('py');
}

export function registerTriggerForTerminalREPL(disposables: Disposable[]): void {
Expand Down

0 comments on commit e9f1071

Please sign in to comment.