Merge Datapuller work
This commit is contained in:
parent
fe6944fb11
commit
7dfaccbafe
1 changed files with 28 additions and 16 deletions
|
|
@ -1,22 +1,34 @@
|
||||||
#! /usr/bin/python3
|
#! /usr/bin/python3
|
||||||
|
|
||||||
import argparse
|
|
||||||
import filecmp
|
|
||||||
import os
|
import os
|
||||||
|
import argparse
|
||||||
import shutil
|
import shutil
|
||||||
|
import filecmp
|
||||||
|
|
||||||
# Argument Parsing
|
# Argument Parsing
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog="DataPuller",
|
prog='DataPuller',
|
||||||
description="Check differences between folders and update files if needed",
|
description='Check differences between folders and update files if needed')
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument("-i", "--input")
|
parser.add_argument("-i", "--input", help="Path to input folder")
|
||||||
parser.add_argument("-o", "--output")
|
parser.add_argument("-o", "--output", help="Path to output folder")
|
||||||
parser.add_argument("-q", "--quiet", action="store_true")
|
parser.add_argument(
|
||||||
parser.add_argument("-y", "--confirm", action="store_true")
|
"-q",
|
||||||
parser.add_argument("-d", "--delete", action="store_true")
|
"--quiet",
|
||||||
parser.add_argument("--dry-run", action="store_true")
|
action="store_true",
|
||||||
|
help="Suppress non-essential commandline output",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-y", "--confirm", action="store_true", help="Auto-confirm user queries"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-d", "--delete", action="store_true", help="Auto-confirm file deletion"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--dry-run",
|
||||||
|
action="store_true",
|
||||||
|
help="List affected files without copying or deleting",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
@ -30,7 +42,6 @@ if not args.output:
|
||||||
else:
|
else:
|
||||||
outpath = args.output
|
outpath = args.output
|
||||||
|
|
||||||
|
|
||||||
def get_files(path):
|
def get_files(path):
|
||||||
file_info = []
|
file_info = []
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
|
|
@ -43,7 +54,6 @@ def get_files(path):
|
||||||
file_info.append(rel_path)
|
file_info.append(rel_path)
|
||||||
return file_info
|
return file_info
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
startstring = " FOLDER-SYNC 1.0 "
|
startstring = " FOLDER-SYNC 1.0 "
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
|
|
@ -103,12 +113,10 @@ def main():
|
||||||
print("Changed:")
|
print("Changed:")
|
||||||
for i in changed:
|
for i in changed:
|
||||||
print(f" ~ {i}")
|
print(f" ~ {i}")
|
||||||
print()
|
|
||||||
if deleted:
|
if deleted:
|
||||||
print("Deleted:")
|
print("Deleted:")
|
||||||
for i in deleted:
|
for i in deleted:
|
||||||
print(f" - {i}")
|
print(f" - {i}")
|
||||||
print()
|
|
||||||
|
|
||||||
# Copy and update files
|
# Copy and update files
|
||||||
if not args.dry_run:
|
if not args.dry_run:
|
||||||
|
|
@ -182,9 +190,13 @@ def main():
|
||||||
print("\nSkipping deletion...")
|
print("\nSkipping deletion...")
|
||||||
|
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
|
if not args.dry_run:
|
||||||
print("\nFolder sync finished!")
|
print("\nFolder sync finished!")
|
||||||
|
else:
|
||||||
|
print("\nDry run complete!")
|
||||||
input("\nPress ENTER to exit...")
|
input("\nPress ENTER to exit...")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue