Server IP : 209.38.156.173 / Your IP : 216.73.216.122 [ Web Server : Apache/2.4.52 (Ubuntu) System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.1.2-1ubuntu2.22 Disable Function : NONE Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /snap/core20/2582/usr/share/subiquity/subiquitycore/ |
Upload File : |
import os import stat import tempfile _DEF_PERMS = 0o644 def write_file(filename, content, mode=None, omode="wb", copy_mode=False): """Atomically write filename. open filename in mode 'omode', write content, chmod to 'mode'. """ if mode is None: mode = _DEF_PERMS if copy_mode: try: file_stat = os.stat(filename) mode = stat.S_IMODE(file_stat.st_mode) except OSError: pass tf = None try: tf = tempfile.NamedTemporaryFile(dir=os.path.dirname(filename), delete=False, mode=omode) tf.write(content) tf.close() os.chmod(tf.name, mode) os.rename(tf.name, filename) except OSError as e: if tf is not None: os.unlink(tf.name) raise e