Skip to content

Commit 9815b53

Browse files
Make save magic command save to main.py instead of boot.py so it doesn't soft brick system
1 parent 06a0b68 commit 9815b53

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

kernel/src/kernel.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ServiceContainer } from './services/ServiceContainer';
44

55
const reconnectString: string = "%connect%"
66
const saveString: string = "%save%";
7-
const bootFileName: string = "boot.py";
7+
const bootFileName: string = "/main.py";
88
const bootSavePrefix: string = `with open('${bootFileName}', 'w') as f:\n f.write('''\n`;
99
const bootSaveSuffix: string = "\n''')\n";
1010

@@ -81,8 +81,8 @@ export class EmbeddedKernel extends BaseKernel {
8181
await this.serviceContainer.deviceService.connect(this.outputResponse.bind(this));
8282
}
8383
if (code.includes(saveString)) {
84-
// Burn the code after the save string into the boot.py file
85-
this.outputResponse("Save command detected, saving code to boot.py...");
84+
// Burn the code after the save string into the main.py file
85+
this.outputResponse(`Save command detected, saving code to ${bootFileName}...`);
8686
const codeToSave = code.split(saveString)[1].trim();
8787
if (!codeToSave) {
8888
return {
@@ -93,19 +93,19 @@ export class EmbeddedKernel extends BaseKernel {
9393
traceback: ['Please provide code to save after the %save% command']
9494
};
9595
}
96-
// Burn the code by adding it to the boot.py file. Can call executeRequest with the code to save
97-
// but append the code to write it to the boot.py file at the start of the code.
96+
// Burn the code by adding it to the main.py file. Can call executeRequest with the code to save
97+
// but append the code to write it to the main.py file at the start of the code.
9898
const bootCode = `# This code is automatically generated by the Embedded Kernel\n${codeToSave}`;
9999
const bootCodeWithSave = `${bootSavePrefix}${bootCode}${bootSaveSuffix}`;
100100

101-
// Execute the command to save the boot.py file
101+
// Execute the command to save the main.py file
102102
if (!this.serviceContainer.deviceService.getTransport()) {
103-
console.log("[Kernel] executeRequest - No transport available for saving boot.py");
103+
console.log(`[Kernel] executeRequest - No transport available for saving ${bootFileName}`);
104104
return {
105105
status: 'error',
106106
execution_count: this.executionCount,
107107
ename: 'TransportError',
108-
evalue: 'No transport available to save boot.py',
108+
evalue: `No transport available to save ${bootFileName}`,
109109
traceback: ['Please connect a device first']
110110
};
111111
}
@@ -123,7 +123,7 @@ export class EmbeddedKernel extends BaseKernel {
123123
traceback: [result.error || 'Unknown error']
124124
};
125125
}
126-
console.log("[Kernel] executeRequest - Code saved to boot.py successfully");
126+
console.log(`[Kernel] executeRequest - Code saved to ${bootFileName} successfully`);
127127
return {
128128
status: 'ok',
129129
execution_count: this.executionCount,

0 commit comments

Comments
 (0)