mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
add to parameter to decide whether to print the command (#11052)
* don't print command * show password as ******
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"import pandas,sys,os,getpass,json,html,time\n",
|
||||
"from string import Template\n",
|
||||
"pandas_version = pandas.__version__.split('.')\n",
|
||||
"pandas_major = int(pandas_version[0])\n",
|
||||
"pandas_minor = int(pandas_version[1])\n",
|
||||
@@ -56,18 +57,21 @@
|
||||
"if not (pandas_major > 0 or (pandas_major == 0 and pandas_minor > 24) or (pandas_major == 0 and pandas_minor == 24 and pandas_patch >= 2)):\n",
|
||||
" sys.exit('Please upgrade the Notebook dependency before you can proceed, you can do it by running the \"Reinstall Notebook dependencies\" command in command palette (View menu -> Command Palette…).')\n",
|
||||
"\n",
|
||||
"def run_command():\n",
|
||||
" print(\"Executing: \" + cmd)\n",
|
||||
"def run_command(displayCommand = \"\"):\n",
|
||||
" print(\"Executing: \" + displayCommand if displayCommand != \"\" else cmd)\n",
|
||||
" !{cmd}\n",
|
||||
" if _exit_code != 0:\n",
|
||||
" sys.exit(f'Command execution failed with exit code: {str(_exit_code)}.\\n\\t{cmd}\\n')\n",
|
||||
" print(f'Successfully executed: {cmd}')\n",
|
||||
" sys.exit(f'Command execution failed with exit code: {str(_exit_code)}.\\n')\n",
|
||||
" print(f'Command successfully executed')\n",
|
||||
"\n",
|
||||
"cmd = 'docker version'\n",
|
||||
"run_command()"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "6196300e-f896-489b-8dca-b2c42eda2d6d"
|
||||
"azdata_cell_guid": "6196300e-f896-489b-8dca-b2c42eda2d6d",
|
||||
"tags": [
|
||||
"hide_input"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
@@ -89,7 +93,10 @@
|
||||
"run_command()"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "26170d1b-4332-4383-bcc4-1d97030daffc"
|
||||
"azdata_cell_guid": "26170d1b-4332-4383-bcc4-1d97030daffc",
|
||||
"tags": [
|
||||
"hide_input"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
@@ -123,7 +130,10 @@
|
||||
"print(f'Port: {sql_port}')"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "93cb0147-7bf6-4630-b796-3811dfd1354b"
|
||||
"azdata_cell_guid": "93cb0147-7bf6-4630-b796-3811dfd1354b",
|
||||
"tags": [
|
||||
"hide_input"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
@@ -144,7 +154,10 @@
|
||||
"run_command()"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "7b102447-3198-488f-a995-982ae1fc8555"
|
||||
"azdata_cell_guid": "7b102447-3198-488f-a995-982ae1fc8555",
|
||||
"tags": [
|
||||
"hide_input"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
@@ -166,11 +179,16 @@
|
||||
"else:\n",
|
||||
" container_name = 'sql2019-' + time.strftime(\"%Y%m%d%H%M%S\", time.localtime())\n",
|
||||
"print('New container name: ' + container_name)\n",
|
||||
"cmd = f'docker run -e ACCEPT_EULA=Y -e \"SA_PASSWORD={sql_password}\" -p {sql_port}:1433 --name {container_name} -d mcr.microsoft.com/mssql/server:2019-latest'\n",
|
||||
"run_command()"
|
||||
"\n",
|
||||
"template = Template(f'docker run -e ACCEPT_EULA=Y -e \"SA_PASSWORD=$password\" -p {sql_port}:1433 --name {container_name} -d mcr.microsoft.com/mssql/server:2019-latest')\n",
|
||||
"cmd = template.substitute(password=sql_password)\n",
|
||||
"run_command(template.substitute(password='******'))"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "82f27460-88eb-4484-92ee-40305e650d70"
|
||||
"azdata_cell_guid": "82f27460-88eb-4484-92ee-40305e650d70",
|
||||
"tags": [
|
||||
"hide_input"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
@@ -191,7 +209,10 @@
|
||||
"run_command()"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "211ee198-f1d1-4781-9daa-8497c2665de6"
|
||||
"azdata_cell_guid": "211ee198-f1d1-4781-9daa-8497c2665de6",
|
||||
"tags": [
|
||||
"hide_input"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
@@ -214,7 +235,10 @@
|
||||
"display(HTML('<br/><a href=\"command:azdata.connect?' + html.escape(connectionParameter)+'\"><font size=\"3\">Click here to connect to SQL Server</font></a><br/>'))"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "4bc64915-c5ae-4507-8fb0-9e413ccc2fd0"
|
||||
"azdata_cell_guid": "4bc64915-c5ae-4507-8fb0-9e413ccc2fd0",
|
||||
"tags": [
|
||||
"hide_input"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
@@ -238,7 +262,10 @@
|
||||
"display(HTML(\"Remove the container: <a href=\\\"command:workbench.action.terminal.sendSequence?%7B%22text%22%3A%22\"+remove_container_command.replace(\" \",\"%20\")+\"%22%7D\\\">\" + remove_container_command + \"</a>\"))"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "f9e0f1ad-ba6e-4c17-84ea-cc5dceb1289b"
|
||||
"azdata_cell_guid": "f9e0f1ad-ba6e-4c17-84ea-cc5dceb1289b",
|
||||
"tags": [
|
||||
"hide_input"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
|
||||
Reference in New Issue
Block a user