From: Peter Schaefer Date: Sat, 28 Sep 2019 12:04:15 +0000 (+0200) Subject: added initial compress titbackup script X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;p=tex_tools.git added initial compress titbackup script --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92d5220 --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +**/.vscode + +# Latex files + +*.aux +*.glo +*.idx +*.log +*.toc +*.ist +*.acn +*.acr +*.alg +*.bbl +*.blg +*.tui +*.top +*.tmp +*.mp +*.dvi +*.glg +*.gls +*.ilg +*.ind +*.lof +*.lot +*.maf +*.mtc +*.mtc1 +*.out +*.synctex.gz +*.synctex(busy) +*.fdb_latexmk +*.fls diff --git a/file_compress/.gitignore b/file_compress/.gitignore new file mode 100644 index 0000000..6f30a3a --- /dev/null +++ b/file_compress/.gitignore @@ -0,0 +1 @@ +/example diff --git a/file_compress/bash_zip.py b/file_compress/bash_zip.py new file mode 100644 index 0000000..2ff0736 --- /dev/null +++ b/file_compress/bash_zip.py @@ -0,0 +1,70 @@ +import os +import datetime +import tarfile +import re +import shutil + +_month = set() +_other = set() + +os.chdir("example") + +def archives(name): + if(re.match(r'\d{4}.apk.tar.gz',name)): + return False + if(re.match(r'\d{6}.tar.gz',name)): + return False + if(name == 'apk.tmp'): + return False + return True + +#find all date groups and other files +for file in filter(archives,os.listdir()): + _split = file.split("-") + # print(file + " " + str(len(_split))) + if(len(_split) > 2): + if(len(_split[-2]) == 8): + _month.add(_split[-2][0:6]) + else: + _other.add(file) + else: + _other.add(file) + +#remove most recent from compressing +_today = datetime.datetime.today() +if _today.strftime("%Y%m") in _month: + _month.remove(_today.strftime("%Y%m")) +if (_today+datetime.timedelta(days=20)).strftime("%Y%m") in _month: + _month.remove((_today-datetime.timedelta(days=15)).strftime("%Y%m")) + + + +#compress date groups + +for date in _month: + if os.path.isfile(date + ".tar.gz"): + os.system("tar -xzkf " + date + ".tar.gz") + os.system("tar -czf " + date + ".tar.gz " + "*-" + date + "*" ) + #shutil.rmtree("*-" + date + "*") + os.system("del *-" + date + "*") +#print(_month) +#print(_other) + + + +#compress other +if(len(_other)>0): + _otherjoined = ' '.join(_other) + if os.path.isfile(_today.strftime("%Y") + ".apk.tar.gz"): + if not os.path.isdir("apk.tmp"): + os.mkdir("apk.tmp") + for move in _other: + os.system("move " + move + ' apk.tmp/') + os.system("tar -xzkf" + _today.strftime("%Y") + ".apk.tar.gz" + " -C apk.tmp") + os.chdir("apk.tmp") + os.system("tar -czf ../" + _today.strftime("%Y") + ".apk.tar.gz *") + os.chdir("..") + shutil.rmtree("apk.tmp") + else: + os.system("tar -czf " + _today.strftime("%Y") + ".apk.tar.gz " + _otherjoined) + os.system("del " + _otherjoined) diff --git a/file_compress/createTestFiles.py b/file_compress/createTestFiles.py new file mode 100644 index 0000000..fe7ccca --- /dev/null +++ b/file_compress/createTestFiles.py @@ -0,0 +1,21 @@ +import os +import random +import string +import datetime + +letter = string.ascii_letters + + +for i in range(10): + _random = ''.join(random.choice(letter) for i in range(20)) + _date = datetime.datetime.today() - datetime.timedelta(hours=random.randint(0,4*30*24)) + + _name = _random + "-" + _date.strftime("%Y%m%d-%I%M%S") + ".tar.gz" + + print(_name) + open(os.path.join("example", _name ), 'a').close() + + +for i in range(2): + _random = ''.join(random.choice(letter) for i in range(20)) + open(os.path.join("example", _random + ".tar.gz" ), 'a').close() \ No newline at end of file diff --git a/git_tools/.gitattributes b/git_tools/.gitattributes new file mode 100644 index 0000000..9280cf1 --- /dev/null +++ b/git_tools/.gitattributes @@ -0,0 +1 @@ +use_cases_web.pdf merge=f_ours \ No newline at end of file diff --git a/git_tools/.gitignore b/git_tools/.gitignore new file mode 100644 index 0000000..d3fe8f3 --- /dev/null +++ b/git_tools/.gitignore @@ -0,0 +1,32 @@ +# Latex files + +*.aux +*.glo +*.idx +*.log +*.toc +*.ist +*.acn +*.acr +*.alg +*.bbl +*.blg +*.tui +*.top +*.tmp +*.mp +*.dvi +*.glg +*.gls +*.ilg +*.ind +*.lof +*.lot +*.maf +*.mtc +*.mtc1 +*.out +*.synctex.gz +*.synctex(busy) +*.fdb_latexmk +*.fls diff --git a/git_tools/enable_autoBuild_pdf.sh b/git_tools/enable_autoBuild_pdf.sh index e4aad96..b7c6e43 100644 --- a/git_tools/enable_autoBuild_pdf.sh +++ b/git_tools/enable_autoBuild_pdf.sh @@ -11,7 +11,6 @@ if [ -e $DESTFILE ]; then cat $SOURCEFILE >> $DESTFILE fi else - echo "create new $DESTFILE..." echo "create new $DESTFILE..." cp $SOURCEFILE $DESTFILE fi