Saves a screenshot of every new state.
964103
@Override
    public void onNewState(CrawlerContext context, StateVertex vertex) {
        LOG.debug("onNewState");
        StateBuilder state = outModelCache.addStateIfAbsent(vertex);
        visitedStates.putIfAbsent(state.getName(), vertex);

        saveScreenshot(context.getBrowser(), state.getName(), vertex);

        outputBuilder.persistDom(state.getName(), context.getBrowser().getUnStrippedDom());
    }
142408
def snapshot(self):
        
        with self._lock:
            current_state = self.state_manager.current_state
            state_change_id = self.state_change_id

            # otherwise no state change was dispatched
            if state_change_id:
                self.storage.write_state_snapshot(state_change_id, current_state)
171750
private void silentlySaveScreenshotTo(final File file) {
		try {
			saveScreenshotTo(file);
			LOG.info("Screenshot saved: " + file.getAbsolutePath());
		} catch (Exception e) {
			LOG.warn("Error while taking screenshot " + file.getName() + ": "
					+ e);
		}
	}
1000102
private void installSnapshot() {
    state.checkThread();

    // If the last stored snapshot has not yet been installed and its index matches the last applied state
    // machine index, install the snapshot. This requires that the state machine see all indexes sequentially
    // even for entries that have been compacted from the log.
    Snapshot currentSnapshot = state.getSnapshotStore().currentSnapshot();
    if (currentSnapshot != null && currentSnapshot.index() > log.compactor().snapshotIndex() && currentSnapshot.index() == lastApplied && stateMachine instanceof Snapshottable) {

      // Install the snapshot in the state machine thread. Multiple threads can access snapshots, so we
      // synchronize on the snapshot object. In practice, this probably isn't even necessary and could prove
      // to be an expensive operation. Snapshots can be read concurrently with separate SnapshotReaders since
      // memory snapshots are copied to the reader and file snapshots open a separate FileBuffer for each reader.
      LOGGER.info("{} - Installing snapshot {}", state.getCluster().member().address(), currentSnapshot.index());
      executor.executor().execute(() -> {
        synchronized (currentSnapshot) {
          try (SnapshotReader reader = currentSnapshot.reader()) {
            ((Snapshottable) stateMachine).install(reader);
          }
        }
      });

      // Once a snapshot has been applied, snapshot dependent entries can be cleaned from the log.
      log.compactor().snapshotIndex(currentSnapshot.index());
    }
  }
456142
def screenshot(self, scale=None, quality=None):
        
        output_dir = BuiltIn().get_variable_value('${OUTPUTDIR}')
        ts = time.time()
        st = datetime.datetime.fromtimestamp(ts).strftime('%Y%m%d%H%M%S')
        screenshot_path = '%s%s%s.png' % (output_dir, os.sep, st)
        self.device.screenshot(screenshot_path, scale, quality)
        logger.info('\n<a href="%s">%s</a><br><img src="%s">' % (screenshot_path, st, screenshot_path), html=True)
69049
def _set_save_states(self):
        """"""

        wx.BeginBusyCursor()
        self.saving = True
        self.grid.Disable()
965552
def _saveState(self, path):
        """"""
        self.addSession()  # next session
        self._save(str(self.n_sessions), path)
555135
def save_state
      # start will al state to be saved
      state_to_save = { 'startup_tags' => startup_tags,
                      'reboot' => reboot?,
                      'log_level' => log_level }

      # only save a log file one is defined
      if log_file
        state_to_save['log_file'] = log_file
      end

      # only save persist the fact we downloaded cookbooks if we are in dev mode
      if download_once?
        state_to_save['has_downloaded_cookbooks'] = has_downloaded_cookbooks?
      end

      RightScale::JsonUtilities::write_json(RightScale::CookState::STATE_FILE, state_to_save)
      true
    end
1133750
@Override
	public void snapshotState(FunctionSnapshotContext context) throws Exception {
		Preconditions.checkState(this.checkpointedState != null,
			"The " + getClass().getSimpleName() + " state has not been properly initialized.");

		this.checkpointedState.clear();
		this.checkpointedState.add(this.globalModificationTime);

		if (LOG.isDebugEnabled()) {
			LOG.debug("{} checkpointed {}.", getClass().getSimpleName(), globalModificationTime);
		}
	}
588367
function( newImage ) {
			// Do not change snapshots stack is locked.
			if ( this.locked )
				return;

			if ( !newImage )
				newImage = new Image( this.editor );

			var i = this.index,
				snapshots = this.snapshots;

			// Find all previous snapshots made for the same content (which differ
			// only by selection) and replace all of them with the current image.
			while ( i > 0 && this.currentImage.equalsContent( snapshots[ i - 1 ] ) )
				i -= 1;

			snapshots.splice( i, this.index - i + 1, newImage );
			this.index = i;
			this.currentImage = newImage;
		}
1293683
public void saveScreenshotAfterInFolder(String policy, String baseDir) throws IOException {
		screenCapture.setScreenshotBaseDir(removeAnchorTag(baseDir));
		saveScreenshotAfter(policy);
	}
1309895
def save_state(self):
        """"""
        # Save boolean settings
        for key, check_box in list(self.boolean_settings.items()):
            self.save_boolean_setting(key, check_box)
        # Save text settings
        for key, line_edit in list(self.text_settings.items()):
            self.save_text_setting(key, line_edit)

        set_setting(
            'north_arrow_path', self.leNorthArrowPath.text(), self.settings)
        set_setting(
            'organisation_logo_path',
            self.organisation_logo_path_line_edit.text(),
            self.settings)
        set_setting(
            'reportTemplatePath',
            self.leReportTemplatePath.text(),
            self.settings)
        set_setting(
            'reportDisclaimer',
            self.txtDisclaimer.toPlainText(),
            self.settings)
        set_setting(
            'defaultUserDirectory',
            self.leUserDirectoryPath.text(),
            self.settings)
        index = self.earthquake_function.currentIndex()
        value = self.earthquake_function.itemData(index)
        set_setting('earthquake_function', value, qsettings=self.settings)

        currency_index = self.currency_combo_box.currentIndex()
        currency_key = self.currency_combo_box.itemData(currency_index)
        set_setting('currency', currency_key, qsettings=self.settings)

        # Save InaSAFE default values
        self.save_default_values()

        # Save population parameters
        self.save_population_parameters()
192087
function saveScreenshotIfExists(testResults) {
        var deferred = Q.defer();

        if (testResults.screenshotBuffer) {

            var screenshotFilePath = path.join(resultsDir, testResults.runId, resultScreenshotName);
            fs.writeFile(screenshotFilePath, testResults.screenshotBuffer);

            delete testResults.screenshotBuffer;

        } else {
            deferred.resolve();
        }

        return deferred;
    }
67655
@Override
    public Parcelable onSaveInstanceState() {

        Bundle bundle = new Bundle();
        bundle.putParcelable("instanceState", super.onSaveInstanceState());
        saveSettings();
        bundle.putParcelable("stateSettings", mPinViewSettings);
        //save everything
        bundle.putString("statePinResults", getPinResults());
        return bundle;
    }
931712
def savepoint(self):
        
        if self._last_image:
            self._savepoints.append(self._last_image)
            self._last_image = None
457370
def save_state(self, fname=None):
        """"""
        if not fname:
            date = datetime.datetime.now().strftime("%Y-%m-%dT%Hh%Mm%Ss")
            fname = date + "_energy_" + str(self.energy()) + ".state"
        with open(fname, "wb") as fh:
            pickle.dump(self.state, fh)
707221
function() {
        var that = this;

        // Save a screenshot.
        if ($$logging.get('screenshots').enabled) {
            var filename = $$logging.get('screenshots').filename.replace('{date}', moment().format('YYYYMMDDhhmmss'));
            logger.info('Saving screenshot to ' + filename);

            var winCmd = path.join(__dirname, '../tools', 'nircmd.exe');
            var winArgs = ['savescreenshotfull', filename];

            var macCmd = '/usr/sbin/screencapture';
            var macArgs = ['-x', '-t', 'jpg', '-C', filename];

            var cmd = process.platform === 'win32' ? winCmd : macCmd;
            var args = process.platform === 'win32' ? winArgs : macArgs;

            var screenshot = child_process.spawn(cmd, args);
            screenshot.on('close', function(code, signal) {
                logger.info('Screenshot saved, restarting.');
                restart();
            });
        } else {
            restart();
        }

        function restart() {
            var restartCount = that.get('restartCount');
            restartCount++;

            var logList = 'App went away: ' + restartCount + ' times\n\n';
            _.each($$logging.get('logCache'), function(log) {
                logList += log.time + ' ' + log.level + ': ' + log.msg + '\n';
            });
            logger.error(logList);

            that.trigger('crash');

            if (restartCount >= that.get('restartMachineAfter')) {
                logger.info('Already restarted app ' + that.get('restartMachineAfter') + ' times, rebooting machine.');
                that.restartMachine();
                return;
            }

            that.set('restartCount', restartCount);
            that._isStartingUp = false;
            that._isShuttingDown = false;
            that.restartApp();
        }
    }