Removed unused logic in get_files()
This commit is contained in:
parent
348f71ba69
commit
9e362e730c
2 changed files with 12 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -241,3 +241,4 @@ cython_debug/
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
.test/
|
||||||
|
|
|
||||||
27
DataPuller.py
Normal file → Executable file
27
DataPuller.py
Normal file → Executable file
|
|
@ -1,9 +1,9 @@
|
||||||
#! /usr/bin/python3
|
#! /usr/bin/python3
|
||||||
|
|
||||||
import os
|
|
||||||
import argparse
|
import argparse
|
||||||
import shutil
|
|
||||||
import filecmp
|
import filecmp
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
# Argument Parsing
|
# Argument Parsing
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
|
|
@ -16,7 +16,7 @@ parser.add_argument("-o", "--output")
|
||||||
parser.add_argument("-q", "--quiet", action="store_true")
|
parser.add_argument("-q", "--quiet", action="store_true")
|
||||||
parser.add_argument("-y", "--confirm", action="store_true")
|
parser.add_argument("-y", "--confirm", action="store_true")
|
||||||
parser.add_argument("-d", "--delete", action="store_true")
|
parser.add_argument("-d", "--delete", action="store_true")
|
||||||
parser.add_argument("--dryrun", action="store_true")
|
parser.add_argument("--dry-run", action="store_true")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ else:
|
||||||
|
|
||||||
|
|
||||||
def get_files(path):
|
def get_files(path):
|
||||||
file_info = {}
|
file_info = []
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return file_info
|
return file_info
|
||||||
|
|
||||||
|
|
@ -40,14 +40,7 @@ def get_files(path):
|
||||||
for file in files:
|
for file in files:
|
||||||
full_path = os.path.join(folder, file)
|
full_path = os.path.join(folder, file)
|
||||||
rel_path = os.path.relpath(full_path, path)
|
rel_path = os.path.relpath(full_path, path)
|
||||||
try:
|
file_info.append(rel_path)
|
||||||
stat = os.stat(full_path)
|
|
||||||
file_info[rel_path] = {
|
|
||||||
"size": stat.st_size,
|
|
||||||
"modified": stat.st_mtime,
|
|
||||||
}
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return file_info
|
return file_info
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -59,7 +52,7 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test Folder availability
|
# Test Folder availability
|
||||||
if not os.path.exists((inpath)):
|
if not os.path.exists(inpath):
|
||||||
print(f"ERROR: The input folder ({inpath}) is unavailable or non-existant.")
|
print(f"ERROR: The input folder ({inpath}) is unavailable or non-existant.")
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
input("\nPress ENTER to exit...")
|
input("\nPress ENTER to exit...")
|
||||||
|
|
@ -81,7 +74,7 @@ def main():
|
||||||
deleted = []
|
deleted = []
|
||||||
|
|
||||||
# Check for file additions and changes
|
# Check for file additions and changes
|
||||||
for path, info in source.items():
|
for path in source:
|
||||||
if path not in target:
|
if path not in target:
|
||||||
new.append(path)
|
new.append(path)
|
||||||
elif not filecmp.cmp(os.path.join(inpath, path), os.path.join(outpath, path)):
|
elif not filecmp.cmp(os.path.join(inpath, path), os.path.join(outpath, path)):
|
||||||
|
|
@ -110,13 +103,15 @@ 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.dryrun:
|
if not args.dry_run:
|
||||||
if new or changed:
|
if new or changed:
|
||||||
if args.confirm:
|
if args.confirm:
|
||||||
copy_confirm = "y"
|
copy_confirm = "y"
|
||||||
|
|
@ -153,7 +148,7 @@ def main():
|
||||||
print("\nSkipping changes...")
|
print("\nSkipping changes...")
|
||||||
|
|
||||||
# Delete files
|
# Delete files
|
||||||
if not args.dryrun:
|
if not args.dry_run:
|
||||||
if deleted:
|
if deleted:
|
||||||
alert = " ALERT: Some files only exist at the destination. "
|
alert = " ALERT: Some files only exist at the destination. "
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue