save a file to alocal folder and make it executable
This commit is contained in:
parent
e54626d971
commit
230cf99f06
8 changed files with 122 additions and 21 deletions
17
majordome/local_files.py
Normal file
17
majordome/local_files.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from pathlib import Path
|
||||
|
||||
|
||||
def save(destination: Path, file_content: bytes):
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
destination.write_bytes(file_content)
|
||||
|
||||
|
||||
def set_execution_rights(file: Path):
|
||||
file_rights = file.stat().st_mode
|
||||
rights_to_set = file_rights | 0o111
|
||||
file.chmod(rights_to_set)
|
||||
|
||||
|
||||
def save_and_make_executable(destination: Path, content: bytes):
|
||||
save(destination, content)
|
||||
set_execution_rights(destination)
|
Loading…
Add table
Add a link
Reference in a new issue