(self, pyfile, contents)
| 1065 | del cls.proxy |
| 1066 | |
| 1067 | def update_pyfile(self, pyfile, contents): |
| 1068 | dirname = os.path.dirname(pyfile) |
| 1069 | if not os.path.exists(dirname): |
| 1070 | os.makedirs(dirname) |
| 1071 | with salt.utils.files.fopen(pyfile, "wb") as fh: |
| 1072 | fh.write(salt.utils.stringutils.to_bytes(contents)) |
| 1073 | fh.flush() |
| 1074 | os.fsync(fh.fileno()) # flush to disk |
| 1075 | |
| 1076 | # pyc files don't like it when we change the original quickly |
| 1077 | # since the header bytes only contain the timestamp (granularity of seconds) |
| 1078 | # TODO: don't write them? Is *much* slower on re-load (~3x) |
| 1079 | # https://docs.python.org/2/library/sys.html#sys.dont_write_bytecode |
| 1080 | remove_bytecode(pyfile) |
| 1081 | |
| 1082 | def rm_pyfile(self, pyfile): |
| 1083 | os.unlink(pyfile) |
no test coverage detected