2015-05-13 16:14:46 -07:00
|
|
|
@setlocal enabledelayedexpansion && py -3 -x "%~f0" %* & exit /b !ERRORLEVEL!
|
|
|
|
#start python code here
|
|
|
|
import zipfile
|
|
|
|
import datetime
|
|
|
|
import os, sys, shutil
|
|
|
|
from glob import glob
|
2015-05-16 11:37:29 -07:00
|
|
|
import pathlib
|
2015-05-13 16:14:46 -07:00
|
|
|
from pathlib import Path
|
2015-05-16 11:37:29 -07:00
|
|
|
import pprint
|
2015-05-16 16:31:08 -07:00
|
|
|
import msvcrt
|
2015-05-17 10:42:01 -07:00
|
|
|
verbose = True
|
2015-05-13 16:14:46 -07:00
|
|
|
|
2015-05-16 11:37:29 -07:00
|
|
|
root = Path('.').resolve().parent.parent
|
2015-05-16 17:20:25 -07:00
|
|
|
boxdir = root / "Box Sync" / "TIJ4-ebook-Backups"
|
2015-05-16 11:37:29 -07:00
|
|
|
gdrive = root / "Google Drive" / "TIJ4RefreshedBackups"
|
|
|
|
idrive = root / "IDrive-Sync" / "TIJ4-ebook-Backups"
|
2015-05-13 16:14:46 -07:00
|
|
|
|
2015-05-17 10:42:01 -07:00
|
|
|
def cp(src, dest, display=True, shortForm=False):
|
2015-05-16 11:37:29 -07:00
|
|
|
if type(src) is pathlib.WindowsPath:
|
|
|
|
name = src.name
|
|
|
|
else:
|
|
|
|
name = src
|
|
|
|
if display:
|
2015-05-17 10:42:01 -07:00
|
|
|
if shortForm:
|
|
|
|
print(name)
|
|
|
|
else:
|
|
|
|
print("\ncopying", name)
|
|
|
|
print("to:", dest)
|
2015-05-16 11:37:29 -07:00
|
|
|
shutil.copy(str(src), str(dest))
|
2015-05-13 16:14:46 -07:00
|
|
|
|
|
|
|
now = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M")
|
|
|
|
zip_file_name = 'TIJDirectorsCut-' + now + '.zip'
|
2015-05-16 11:37:29 -07:00
|
|
|
dest = boxdir / zip_file_name
|
2015-05-17 10:42:01 -07:00
|
|
|
print(dest)
|
2015-05-16 11:37:29 -07:00
|
|
|
tozip = ["Notes.txt", "backup.bat", "go.bat"] + glob("*.py") + glob("*.docx") + glob("*.docm")
|
2015-05-13 16:14:46 -07:00
|
|
|
|
2015-05-16 11:37:29 -07:00
|
|
|
with zipfile.ZipFile(str(dest), 'w') as myzip:
|
|
|
|
for f in tozip:
|
2015-05-13 16:14:46 -07:00
|
|
|
myzip.write(f)
|
2015-05-17 10:42:01 -07:00
|
|
|
if verbose:
|
|
|
|
print("adding {}".format(f))
|
2015-05-13 16:14:46 -07:00
|
|
|
|
2015-05-16 11:37:29 -07:00
|
|
|
cp(dest, gdrive)
|
|
|
|
cp(dest, idrive)
|
2015-05-13 16:14:46 -07:00
|
|
|
|
2015-05-16 11:37:29 -07:00
|
|
|
shortcut = Path(r"C:\Python34\Scripts")
|
2015-05-27 23:22:27 -07:00
|
|
|
tools = ["Examples.py", "Validate.py", "backup.bat", "go.bat", "StripLastBlankLine.py", "update_git.py",
|
2015-05-29 12:09:16 -07:00
|
|
|
shortcut / "v.bat", shortcut / "e.bat", shortcut / "g.bat"]
|
2015-05-16 11:37:29 -07:00
|
|
|
|
2015-05-17 10:42:01 -07:00
|
|
|
print("\nCopying tools to Github")
|
2015-05-16 11:37:29 -07:00
|
|
|
for tool in tools:
|
2015-05-17 10:42:01 -07:00
|
|
|
cp(tool, root / "Documents" / "GitHub" / "TIJ-Directors-Cut" / "tools", shortForm=True)
|
2015-05-13 16:14:46 -07:00
|
|
|
|
|
|
|
# Touch this file to indicate most recent update time:
|
|
|
|
os.utime("backup.bat", None)
|
2015-05-16 16:31:08 -07:00
|
|
|
msvcrt.getch()
|