MCPcopy
hub / github.com/saltstack/salt / update_module

Method update_module

tests/unit/test_loader.py:886–901  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

884 del cls.opts
885
886 def update_module(self):
887 self.count += 1
888 with salt.utils.files.fopen(self.module_path, "wb") as fh:
889 fh.write(
890 salt.utils.stringutils.to_bytes(
891 submodule_template.format(self.module_name, count=self.count)
892 )
893 )
894 fh.flush()
895 os.fsync(fh.fileno()) # flush to disk
896
897 # pyc files don't like it when we change the original quickly
898 # since the header bytes only contain the timestamp (granularity of seconds)
899 # TODO: don't write them? Is *much* slower on re-load (~3x)
900 # https://docs.python.org/2/library/sys.html#sys.dont_write_bytecode
901 remove_bytecode(self.module_path)
902
903 def rm_module(self):
904 os.unlink(self.module_path)

Callers 3

test_basicMethod · 0.95
test_reloadMethod · 0.95

Calls 5

remove_bytecodeFunction · 0.85
formatMethod · 0.80
writeMethod · 0.45
flushMethod · 0.45
filenoMethod · 0.45

Tested by

no test coverage detected