public function loadSnapshot($deviceName, $key)
 {
     extract($this->configIO->getConfigData());
     $loadSnapContent = file_get_contents($SnapshotSwapPath . "/" . $this->formatKey($deviceName, $key));
     $snapSections = unserialize($loadSnapContent);
     $jSnapBundle = new JSnapSnapSectionBundle($key);
     foreach ($snapSections as $section) {
         $jSnapBundle->addSnapshotSection(new JSnapSnapSectionXML($section->getSnapType(), $key, $section->getSnapData()));
     }
     return $jSnapBundle;
 }
 public function check($deviceName, JSnapSnapSectionBundle $preSnap, JSnapSnapSectionBundle $postSnap)
 {
     try {
         extract($this->configIO->getConfigData());
         chdir($SwapPath);
         $snapshots = array($preSnap->getSnapshotSections(), $postSnap->getSnapshotSections());
         $snapTimes = array();
         foreach ($snapshots as $key => $snap) {
             foreach ($snap as $section) {
                 $fileNames[] = "{$deviceName}__{$section->getSnapType()}__{$section->getSnapTime()}.xml";
                 file_put_contents(end($fileNames), $section->getSnapData());
                 $snapTimes[$key] = $section->getSnapTime();
             }
         }
         $output = shell_exec(escapeshellcmd("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" . $JuiseExecutablePath . ":" . $JSnapExecutablePath . " " . $JSnapExecutable . " --check {$snapTimes[0]},{$snapTimes[1]}" . " -t " . escapeshellarg($deviceName) . ' ' . escapeshellarg($CheckCommandLineArguments) . ' ' . $ConfigFile) . " 2>&1");
         foreach ($fileNames as $filename) {
             unlink($filename);
         }
         $output = implode("\n", array_slice(explode("\n", $output), 4));
         if (strpos($output, "CHECKING SECTION: ") === false) {
             throw new \Exception("jSnap failed to run: {$output}");
         }
         $jSnapResults = new JSnapResults($deviceName);
         foreach (explode("CHECKING SECTION: ", $output) as $key => $section) {
             if ($key == 0) {
                 continue;
             }
             $sectionSplit = explode("\n---------------------------------------------------------------------------\n", $section);
             $sectionSplit = array_filter($sectionSplit);
             $testName = $sectionSplit[0];
             $testContents = $sectionSplit[1];
             $testInfo = array_filter(preg_split("/[+-] TEST /", $testContents));
             foreach ($testInfo as $info) {
                 if (substr($info, 0, 8) === "FAILED: ") {
                     list($infoName, $infoContent) = explode("\n", $info, 2);
                     $infoName = substr($infoName, 8);
                     $jSnapResults->addFailedTest($testName, $infoName, $infoContent);
                 } else {
                     $infoContent = substr($info, 8);
                     $jSnapResults->addPassedTest($testName, $infoContent);
                 }
             }
         }
         return $jSnapResults;
     } catch (\Exception $e) {
         JSnapHelpers::JSONOutput($e->getMessage(), 1);
     }
 }