Skip to content

Commit 7da840f

Browse files
author
Bruce Eckel
committed
tuning
1 parent 6beb47d commit 7da840f

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

tools/backup.bat

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,37 @@ import pathlib
88
from pathlib import Path
99
import pprint
1010
import msvcrt
11+
verbose = True
1112

1213
root = Path('.').resolve().parent.parent
1314
boxdir = root / "Box Sync" / "TIJ4-ebook-Backups"
1415
gdrive = root / "Google Drive" / "TIJ4RefreshedBackups"
1516
idrive = root / "IDrive-Sync" / "TIJ4-ebook-Backups"
1617

17-
def cp(src, dest, display=True):
18+
def cp(src, dest, display=True, shortForm=False):
1819
if type(src) is pathlib.WindowsPath:
1920
name = src.name
2021
else:
2122
name = src
2223
if display:
23-
print("copying", name)
24-
print("to:", dest, "\n")
24+
if shortForm:
25+
print(name)
26+
else:
27+
print("\ncopying", name)
28+
print("to:", dest)
2529
shutil.copy(str(src), str(dest))
2630

2731
now = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M")
2832
zip_file_name = 'TIJDirectorsCut-' + now + '.zip'
2933
dest = boxdir / zip_file_name
30-
print(dest, "\n")
34+
print(dest)
3135
tozip = ["Notes.txt", "backup.bat", "go.bat"] + glob("*.py") + glob("*.docx") + glob("*.docm")
3236

3337
with zipfile.ZipFile(str(dest), 'w') as myzip:
3438
for f in tozip:
3539
myzip.write(f)
40+
if verbose:
41+
print("adding {}".format(f))
3642

3743
cp(dest, gdrive)
3844
cp(dest, idrive)
@@ -41,9 +47,9 @@ shortcut = Path(r"C:\Python34\Scripts")
4147
tools = ["Examples.py", "Validate.py", "backup.bat", "go.bat", "StripLastBlankLine.py",
4248
shortcut / "v.bat", shortcut / "e.bat"]
4349

44-
print("copying tools to Github")
50+
print("\nCopying tools to Github")
4551
for tool in tools:
46-
cp(tool, root / "Documents" / "GitHub" / "TIJ-Directors-Cut" / "tools", False)
52+
cp(tool, root / "Documents" / "GitHub" / "TIJ-Directors-Cut" / "tools", shortForm=True)
4753

4854
# Touch this file to indicate most recent update time:
4955
os.utime("backup.bat", None)

0 commit comments

Comments
 (0)