Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
1e801fb3e8 | |||
7ff6803390 | |||
987aed63eb | |||
26afc6a346 | |||
609cdbd5c5 | |||
985a5b6b69 | |||
da4c0671e1 | |||
0e4a09ae13 | |||
81803f36f1 | |||
2488127b9c | |||
7aaea3746f | |||
95840f10d4 | |||
644a023d5d | |||
66951ce1ae | |||
8232776e41 | |||
ebfcdeb70b | |||
13deb5677b | |||
b750f65311 | |||
3a18c1fad8 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,4 +3,8 @@
|
||||
# Ignore PyCharm
|
||||
.idea
|
||||
|
||||
#
|
||||
__pycache__
|
||||
|
||||
|
||||
|
||||
|
21
backup-rotator → BackupRotator.py
Normal file → Executable file
21
backup-rotator → BackupRotator.py
Normal file → Executable 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
13
Pipfile
Normal 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
40
Pipfile.lock
generated
Normal 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": {}
|
||||
}
|
Reference in New Issue
Block a user