Reformatted DataPuller.py
This commit is contained in:
parent
5fc7602ea7
commit
348f71ba69
1 changed files with 31 additions and 13 deletions
|
|
@ -7,14 +7,15 @@ import filecmp
|
|||
|
||||
# Argument Parsing
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='DataPuller',
|
||||
description='Check differences between folders and update files if needed')
|
||||
prog="DataPuller",
|
||||
description="Check differences between folders and update files if needed",
|
||||
)
|
||||
|
||||
parser.add_argument('-i', '--input')
|
||||
parser.add_argument('-o', '--output')
|
||||
parser.add_argument('-q', '--quiet', action='store_true')
|
||||
parser.add_argument('-y', '--confirm', action="store_true")
|
||||
parser.add_argument('-d', '--delete', action="store_true")
|
||||
parser.add_argument("-i", "--input")
|
||||
parser.add_argument("-o", "--output")
|
||||
parser.add_argument("-q", "--quiet", action="store_true")
|
||||
parser.add_argument("-y", "--confirm", action="store_true")
|
||||
parser.add_argument("-d", "--delete", action="store_true")
|
||||
parser.add_argument("--dryrun", action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
|
@ -29,6 +30,7 @@ if not args.output:
|
|||
else:
|
||||
outpath = args.output
|
||||
|
||||
|
||||
def get_files(path):
|
||||
file_info = {}
|
||||
if not os.path.exists(path):
|
||||
|
|
@ -48,10 +50,13 @@ def get_files(path):
|
|||
pass
|
||||
return file_info
|
||||
|
||||
|
||||
def main():
|
||||
startstring = " FOLDER-SYNC 1.0 "
|
||||
if not args.quiet:
|
||||
print(len(startstring)*"=" + "\n" + startstring + "\n" + len(startstring)*"=")
|
||||
print(
|
||||
len(startstring) * "=" + "\n" + startstring + "\n" + len(startstring) * "="
|
||||
)
|
||||
|
||||
# Test Folder availability
|
||||
if not os.path.exists((inpath)):
|
||||
|
|
@ -116,7 +121,9 @@ def main():
|
|||
if args.confirm:
|
||||
copy_confirm = "y"
|
||||
else:
|
||||
copy_confirm = input("Write new and changed files? (y/N): ").strip().lower()
|
||||
copy_confirm = (
|
||||
input("Write new and changed files? (y/N): ").strip().lower()
|
||||
)
|
||||
if copy_confirm in ["ja", "j", "yes", "y"]:
|
||||
if not args.quiet:
|
||||
print("\nCopying files...")
|
||||
|
|
@ -135,7 +142,12 @@ def main():
|
|||
except Exception as error:
|
||||
print(f"Failed to copy {path} with error {error}")
|
||||
if not args.confirm:
|
||||
if not input("Continue? (y/N): ") in ["ja", "j", "yes", "y"]:
|
||||
if not input("Continue? (y/N): ") in [
|
||||
"ja",
|
||||
"j",
|
||||
"yes",
|
||||
"y",
|
||||
]:
|
||||
exit(1)
|
||||
elif not args.quiet:
|
||||
print("\nSkipping changes...")
|
||||
|
|
@ -149,7 +161,9 @@ def main():
|
|||
if args.delete:
|
||||
delete_confirm = "y"
|
||||
else:
|
||||
delete_confirm = input("Delete files on the target? (y/N): ").strip().lower()
|
||||
delete_confirm = (
|
||||
input("Delete files on the target? (y/N): ").strip().lower()
|
||||
)
|
||||
if delete_confirm in ["ja", "j", "yes", "y"]:
|
||||
if not args.quiet:
|
||||
print("\nDeleting files...")
|
||||
|
|
@ -162,7 +176,12 @@ def main():
|
|||
except Exception as error:
|
||||
print(f"Failed to delete {path} with error {error}")
|
||||
if not args.confirm:
|
||||
if not input("Continue? (y/N): ") in ["ja", "j", "yes", "y"]:
|
||||
if not input("Continue? (y/N): ") in [
|
||||
"ja",
|
||||
"j",
|
||||
"yes",
|
||||
"y",
|
||||
]:
|
||||
exit(1)
|
||||
elif not args.quiet:
|
||||
print("\nSkipping deletion...")
|
||||
|
|
@ -172,6 +191,5 @@ def main():
|
|||
input("\nPress ENTER to exit...")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue