Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/smshex_r.../opt/tier2c
File: mv_backup.py
#!/opt/imh-python/bin/python3
[0] Fix | Delete
"""Move cpanel backups to and from /home"""
[1] Fix | Delete
from pathlib import Path
[2] Fix | Delete
import argparse
[3] Fix | Delete
import shlex
[4] Fix | Delete
import sys
[5] Fix | Delete
[6] Fix | Delete
sys.path.insert(0, '/opt/support/lib')
[7] Fix | Delete
from arg_types import cpmove_file_type, path_in_home
[8] Fix | Delete
[9] Fix | Delete
[10] Fix | Delete
def parse_args() -> tuple[Path, Path]:
[11] Fix | Delete
"""Validate and return source and destination paths"""
[12] Fix | Delete
parser = argparse.ArgumentParser(description=__doc__)
[13] Fix | Delete
parser.add_argument(
[14] Fix | Delete
'src',
[15] Fix | Delete
metavar='SOURCE',
[16] Fix | Delete
type=cpmove_file_type,
[17] Fix | Delete
help='cPanel backup file',
[18] Fix | Delete
)
[19] Fix | Delete
parser.add_argument(
[20] Fix | Delete
'dst',
[21] Fix | Delete
metavar='DESTINATION',
[22] Fix | Delete
type=path_in_home,
[23] Fix | Delete
help='destination folder',
[24] Fix | Delete
)
[25] Fix | Delete
args = parser.parse_args()
[26] Fix | Delete
return args.src, args.dst
[27] Fix | Delete
[28] Fix | Delete
[29] Fix | Delete
def main():
[30] Fix | Delete
"""Validate input, then move a cpanel backup in or out of /home"""
[31] Fix | Delete
source, dest_dir = parse_args()
[32] Fix | Delete
dest = dest_dir.joinpath(source.name)
[33] Fix | Delete
# perform the move
[34] Fix | Delete
try:
[35] Fix | Delete
print(shlex.quote(str(source)), '->', shlex.quote(str(dest)))
[36] Fix | Delete
source.rename(dest)
[37] Fix | Delete
except OSError as exc:
[38] Fix | Delete
sys.exit(exc)
[39] Fix | Delete
[40] Fix | Delete
[41] Fix | Delete
if __name__ == '__main__':
[42] Fix | Delete
main()
[43] Fix | Delete
[44] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function