"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Tardis/CacheDir.py" between
Tardis-1.1.1.tar.gz and Tardis-1.1.2.tar.gz

About: Tardis is a system for making encrypted, incremental backups of filesystems.

CacheDir.py  (Tardis-1.1.1):CacheDir.py  (Tardis-1.1.2)
# vim: set et sw=4 sts=4 fileencoding=utf-8: # vim: set et sw=4 sts=4 fileencoding=utf-8:
# #
# Tardis: A Backup System # Tardis: A Backup System
# Copyright 2013-2016, Eric Koldinger, All Rights Reserved. # Copyright 2013-2019, Eric Koldinger, All Rights Reserved.
# kolding@washington.edu # kolding@washington.edu
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
# #
# * Redistributions of source code must retain the above copyright # * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer. # notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright # * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the # notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. # documentation and/or other materials provided with the distribution.
skipping to change at line 38 skipping to change at line 38
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
import os import os
import os.path import os.path
import socket import socket
import logging import logging
import shutil import shutil
import configparser import configparser
from . import Defaults
from functools import reduce from functools import reduce
from . import Defaults
logger = logging.getLogger("CacheDir") logger = logging.getLogger("CacheDir")
class CacheDirDoesNotExist(Exception): class CacheDirDoesNotExist(Exception):
pass pass
PARTSIZE = "partsize" PARTSIZE = "partsize"
PARTS = "parts" PARTS = "parts"
CONFIGFILE = ".cachedir" CONFIGFILE = ".cachedir"
class CacheDir(object): class CacheDir:
def __init__(self, root, parts=2, partsize=2, create=True, user=None, group= None, skipFile=Defaults.getDefault("TARDIS_SKIP")): def __init__(self, root, parts=2, partsize=2, create=True, user=None, group= None, skipFile=Defaults.getDefault("TARDIS_SKIP")):
self.root = os.path.abspath(root) self.root = os.path.abspath(root)
self.user = user if user else -1 self.user = user if user else -1
self.group = group if group else -1 self.group = group if group else -1
self.chown = user or group self.chown = user or group
if not os.path.isdir(self.root): if not os.path.isdir(self.root):
if create: if create:
os.makedirs(self.root) os.makedirs(self.root)
if self.chown: if self.chown:
skipping to change at line 176 skipping to change at line 177
def move(self, oldname, newname): def move(self, oldname, newname):
try: try:
self.mkdir(newname) self.mkdir(newname)
os.rename(self.path(oldname), self.path(newname)) os.rename(self.path(oldname), self.path(newname))
return True return True
except OSError: except OSError:
return False return False
if __name__ == "__main__": if __name__ == "__main__":
test = "abcdefghijklmnop" test = "abcdefghijklmnop"
path = os.path.join("cache", socket.gethostname()) testPath = os.path.join("cache", socket.gethostname())
c = CacheDir(path, 4, 2, True) c = CacheDir(testPath, 4, 2, True)
print(c.comps(test)) print(c.comps(test))
print(c.dirPath(test)) print(c.dirPath(test))
print(c.path(test)) print(c.path(test))
print(c.exists(test)) print(c.exists(test))
try: try:
c.open(test, "r") c.open(test, "r")
except IOError as ex: except IOError as ex:
print("Caught IOError") print("Caught IOError")
 End of changes. 5 change blocks. 
5 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)