FIX Previous commit with writing of shell script
This commit is contained in:
@@ -1,5 +1,19 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
from os import chmod
|
||||||
|
|
||||||
|
|
||||||
def sanitize_filename(filename: str) -> str:
|
def sanitize_filename(filename: str) -> str:
|
||||||
characters_not_allowed = ["<", ">", ":", '"', "/", "\\", "|", "?", "*", " ", "'"]
|
characters_not_allowed = ["<", ">", ":", '"', "/", "\\", "|", "?", "*", " ", "'"]
|
||||||
for char in characters_not_allowed:
|
for char in characters_not_allowed:
|
||||||
filename = filename.replace(char, "")
|
filename = filename.replace(char, "")
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
|
def write_shell_script(script: str, filename: Path):
|
||||||
|
if filename.exists():
|
||||||
|
raise FileExistsError("encode.sh already exists")
|
||||||
|
with open(filename, "w") as f:
|
||||||
|
f.write("#!/bin/bash\n")
|
||||||
|
f.write(script)
|
||||||
|
|
||||||
|
chmod(filename, 0o755)
|
||||||
|
|||||||
Reference in New Issue
Block a user