write all needed state info to filesystem
504613
def write(self):
        
        dumped = self._fax.codec.dump(self.__state, open(self.state_file, 'w'))
1137668
def _writen(fd, data):
    """"""
    while data:
        n = os.write(fd, data)
        data = data[n:]
1328222
function write (to, what, locals) {
  const content = ejs.render(what, _.extend({}, (locals || {}), { S: underscoreString }))
  return mkdirp(path.dirname(to)).then(() => {
    return fs.writeFileAsync(to, content, 'utf8')
  })
}
321684
def write(self):
        """"""
        with open(self.log_path, "w") as f:
            json.dump(self.log_dict, f, indent=1)
968319
def _writePlistInfo(self):
        
        pl = Plist(
            CFBundleExecutable=self.executable,
            CFBundleGetInfoString='%s-1.0.0' % self.name,
            CFBundleIconFile=basename(self.icns),
            CFBundleIdentifier='com.%s' % self.name,
            CFBundlePackageType='APPL',
            CFBundleVersion='1.0.0',
            CFBundleShortVersionString='1.0.0',
            )
        writePlist(pl, join(self.contents_dir, 'Info.plist'))
69860
def process_states(self, helper, session, check):
        """"""
        snmp_result_status = helper.walk_snmp_values(session, helper,
                                                     DEVICE_STATES_OIDS["oid_" + check],
                                                     check)

        snmp_result_names = helper.walk_snmp_values(session, helper,
                                                    DEVICE_NAMES_OIDS["oid_" + check],
                                                    check)

        for i, _result in enumerate(snmp_result_status):
            if check == "power_unit":
                helper.update_status(
                    helper,
                    normal_check(snmp_result_names[i], snmp_result_status[i], "Power unit"))
            elif check == "drive":
                helper.update_status(
                    helper,
                    self.check_drives(snmp_result_names[i], snmp_result_status[i]))
            elif check == "power_unit_redundancy":
                helper.update_status(
                    helper,
                    self.check_power_unit_redundancy(snmp_result_names[i], snmp_result_status[i]))
            elif check == "chassis_intrusion":
                helper.update_status(
                    helper,
                    normal_check(snmp_result_names[i], snmp_result_status[i],
                                 "Chassis intrusion sensor"))
            elif check == "cooling_unit":
                helper.update_status(
                    helper,
                    normal_check(snmp_result_names[i], snmp_result_status[i], "Cooling unit"))
1066783
def save_state(self):
        
        if not self.filename:
            self.logger.error('Filename not specified. Could not save state')
            return
        self.logger.debug('Saving system state to %s', self.filename)
        for i in reversed(range(self.num_state_backups)):
            fname = self.filename if i == 0 else '%s.%d' % (self.filename, i)
            new_fname = '%s.%d' % (self.filename, i+1)
            try:
                os.rename(fname, new_fname)
            except FileNotFoundError:
                pass

        with open(self.filename, 'wb') as file, self.worker_thread.queue.mutex:
            obj_list = list(self.objects)
            config = {obj.name: obj.status for obj in obj_list
                      if getattr(obj, 'user_editable', False)}
            data = obj_list, config
            pickle.dump((STATEFILE_VERSION, data), file, pickle.HIGHEST_PROTOCOL)
1268961
def WriteToFD(self, fd):
    """"""
    if self.writeback:
      self.writeback.SaveDataToFD(self.writeback_data, fd)
    else:
      raise RuntimeError("Attempting to write a configuration without a "
                         "writeback location.")
617728
def write(data, path, saltenv='base', index=0):
    '''
    
    '''
    if saltenv not in __opts__['pillar_roots']:
        return 'Named environment {0} is not present'.format(saltenv)
    if len(__opts__['pillar_roots'][saltenv]) <= index:
        return 'Specified index {0} in environment {1} is not present'.format(
                index, saltenv)
    if os.path.isabs(path):
        return ('The path passed in {0} is not relative to the environment '
                '{1}').format(path, saltenv)
    dest = os.path.join(__opts__['pillar_roots'][saltenv][index], path)
    dest_dir = os.path.dirname(dest)
    if not os.path.isdir(dest_dir):
        os.makedirs(dest_dir)
    with salt.utils.files.fopen(dest, 'w+') as fp_:
        fp_.write(salt.utils.stringutils.to_str(data))
    return 'Wrote data to file {0}'.format(dest)
265983
def atomic_write(path, mode):
  """"""
  tmp_path = "%s%s_%s" % (path, constants.INCOMPLETE_SUFFIX, uuid.uuid4().hex)
  with tf.io.gfile.GFile(tmp_path, mode) as file_:
    yield file_
  tf.io.gfile.rename(tmp_path, path, overwrite=True)
92831
def _flush(self):
        
        t1, t2 = str(time.time()).split(".")
        state_path = os.path.join(self.ep_directory, "state_{}_{}.npz".format(t1, t2))
        if hasattr(self.env, "unwrapped"):
            env_name = self.env.unwrapped.__class__.__name__
        else:
            env_name = self.env.__class__.__name__
        np.savez(
            state_path,
            states=np.array(self.states),
            action_infos=self.action_infos,
            env=env_name,
        )
        self.states = []
        self.action_infos = []
535209
def restore_state(self):
        
        settings = QSettings()
        try:
            last_path = settings.value('directory', type=str)
        except TypeError:
            last_path = ''
        self.output_directory.setText(last_path)
1228749
def write_system(filename, format=None):
    ''''''
    datafile(filename, format=format, mode='w').write('system',
                                                      current_system())
254080
def dispatch_write(self, buf):
        """"""
        if self.state != STATE_DEAD and self.enabled:
            super().dispatch_write(buf)
            return True
        return False
77820
def PushState(self, **unused_kwargs):
    """"""
    logging.debug('Storing state {0:s}'.format(repr(self.state)))
    self.state_stack.append(self.state)
1108933
async def dump_devinfo(dev: Device, file):
    
    import attr

    methods = await dev.get_supported_methods()
    res = {
        "supported_methods": {k: v.asdict() for k, v in methods.items()},
        "settings": [attr.asdict(x) for x in await dev.get_settings()],
        "sysinfo": attr.asdict(await dev.get_system_info()),
        "interface_info": attr.asdict(await dev.get_interface_information()),
    }
    if file:
        click.echo("Saving to file: %s" % file.name)
        json.dump(res, file, sort_keys=True, indent=4)
    else:
        click.echo(json.dumps(res, sort_keys=True, indent=4))
92293
def sync(self):
        """"""
        if self.filepath:
            serialised_file = open(self.filepath, "w")
            json.dump(self.state, serialised_file)
            serialised_file.close()
        else:
            print("Filepath to the persistence file is not set. State cannot be synced to disc.")