MCPcopy Create free account
hub / github.com/NicolasLagaillardie/mpst_rust_github / kmc_cli

Function kmc_cli

src/checking/mod.rs:258–295  ·  view source on GitHub ↗

Run the KMC command line

(name_file: &str, kmc_number: i32)

Source from the content-addressed store, hash-verified

256
257// Run the KMC command line
258pub(crate) fn kmc_cli(name_file: &str, kmc_number: i32) -> Result<(bool, String), Box<dyn Error>> {
259 // Delete previous files
260 remove_file(format!(
261 "../mpst_rust_github/outputs/{name_file}_{kmc_number}_kmc.txt"
262 ))
263 .unwrap_or(());
264 remove_file(format!(
265 "../mpst_rust_github/outputs/{name_file}-sync-0norm-system.dot"
266 ))
267 .unwrap_or(());
268 remove_file(format!(
269 "../mpst_rust_github/outputs/{name_file}-sync-0norm-system.png"
270 ))
271 .unwrap_or(());
272 remove_file(format!(
273 "../mpst_rust_github/outputs/{name_file}-ts-{kmc_number}.fsm"
274 ))
275 .unwrap_or(());
276
277 // Run KMC tool, the outputs files of the tool are in the "outputs" folder
278 let kmc = Command::new("KMC")
279 .arg(format!("cfsm/{name_file}.txt"))
280 .arg(format!("{kmc_number:?}"))
281 .arg("--fsm")
282 .output()?;
283
284 let stdout = String::from(str::from_utf8(&kmc.stdout)?);
285
286 if stdout.contains("False") {
287 Ok((false, stdout))
288 } else {
289 // Write down the stdout of the previous command into
290 // a corresponding file in the "outputs" folder
291 let mut kmc_file = File::create(format!("outputs/{name_file}_{kmc_number}_kmc.txt"))?;
292 writeln!(kmc_file, "{stdout}")?;
293 Ok((true, stdout))
294 }
295}
296
297// The starting function for extracting the graphs
298#[doc(hidden)]

Callers 1

checkerFunction · 0.85

Calls 2

newFunction · 0.85
OkClass · 0.50

Tested by

no test coverage detected