-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20d6ee5
commit 3bd3e96
Showing
4 changed files
with
158 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ config/config.py | |
/data | ||
/venv | ||
*png | ||
*.gz | ||
code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"/root/code_Bao/stock_price_4_fun/notebook\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import os\n", | ||
"try:\n", | ||
" print(file_path)\n", | ||
"except:\n", | ||
" file_path = os.path.abspath('')\n", | ||
" os.chdir(os.path.dirname(file_path))\n", | ||
" print(file_path)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import subprocess" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"*\n", | ||
"* Visual Studio Code Server\n", | ||
"*\n", | ||
"* By using the software, you agree to\n", | ||
"* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and\n", | ||
"* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).\n", | ||
"*\n", | ||
"\n", | ||
"Open this link in your browser https://vscode.dev/tunnel/bao_msi/root/code_Bao/stock_price_4_fun\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"ename": "KeyboardInterrupt", | ||
"evalue": "", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", | ||
"\u001b[1;32m/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb Cell 3\u001b[0m line \u001b[0;36m8\n\u001b[1;32m <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=3'>4</a>\u001b[0m command \u001b[39m=\u001b[39m [\u001b[39m'\u001b[39m\u001b[39m./code\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mtunnel\u001b[39m\u001b[39m'\u001b[39m]\n\u001b[1;32m <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a>\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=6'>7</a>\u001b[0m \u001b[39m# Run the command\u001b[39;00m\n\u001b[0;32m----> <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a>\u001b[0m result \u001b[39m=\u001b[39m subprocess\u001b[39m.\u001b[39;49mrun(command, check\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m, text\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m)\n\u001b[1;32m <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8'>9</a>\u001b[0m \u001b[39m# tunnel_output = result.stdout.strip()\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=9'>10</a>\u001b[0m \u001b[39m# print ('tunnel_output', tunnel_output)\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=10'>11</a>\u001b[0m \u001b[39m# # Parse the output to extract the vscode.dev URL\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=16'>17</a>\u001b[0m \n\u001b[1;32m <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=17'>18</a>\u001b[0m \u001b[39m# Display success message\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://wsl%2Bubuntu/root/code_Bao/stock_price_4_fun/notebook/remote_tunnel.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=18'>19</a>\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39mCommand executed successfully.\u001b[39m\u001b[39m\"\u001b[39m)\n", | ||
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:505\u001b[0m, in \u001b[0;36mrun\u001b[0;34m(input, capture_output, timeout, check, *popenargs, **kwargs)\u001b[0m\n\u001b[1;32m 503\u001b[0m \u001b[39mwith\u001b[39;00m Popen(\u001b[39m*\u001b[39mpopenargs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs) \u001b[39mas\u001b[39;00m process:\n\u001b[1;32m 504\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 505\u001b[0m stdout, stderr \u001b[39m=\u001b[39m process\u001b[39m.\u001b[39;49mcommunicate(\u001b[39minput\u001b[39;49m, timeout\u001b[39m=\u001b[39;49mtimeout)\n\u001b[1;32m 506\u001b[0m \u001b[39mexcept\u001b[39;00m TimeoutExpired \u001b[39mas\u001b[39;00m exc:\n\u001b[1;32m 507\u001b[0m process\u001b[39m.\u001b[39mkill()\n", | ||
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:1146\u001b[0m, in \u001b[0;36mPopen.communicate\u001b[0;34m(self, input, timeout)\u001b[0m\n\u001b[1;32m 1144\u001b[0m stderr \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstderr\u001b[39m.\u001b[39mread()\n\u001b[1;32m 1145\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstderr\u001b[39m.\u001b[39mclose()\n\u001b[0;32m-> 1146\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mwait()\n\u001b[1;32m 1147\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 1148\u001b[0m \u001b[39mif\u001b[39;00m timeout \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n", | ||
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:1209\u001b[0m, in \u001b[0;36mPopen.wait\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 1207\u001b[0m endtime \u001b[39m=\u001b[39m _time() \u001b[39m+\u001b[39m timeout\n\u001b[1;32m 1208\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m-> 1209\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_wait(timeout\u001b[39m=\u001b[39;49mtimeout)\n\u001b[1;32m 1210\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mKeyboardInterrupt\u001b[39;00m:\n\u001b[1;32m 1211\u001b[0m \u001b[39m# https://bugs.python.org/issue25942\u001b[39;00m\n\u001b[1;32m 1212\u001b[0m \u001b[39m# The first keyboard interrupt waits briefly for the child to\u001b[39;00m\n\u001b[1;32m 1213\u001b[0m \u001b[39m# exit under the common assumption that it also received the ^C\u001b[39;00m\n\u001b[1;32m 1214\u001b[0m \u001b[39m# generated SIGINT and will exit rapidly.\u001b[39;00m\n\u001b[1;32m 1215\u001b[0m \u001b[39mif\u001b[39;00m timeout \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n", | ||
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:1959\u001b[0m, in \u001b[0;36mPopen._wait\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 1957\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mreturncode \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 1958\u001b[0m \u001b[39mbreak\u001b[39;00m \u001b[39m# Another thread waited.\u001b[39;00m\n\u001b[0;32m-> 1959\u001b[0m (pid, sts) \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_try_wait(\u001b[39m0\u001b[39;49m)\n\u001b[1;32m 1960\u001b[0m \u001b[39m# Check the pid and loop as waitpid has been known to\u001b[39;00m\n\u001b[1;32m 1961\u001b[0m \u001b[39m# return 0 even without WNOHANG in odd situations.\u001b[39;00m\n\u001b[1;32m 1962\u001b[0m \u001b[39m# http://bugs.python.org/issue14396.\u001b[39;00m\n\u001b[1;32m 1963\u001b[0m \u001b[39mif\u001b[39;00m pid \u001b[39m==\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mpid:\n", | ||
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:1917\u001b[0m, in \u001b[0;36mPopen._try_wait\u001b[0;34m(self, wait_flags)\u001b[0m\n\u001b[1;32m 1915\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"All callers to this function MUST hold self._waitpid_lock.\"\"\"\u001b[39;00m\n\u001b[1;32m 1916\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m-> 1917\u001b[0m (pid, sts) \u001b[39m=\u001b[39m os\u001b[39m.\u001b[39;49mwaitpid(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mpid, wait_flags)\n\u001b[1;32m 1918\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mChildProcessError\u001b[39;00m:\n\u001b[1;32m 1919\u001b[0m \u001b[39m# This happens if SIGCLD is set to be ignored or waiting\u001b[39;00m\n\u001b[1;32m 1920\u001b[0m \u001b[39m# for child processes has otherwise been disabled for our\u001b[39;00m\n\u001b[1;32m 1921\u001b[0m \u001b[39m# process. This child is dead, we can't get the status.\u001b[39;00m\n\u001b[1;32m 1922\u001b[0m pid \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mpid\n", | ||
"\u001b[0;31mKeyboardInterrupt\u001b[0m: " | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import subprocess\n", | ||
"\n", | ||
"# Define the command\n", | ||
"command = ['./code', 'tunnel']\n", | ||
"\n", | ||
"try:\n", | ||
" # Run the command\n", | ||
" result = subprocess.run(command, check=True, text=True)\n", | ||
" # tunnel_output = result.stdout.strip()\n", | ||
" # print ('tunnel_output', tunnel_output)\n", | ||
" # # Parse the output to extract the vscode.dev URL\n", | ||
" # url_start = tunnel_output.find('https://vscode.dev/tunnel/')\n", | ||
" # print ('url_start', url_start)\n", | ||
"\n", | ||
" # vscode_url = tunnel_output[url_start:]\n", | ||
" # print ('vscode_url', vscode_url)\n", | ||
"\n", | ||
" # Display success message\n", | ||
" print(\"Command executed successfully.\")\n", | ||
"\n", | ||
" # Display command output (if any)\n", | ||
" if result.stdout:\n", | ||
" print(\"Command output:\")\n", | ||
" print(result.stdout)\n", | ||
"\n", | ||
"except subprocess.CalledProcessError as e:\n", | ||
" # Handle errors\n", | ||
" print(f\"Error: {e}\")\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters