Save a script

    Save a script # noqa: E501

    :param name: Get status of a driver with this name
    :type name: str
    :param save: The data needed to save this script
    :type save: dict | bytes

    :rtype: Response
541950
def save_driver_script(name, save=None):  # noqa: E501
    
    if connexion.request.is_json:
        save = Save1.from_dict(connexion.request.get_json())  # noqa: E501

    response = errorIfUnauthorized(role='developer')
    if response:
        return response
    else:
        response = ApitaxResponse()

    driver: Driver = LoadedDrivers.getDriver(name)
    driver.saveDriverScript(save.script.name, save.script.content)

    return Response(status=200, body=response.getResponseBody())
400457
def save(self):
        
        if not self.txt:
            # no changes
            return
        if not self.fn:
            raise exception.InvalidAction(
                "Can't save .spec file without its file name specified.")
        f = codecs.open(self.fn, 'w', encoding='utf-8')
        f.write(self.txt)
        f.close()
        self._rpmspec = None
145642
def save(connection)
      xml = '<EngineSaveRequest session-id="' + connection.session_id + '">'
      xml << to_xml
      xml << '</EngineSaveRequest>'

      r = connection.execute(xml, '1.2')
      if r.success
        r.res.elements.each('EngineSaveResponse/EngineConfig') do |v|
          return @id = v.attributes['id'].to_i
        end
      end
    end
684796
def save(self, fname=''):
        
        if fname != '':
            with open(fname, 'w') as f:
                for t in self.lstTools:
                    self.verify(t)
                    f.write(self.tool_as_string(t))
74917
def __generic_save(self):
        """"""
        page = self._get_page()
        f = page.editor.f
        if not f:
            return True
        if not page.editor.flag_valid:
            a99.show_error("Cannot save, {0!s} has error(s)!".format(f.description))
            return True
        if f.filename:
            f.save_as()

            self.add_log("Saved '{}'".format(f.filename))
            page.flag_changed = False
            self._update_gui_text_tabs()

            if hasattr(page.editor, "update_gui_label_fn"):
                page.editor.update_gui_label_fn()  # duck typing
            return True
        else:
            return self.__generic_save_as()
987072
function save(scriptModule, agent, msg, cb) {
    const filepath = path.join(scriptModule.root, msg.filename);

    fs.writeFile(filepath, msg.body, (err) => {
        if (err) {
            logger.error(`fail to write script file:${msg.filename}, ${err.stack}`);
            cb(`fail to write script file:${msg.filename}`);
            return;
        }

        cb();
    });
}
761168
def save_all_ggr_logs(cls, test_name, test_passed):
        
        log_name = '{} [driver {}]' if len(cls.driver_wrappers) > 1 else '{}'
        driver_index = 1
        for driver_wrapper in cls.driver_wrappers:
            if not driver_wrapper.driver or driver_wrapper.server_type not in ['ggr', 'selenoid']:
                continue
            try:
                if driver_wrapper.config.getboolean_optional('Server', 'logs_enabled') or not test_passed:
                    name = get_valid_filename(log_name.format(test_name, driver_index))
                    Selenoid(driver_wrapper).download_session_log(name)
            except Exception as exc:
                # Capture exceptions to avoid errors in teardown method due to session timeouts
                driver_wrapper.logger.warn('Error downloading GGR logs: %s' % exc)
            driver_index += 1
1231188
def create_driver_script(name, create=None):  # noqa: E501
    
    if connexion.request.is_json:
        create = Create1.from_dict(connexion.request.get_json())  # noqa: E501

    response = errorIfUnauthorized(role='developer')
    if response:
        return response
    else:
        response = ApitaxResponse()

    driver: Driver = LoadedDrivers.getDriver(name)
    driver.saveDriverScript(create.script.name, create.script.content)

    return Response(status=200, body=response.getResponseBody())
1209622
def save(self, filename, verbose=False):
        
        with open(filename, 'w') as fid:
            json.dump(self._conf, fid, indent=4)
        if verbose:
            print('Saved settings in ' + filename)
922447
def save(self):
        
        return dict(code=self.code, name=self.name, abilities=self.abilities,
                    attributes=self.attributes, info=self.info)
498307
def _save_nb(nb_name):
    
    display(Javascript('IPython.notebook.save_checkpoint();'))
    display(Javascript('IPython.notebook.save_notebook();'))
    print('Saving notebook...', end=' ')

    if _wait_for_save(nb_name):
        print("Saved '{}'.".format(nb_name))
    else:
        logging.warning(
            "Could not save your notebook (timed out waiting for "
            "IPython save). Make sure your notebook is saved "
            "and export again."
        )
355584
def p_save_code(p):
    
    if p[2].type_ != TYPE.string:
        api.errmsg.syntax_error_expected_string(p.lineno(1), p[2].type_)

    if len(p) == 5:
        if p[3].upper() not in ('SCREEN', 'SCREEN$'):
            syntax_error(p.lineno(3), 'Unexpected "%s" ID. Expected "SCREEN$" instead' % p[3])
            return None
        else:
            # ZX Spectrum screen start + length
            # This should be stored in a architecture-dependant file
            start = make_number(16384, lineno=p.lineno(1))
            length = make_number(6912, lineno=p.lineno(1))
    else:
        start = p[4]
        length = p[6]

    p[0] = make_sentence(p[1], p[2], start, length)
1317954
def save(self, name=None, path=None):
        
        if path :
            name = os.path.join(path,name)

        try:
            self._create_table_xml_file(self.etree, name)
        except (Exception,) as e:
            print(e)
            return False

        return True
541365
def saveas name=nil, config={}
      unless name
        name = rb_gets "File to save as: "
        return if name.nil? || name == ""
      end
      overwrite_if_exists = config[:overwrite_if_exists] || false
      unless overwrite_if_exists
        exists = File.exists? name
        if exists # need to prompt
          return unless rb_confirm("Overwrite existing file? ")
        end
      end
      # if it has been set do not prompt. or ask only if value is :ask
      # But this should only be if there is someformatting provided, that is there 
      # is a @document
      l = @list
      # the check for document is to see if it is some old widget like textarea that is calling this.
      if @document
        if config.key? :save_with_formatting
          save_with_formatting = config[:save_with_formatting] 
        else
          save_with_formatting = rb_confirm("Save with formatting?")
        end
        if save_with_formatting
          l = @list
        else
          l = @document.native_text().map do |w| w.to_s ; end
        end
      end
      #l = getvalue
      File.open(name, "w"){ |f|
        l.each { |line| f.puts line }
        #l.each { |line| f.write line.gsub(/\r/,"\n") }
      }
      rb_puts "#{name} written."
    end
430856
def get_driver_script(name, name2=None):  # noqa: E501
    
    response = errorIfUnauthorized(role='user')
    if response:
        return response
    else:
        response = ApitaxResponse()

    print(name)
    print(name2)


    driver: Driver = LoadedDrivers.getDriver(name2)

    response.body.add({'content': driver.getDriverScript(name)})

    return Response(status=200, body=response.getResponseBody())
693567
def save_cert(name, master):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': ''}
    cert = "{0}trusted-master.crt".format(get_certs_path())

    # Checking if execution is needed.
    if os.path.isfile(cert):
        ret['comment'] = 'No execution needed. Cert: {0} already saved.'.format(cert)
        return ret
    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = 'Certificate save for icinga2 master would be executed'
        return ret

    # Executing the command.
    cert_save = __salt__['icinga2.save_cert'](name, master)
    if not cert_save['retcode']:
        ret['comment'] = "Certificate for icinga2 master saved"
        ret['changes']['cert'] = "Executed. Certificate saved: {0}".format(cert)
    return ret
981276
def save_to(self, nameprefix, switch=False):
        
        if not nameprefix or not isinstance(nameprefix, basestring):
            raise _Error('filename prefix must be a nonempty string')

        if nameprefix == self.default_prefix:
            raise _Error('cannot save to default name "' + nameprefix + '...", chose another name')

        if nameprefix == self.name_prefix:
            return

        for name in self.file_names:
            open(nameprefix + name + '.dat', 'w').write(open(self.name_prefix + name + '.dat').read())

        if switch:
            self.name_prefix = nameprefix