Tweak runCQ
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { writeFiles, runCommand } from '../common/utils'
|
import { writeFiles, runCommand } from '../common/utils'
|
||||||
import { nanoid } from 'nanoid'
|
import { nanoid } from 'nanoid'
|
||||||
|
import { readFile } from 'fs/promises'
|
||||||
|
|
||||||
export const runCQ = async ({
|
export const runCQ = async ({
|
||||||
file,
|
file,
|
||||||
@@ -11,34 +12,35 @@ export const runCQ = async ({
|
|||||||
)
|
)
|
||||||
const fullPath = `/tmp/${tempFile}/output.gz`
|
const fullPath = `/tmp/${tempFile}/output.gz`
|
||||||
const stlPath = `/tmp/${tempFile}/output.stl`
|
const stlPath = `/tmp/${tempFile}/output.stl`
|
||||||
const customizerPath = `/tmp/${tempFile}/customizer.param`
|
// const customizerPath = `/tmp/${tempFile}/customizer.param`
|
||||||
const command = [
|
const command = [
|
||||||
`cq-cli/cq-cli`,
|
`cq-cli/cq-cli`,
|
||||||
`--codec stl`,
|
`--codec stl`,
|
||||||
`--infile /tmp/${tempFile}/main.py`,
|
`--infile /tmp/${tempFile}/main.py`,
|
||||||
`--outfile ${stlPath}`,
|
`--outfile ${stlPath}`,
|
||||||
`--outputopts "deflection:${deflection};angularDeflection:${deflection};"`,
|
`--outputopts "deflection:${deflection};angularDeflection:${deflection};"`,
|
||||||
`--params ${customizerPath}`,
|
// `--params ${customizerPath}`,
|
||||||
].join(' ')
|
].join(' ')
|
||||||
const command2 = [
|
// const command2 = [
|
||||||
`cq-cli/cq-cli`,
|
// `cq-cli/cq-cli`,
|
||||||
`--getparams true`,
|
// `--getparams true`,
|
||||||
`--infile /tmp/${tempFile}/main.py`,
|
// `--infile /tmp/${tempFile}/main.py`,
|
||||||
`--outfile ${customizerPath}`,
|
// `--outfile ${customizerPath}`,
|
||||||
]
|
// ]
|
||||||
console.log('command', command)
|
console.log('command', command)
|
||||||
let consoleMessage = ''
|
let consoleMessage = ''
|
||||||
try {
|
try {
|
||||||
consoleMessage = await runCommand(command, 30000)
|
consoleMessage = await runCommand(command, 30000)
|
||||||
consoleMessage2 = await runCommand(command2, 30000)
|
// const consoleMessage2 = await runCommand(command2, 30000)
|
||||||
const params = JSON.parse(
|
// const params = JSON.parse(
|
||||||
await readFile(customizerPath, { encoding: 'ascii'})
|
// await readFile(customizerPath, { encoding: 'ascii'})
|
||||||
).parameters
|
// )
|
||||||
|
// console.log('params', params)
|
||||||
await writeFiles(
|
await writeFiles(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
file: JSON.stringify({
|
file: JSON.stringify({
|
||||||
customizerParams: params,
|
// customizerParams: params,
|
||||||
consoleMessage,
|
consoleMessage,
|
||||||
type: 'stl',
|
type: 'stl',
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user