Skip to content

Commit

Permalink
Fix Popen Syscalls (#14585)
Browse files Browse the repository at this point in the history
Some of the calls in the Notebooks to clear out the configuration files
didn't really remove them.

Fixes the various Popen syscalls to remove the configurationes by
switching them over to os.system().
  • Loading branch information
mrjerryjohns authored and pull[bot] committed Feb 2, 2024
1 parent 03ed251 commit 1715570
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 109 deletions.
91 changes: 49 additions & 42 deletions docs/guides/repl/Matter - Access Control.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,48 @@
"Briefly, you can read and write the entire ACL attribute in the all-clusters-app, but Access Control isn’t yet turned on, so it won’t affect interactions. There’s almost no error checking when writing the ACL attribute (e.g. ensuring subjects match auth mode, only your fabric can be written, etc.) so exercise caution for now."
]
},
{
"cell_type": "markdown",
"id": "be8d3d64-e3d3-46b9-bbea-29aba67aee3b",
"metadata": {},
"source": [
"## Clear Persisted Storage\n",
"\n",
"Let's clear out our persisted storage (if one exists) to start from a clean slate."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "59352193-6c8f-4bda-9a3c-d84317b63c30",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[1;36m0\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import os, subprocess\n",
"\n",
"if os.path.isfile('/tmp/repl-storage.json'):\n",
" os.remove('/tmp/repl-storage.json')\n",
"\n",
"# So that the all-clusters-app won't boot with stale prior state.\n",
"os.system('rm -rf /tmp/chip_*')"
]
},
{
"cell_type": "markdown",
"id": "99ce2877",
Expand All @@ -43,7 +85,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 8,
"id": "bad327b7-c78a-4c46-b224-077fe7539ee1",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -106,16 +148,6 @@
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-01-25 16:59:51 johnsj-macbookpro1.roam.corp.google.com root[28183] CRITICAL Loading configuration from /tmp/repl-storage.json...\n",
"2022-01-25 16:59:51 johnsj-macbookpro1.roam.corp.google.com chip.DL[28183] ERROR MAC is not known, using a default.\n",
"2022-01-25 16:59:51 johnsj-macbookpro1.roam.corp.google.com chip.DL[28183] ERROR Register (kDNSServiceErr_NameConflict)\n",
"2022-01-25 16:59:51 johnsj-macbookpro1.roam.corp.google.com chip.DIS[28183] ERROR Failed to advertise unprovisioned commissionable node: ../../src/platform/Darwin/DnssdImpl.cpp:302: CHIP Error 0x000000AC: Internal error\n"
]
},
{
"data": {
"text/html": [
Expand Down Expand Up @@ -151,26 +183,6 @@
"New FabricAdmin: FabricId: 1(1)\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #af00ff; text-decoration-color: #af00ff\">Restoring FabricAdmin from storage to manage FabricId </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">2</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">, FabricIndex </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">2</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">...</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[38;5;129mRestoring FabricAdmin from storage to manage FabricId \u001b[0m\u001b[1;38;5;129m2\u001b[0m\u001b[38;5;129m, FabricIndex \u001b[0m\u001b[1;38;5;129m2\u001b[0m\u001b[38;5;129m...\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"New FabricAdmin: FabricId: 2(2)\n"
]
},
{
"data": {
"text/html": [
Expand Down Expand Up @@ -268,26 +280,22 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 9,
"id": "52ccd8c6",
"metadata": {},
"outputs": [],
"source": [
"import time, os\n",
"import subprocess\n",
"subprocess.Popen(['pkill', '-f', 'chip-all-clusters-app'])\n",
"time.sleep(1)\n",
"\n",
"# So that the all-clusters-app won't boot with stale prior state. \n",
"subprocess.Popen(['rm', '-rf', '/tmp/chip_*'])\n",
"os.system('pkill -f chip-all-clusters-app')\n",
"time.sleep(1)\n",
"\n",
"# The location of the all-clusters-app in the cloud playground is one level higher - adjust for this by testing for file presence.\n",
"if (os.path.isfile('../../../out/debug/chip-all-clusters-app')):\n",
" appPath = '../../../out/debug/chip-all-clusters-app'\n",
"else:\n",
" appPath = '../../../../out/debug/chip-all-clusters-app'\n",
" \n",
"\n",
"process = subprocess.Popen(appPath, stdout=subprocess.DEVNULL)\n",
"time.sleep(1)"
]
Expand All @@ -304,7 +312,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 10,
"id": "5e964fe3",
"metadata": {
"tags": []
Expand All @@ -314,8 +322,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"2022-01-25 16:59:54 johnsj-macbookpro1.roam.corp.google.com chip.CTL[28183] ERROR Unable to find country code, defaulting to WW\n",
"2022-01-25 16:59:54 johnsj-macbookpro1.roam.corp.google.com chip.SC[28183] ERROR The device does not support GetClock_RealTimeMS() API. This will eventually result in CASE session setup failures.\n"
"2022-01-29 16:01:43 johnsj-macbookpro1.roam.corp.google.com chip.SC[9915] ERROR The device does not support GetClock_RealTimeMS() API. This will eventually result in CASE session setup failures.\n"
]
},
{
Expand Down Expand Up @@ -364,7 +371,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 11,
"id": "058504b3",
"metadata": {},
"outputs": [
Expand Down
122 changes: 58 additions & 64 deletions docs/guides/repl/Matter - Basic Interactions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,45 @@
"This walks through the various interactions that can be initiated from the REPL towards a target using the Matter Interaction Model (IM) and Data Model (DM)."
]
},
{
"cell_type": "markdown",
"id": "d2ed9fe9-e4a7-4540-a434-8f4ee1362bc6",
"metadata": {},
"source": [
"## Clear Persisted Storage\n",
"\n",
"Let's clear out our persisted storage (if one exists) to start from a clean slate."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "06c609a5-1d5c-4ae2-85f0-39a280d1bf2c",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os, subprocess\n",
"\n",
"if os.path.isfile('/tmp/repl-storage.json'):\n",
" os.remove('/tmp/repl-storage.json')\n",
"\n",
"# So that the all-clusters-app won't boot with stale prior state.\n",
"os.system('rm -rf /tmp/chip_*')"
]
},
{
"cell_type": "markdown",
"id": "99ce2877",
Expand All @@ -35,12 +74,20 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"id": "bad327b7-c78a-4c46-b224-077fe7539ee1",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;34m[1643499271185] [10607:4156252] CHIP: [DL] _Init\u001b[0m\n",
"\u001b[0;32m[1643499271185] [10607:4156669] CHIP: [DL] Platform main loop started.\u001b[0m\n"
]
},
{
"data": {
"text/html": [
Expand Down Expand Up @@ -104,32 +151,20 @@
"name": "stderr",
"output_type": "stream",
"text": [
"2022-01-25 16:58:28 johnsj-macbookpro1.roam.corp.google.com root[27801] CRITICAL Loading configuration from /tmp/repl-storage.json...\n"
"2022-01-29 15:34:31 johnsj-macbookpro1.roam.corp.google.com root[10607] ERROR [Errno 2] No such file or directory: '/tmp/repl-storage.json'\n",
"2022-01-29 15:34:31 johnsj-macbookpro1.roam.corp.google.com root[10607] WARNING Could not load configuration from /tmp/repl-storage.json - resetting configuration...\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"\n",
"<span style=\"color: #af00ff; text-decoration-color: #af00ff\">No previous fabric admins discovered in persistent storage - creating a new one...</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #af00ff; text-decoration-color: #af00ff\">Restoring FabricAdmin from storage to manage FabricId </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">1</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">, FabricIndex </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">1</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">...</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[38;5;129mRestoring FabricAdmin from storage to manage FabricId \u001b[0m\u001b[1;38;5;129m1\u001b[0m\u001b[38;5;129m, FabricIndex \u001b[0m\u001b[1;38;5;129m1\u001b[0m\u001b[38;5;129m...\u001b[0m\n"
"\u001b[38;5;129mNo previous fabric admins discovered in persistent storage - creating a new one\u001b[0m\u001b[38;5;129m...\u001b[0m\n"
]
},
"metadata": {},
Expand All @@ -142,41 +177,6 @@
"New FabricAdmin: FabricId: 1(1)\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #af00ff; text-decoration-color: #af00ff\">Restoring FabricAdmin from storage to manage FabricId </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">2</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">, FabricIndex </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">2</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">...</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[38;5;129mRestoring FabricAdmin from storage to manage FabricId \u001b[0m\u001b[1;38;5;129m2\u001b[0m\u001b[38;5;129m, FabricIndex \u001b[0m\u001b[1;38;5;129m2\u001b[0m\u001b[38;5;129m...\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"New FabricAdmin: FabricId: 2(2)\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"<span style=\"color: #000080; text-decoration-color: #000080\">Fabric Admins have been loaded and are available at </span><span style=\"color: #800000; text-decoration-color: #800000\">fabricAdmins</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\u001b[34mFabric Admins have been loaded and are available at \u001b[0m\u001b[31mfabricAdmins\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
Expand Down Expand Up @@ -595,7 +595,6 @@
"cell_type": "markdown",
"id": "322ebc15-ae5d-4e84-bb66-a5d77d1e04c6",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
Expand Down Expand Up @@ -630,7 +629,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 3,
"id": "52ccd8c6",
"metadata": {},
"outputs": [],
Expand All @@ -639,11 +638,7 @@
"import subprocess\n",
"\n",
"# So that the all-clusters-app won't boot with stale prior state. \n",
"subprocess.Popen(['rm', '-rf', '/tmp/chip_*'])\n",
"time.sleep(1)\n",
"\n",
"subprocess.Popen(['pkill', '-f', 'chip-all-clusters-app'])\n",
"time.sleep(1)\n",
"os.system('pkill -f chip-all-clusters-app')\n",
"\n",
"# The location of the all-clusters-app in the cloud playground is one level higher - adjust for this by testing for file presence.\n",
"if (os.path.isfile('../../../out/debug/chip-all-clusters-app')):\n",
Expand All @@ -667,7 +662,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 4,
"id": "5e964fe3",
"metadata": {
"tags": []
Expand All @@ -677,8 +672,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"2022-01-25 16:58:31 johnsj-macbookpro1.roam.corp.google.com chip.CTL[27801] ERROR Unable to find country code, defaulting to WW\n",
"2022-01-25 16:58:31 johnsj-macbookpro1.roam.corp.google.com chip.SC[27801] ERROR The device does not support GetClock_RealTimeMS() API. This will eventually result in CASE session setup failures.\n"
"2022-01-29 15:34:45 johnsj-macbookpro1.roam.corp.google.com chip.SC[10607] ERROR The device does not support GetClock_RealTimeMS() API. This will eventually result in CASE session setup failures.\n"
]
},
{
Expand Down Expand Up @@ -730,7 +724,7 @@
},
"outputs": [],
"source": [
"devCtrl.CommissionThreadBle(3840, 20202021, 2, b'\\x01\\x03\\xff')"
"devCtrl.CommissionThread(3840, 20202021, 2, b'\\x01\\x03\\xff')"
]
},
{
Expand Down Expand Up @@ -787,7 +781,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 5,
"id": "bed38512-91f8-4d4e-b6e1-b30749137bbd",
"metadata": {},
"outputs": [],
Expand Down
Loading

0 comments on commit 1715570

Please sign in to comment.