19 Commits

Author SHA1 Message Date
1e801fb3e8 Ignore minor python version (pipenv)? 2020-12-17 04:18:18 -08:00
7ff6803390 Merge branch 'master' into dev 2020-12-16 19:58:45 -08:00
987aed63eb Merge branch 'master' of ssh://git.mikeperalta.com:3222/misc-utilities/mikes-backup-rotator 2020-12-16 19:57:49 -08:00
26afc6a346 Merge branch 'dev' of ssh://git.mikeperalta.com:3222/misc-utilities/mikes-backup-rotator into dev 2020-12-16 19:57:44 -08:00
609cdbd5c5 Pipenv -> Go back down to python 3.6 because we're having major pyenv issues with higher versions 2020-06-15 16:20:40 -07:00
985a5b6b69 Bump python to 3.8 in pipenv 2020-06-15 11:48:56 -07:00
da4c0671e1 Write to syslog as well 2020-01-02 18:06:09 -08:00
0e4a09ae13 Adding pipenv ! 2020-01-02 17:19:55 -08:00
81803f36f1 noop to test hook 2020-01-02 10:54:44 -08:00
2488127b9c noop to test hook 2020-01-02 10:53:59 -08:00
7aaea3746f Merge branch 'master' of ssh://gogs.mikeperalta.com:2222/mikeperalta/backup-rotator 2019-12-28 12:00:20 -08:00
95840f10d4 Make main.py executable 2019-11-19 04:43:23 -08:00
644a023d5d ignore pycache 2019-11-19 04:43:17 -08:00
66951ce1ae rename to avoid bad identifiers 2019-11-19 04:41:38 -08:00
8232776e41 Bad env path? 2019-08-30 16:14:18 -07:00
ebfcdeb70b Noop to test hook 2019-08-06 16:42:09 -07:00
13deb5677b Changing yaml.load() to yaml.safe_load() 2019-07-16 12:06:20 -07:00
b750f65311 Tweak log output 2019-03-13 04:24:38 -07:00
3a18c1fad8 Set script to executable 2019-03-13 03:32:39 -07:00
5 changed files with 79 additions and 14 deletions

4
.gitignore vendored
View File

@ -3,4 +3,8 @@
# Ignore PyCharm
.idea
#
__pycache__

21
backup-rotator → BackupRotator.py Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!/usr/env python3
#!/usr/bin/env python3
"""
@ -16,6 +16,7 @@ import datetime
import os
import shutil
import sys
import syslog
import yaml
@ -59,6 +60,8 @@ class BackupRotator:
if o is not None:
to_log += " " + str(o)
syslog.syslog(to_log)
print(to_log)
def consume_arguments(self):
@ -72,11 +75,11 @@ class BackupRotator:
if arg == "--config":
i, one_path = self.consume_argument_companion(i)
self.__config_paths.append(one_path)
print("Found config path argument:", one_path)
self.log("Found config path argument:", one_path)
elif arg == "--dry-run":
self.__dry_run = True
print("Activating global dry-run mode")
self.log("Activating global dry-run mode")
@staticmethod
def consume_argument_companion(arg_index):
@ -114,7 +117,7 @@ class BackupRotator:
raise Exception("Unable to open config file: " + path)
# Parse
config = yaml.load(f)
config = yaml.safe_load(f)
# Add its own path
config["__path"] = path
@ -246,13 +249,3 @@ class BackupRotator:
else:
self.log("Purging directory:", dir_path)
shutil.rmtree(dir_path)
def main():
rotator = BackupRotator()
rotator.run()
if __name__ == "__main__":
main()

13
Pipfile Normal file
View File

@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pyyaml = "*"
[dev-packages]
[requires]
python_version = "3"

40
Pipfile.lock generated Normal file
View File

@ -0,0 +1,40 @@
{
"_meta": {
"hash": {
"sha256": "25d0d6f494ae55bc9fa72711e1e8edb7e3d6b7ce72e6254d2ec85bd3b0e637bd"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.python.org/simple",
"verify_ssl": true
}
]
},
"default": {
"pyyaml": {
"hashes": [
"sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97",
"sha256:240097ff019d7c70a4922b6869d8a86407758333f02203e0fc6ff79c5dcede76",
"sha256:4f4b913ca1a7319b33cfb1369e91e50354d6f07a135f3b901aca02aa95940bd2",
"sha256:6034f55dab5fea9e53f436aa68fa3ace2634918e8b5994d82f3621c04ff5ed2e",
"sha256:69f00dca373f240f842b2931fb2c7e14ddbacd1397d57157a9b005a6a9942648",
"sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf",
"sha256:74809a57b329d6cc0fdccee6318f44b9b8649961fa73144a98735b0aaf029f1f",
"sha256:7739fc0fa8205b3ee8808aea45e968bc90082c10aef6ea95e855e10abf4a37b2",
"sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee",
"sha256:ad9c67312c84def58f3c04504727ca879cb0013b2517c85a9a253f0cb6380c0a",
"sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d",
"sha256:cc8955cfbfc7a115fa81d85284ee61147059a753344bc51098f3ccd69b0d7e0c",
"sha256:d13155f591e6fcc1ec3b30685d50bf0711574e2c0dfffd7644babf8b5102ca1a"
],
"index": "pypi",
"version": "==5.3.1"
}
},
"develop": {}
}

15
main.py Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env python3
from BackupRotator import BackupRotator
#
def main():
rotator = BackupRotator()
rotator.run()
if __name__ == "__main__":
main()