Rollback configuration to filename or to self.rollback_cfg file.
778161
def rollback(self):
        """"""
        filename = self.rollback_cfg
        cfg_file = self._gen_full_path(filename)
        if not self._check_file_exists(cfg_file):
            raise ReplaceConfigException("Rollback config file does not exist")
        cmd = "configure replace {} force".format(cfg_file)
        self.device.send_command_expect(cmd)

        # After a rollback - we no longer know whether this is configured or not.
        self.prompt_quiet_configured = None

        # Save config to startup
        self.device.save_config()
185406
def save(self, filename=None, debug=False):
        """"""
        if not filename: filename = self.name
        with open(filename, "w") as f: # save config data file
            f.write(self.toJson(self.attrs))
        if self.debug or debug:
            print("saved configuration %s"%(self.name))
            for k,v in sorted(iteritems(self.attrs)):
                print("%15s : %s"%(k,v))
696611
def rollback(self):
        

        try:
            self.check_connection()
        except NullDatabaseConnectionError:
            return

        logger.debug("rollback: path='{}'".format(self.database_path))

        self.connection.rollback()
682268
def save(self, filename=None):
        """"""
        if self.__fname is None and filename is None:
            raise ValueError('Config loaded from string, no filename specified')
        conf = self.__config
        cpa = dict_to_cp(conf)
        with open(self.__fname if filename is None else filename, 'w') as f:
            cpa.write(f)
453443
def _get_diff(self, cp_file):
        """"""
        diff = []
        self._create_sot_file()
        diff_out = self.device.show(
            'show diff rollback-patch file {0} file {1}'.format(
                'sot_file', self.replace_file.split('/')[-1]), raw_text=True)
        try:
            diff_out = diff_out.split(
                '#Generating Rollback Patch')[1].replace(
                    'Rollback Patch is Empty', '').strip()
            for line in diff_out.splitlines():
                if line:
                    if line[0].strip() != '!':
                        diff.append(line.rstrip(' '))
        except (AttributeError, KeyError):
            raise ReplaceConfigException(
                'Could not calculate diff. It\'s possible the given file doesn\'t exist.')
        return '\n'.join(diff)
72841
public void rollback() {
        log.debug("Rolling back rebind operation");
        try {
            ldapOperations.unbind(originalDn);
            ldapOperations.rename(temporaryDn, originalDn);
        } catch (Exception e) {
            log.warn("Failed to rollback operation, dn: " + originalDn
                    + "; temporary DN: " + temporaryDn, e);
        }
    }
58900
def rollback(self):
        
        with self.native(writeAccess=True) as conn:
            return self._rollback(conn)
1212802
def reset_config_files():
    """"""
    print("*** Reset Spyder settings to defaults ***", file=STDERR)
    for fname in SAVED_CONFIG_FILES:
        cfg_fname = get_conf_path(fname)
        if osp.isfile(cfg_fname) or osp.islink(cfg_fname):
            os.remove(cfg_fname)
        elif osp.isdir(cfg_fname):
            shutil.rmtree(cfg_fname)
        else:
            continue
        print("removing:", cfg_fname, file=STDERR)
1069439
protected function configure()
    {
        $this
            ->setName('rollback')
            ->setDescription('Reverts the last change.');

        $this->sudo = true;
        $this->validate = false;
    }
962896
def rollback():
    

    init_tasks()

    run_hook("before_rollback")

    # Remove current version
    current_release = paths.get_current_release_path()
    if current_release:
        env.run("rm -rf %s" % current_release)

    # Restore previous version
    old_release = paths.get_current_release_name()
    if old_release:
        paths.symlink(paths.get_source_path(old_release),
                      paths.get_current_path())

    run_hook("rollback")
    run_hook("after_rollback")

    logger.info("Rollback complete")
215511
def _discard_config(self):
        """"""
        discard_candidate = "copy running-config {}".format(
            self._gen_full_path(self.candidate_cfg)
        )
        discard_merge = "copy null: {}".format(self._gen_full_path(self.merge_cfg))
        self.device.send_command_expect(discard_candidate)
        self.device.send_command_expect(discard_merge)
1034233
def rollback(self):
        """"""
        if not self._in_transaction:
            raise NotInTransaction
        self._init_cache()
        self._in_transaction = False
145974
function(cfg, callback) {
  var paths = cfg.input_files || cfg.input_file || cfg.input_dir;
  if (!Array.isArray(paths)) {
    paths = [paths];
  }
  
  watchr.watch({
    paths: paths,
    listener: function(eventName,filePath,fileCurrentStat,filePreviousStat){
      console.log(formatLog('File changed:', filePath));
      
      var singleFileCfg,
          outputDir,
          logTaskError = function(msg) {
            console.log('\n'+msg.red);
          };

      // Detect what build configuration the file belongs to
      if (config.scripts.indexOf(cfg) !== -1) {
        // rebuild scripts
        buildScripts(cfg, function(err){
          if (err) {
            logTaskError('Scripts not saved!');
          }
        });
      } else if (config.styles.indexOf(cfg) !== -1) {
        // rebuild styles
        buildStyles(cfg, function(err){
          if (err) {
            logTaskError('Styles not saved!');
          }
        });
      } else if (config.copy_files.indexOf(cfg) !== -1) {
        // copy files
        singleFileCfg = {input_files: [filePath], output_dir: cfg.output_dir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_file.indexOf(cfg) !== -1) {
        // copy/rename single file
        singleFileCfg = {input_file: filePath, output_file: cfg.output_file};
        copyFile(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_dir.indexOf(cfg) !== -1) {
        // copy single directory
        outputDir = path.dirname(filePath).replace(cfg.input_dir, cfg.output_dir);
        singleFileCfg = {input_files: [filePath], output_dir: outputDir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('Directory not copied!');
          }
        });
      }
    },
    next: function(err,watcher){
      if (err) {
        callback(err);
      } else {
        callback();
      }
    }
  });
}
646007
def save(self, filename=None):
        
        if not filename:
            filename = self.DEFAULT_CONFIG_FILE_NAME
        else:
            filename = str(filename)
            # try to extract the path from filename and use is as cfg_dir
            head, tail = os.path.split(filename)
            if head:
                self._cfg_dir = head

            # we are search for .cfg files in cfg_dir so make sure it contains the proper extension.
            base, ext = os.path.splitext(tail)
            if ext != ".cfg":
                filename += ".cfg"

        # if we have no cfg dir, try to create it first. Return if it failed.
        if not self.cfg_dir or not os.path.isdir(self.cfg_dir) or not os.stat(self.cfg_dir) != os.W_OK:
            try:
                self.cfg_dir = self.DEFAULT_CONFIG_DIR
            except ConfigDirectoryException as cde:

                print(Config._format_msg('Could not create configuration directory "{dir}"! config.save() failed.'
                                          ' Please set a writeable location with config.cfg_dir = val. Error was {exc}'
                                          .format(dir=self.cfg_dir, exc=cde)))
                return

        filename = os.path.join(self.cfg_dir, filename)

        try:
            with open(filename, 'w') as fh:
                self._conf_values.write(fh)
        except IOError as ioe:
            print(Config._format_msg("Save failed with error %s" % ioe))
150077
def load(self):
        """"""

        # Config files prior to 0.2.4 dor not have config version keys
        old_config = not self.cfg_file.Exists("config_version")

        # Reset data
        self.data.__dict__.update(self.defaults.__dict__)

        for key in self.defaults.__dict__:
            if self.cfg_file.Exists(key):
                setattr(self.data, key, self.cfg_file.Read(key))

        # Reset keys that should be reset on version upgrades
        if old_config or self.version != self.data.config_version:
            for key in self.reset_on_version_change:
                setattr(self.data, key, getattr(DefaultConfig(), key))
            self.data.config_version = self.version

        # Delete gpg_key_uid and insert fingerprint key

        if hasattr(self.data, "gpg_key_uid"):
            oldkey = "gpg_key_uid"
            delattr(self.data, oldkey)
            newkey = "gpg_key_fingerprint"
            setattr(self.data, newkey, getattr(DefaultConfig(), newkey))
264688
def discard(self):  # pylint: disable=no-self-use
        
        try:
            self.rollback(0)
        except pyPluribus.exceptions.RollbackError as rbackerr:
            raise pyPluribus.exceptions.ConfigurationDiscardError("Cannot discard configuration: {err}.\
                ".format(err=rbackerr))
871596
def cfgdump(path, config):
    """"""
    dump = yaml_dump(config)
    if not os.path.exists(path):
        os.makedirs(path)
    with open(os.path.join(path, 'config.yaml'), 'w') as outf:
        outf.write(dump)
    print(dump)