[cedar-backup-svn] SF.net SVN: cedar-backup: [861] cedar-backup2/trunk/CedarBackup2
Brought to you by:
pronovic
|
From: <pro...@us...> - 2008-03-18 03:45:48
|
Revision: 861
http://cedar-backup.svn.sourceforge.net/cedar-backup/?rev=861&view=rev
Author: pronovic
Date: 2008-03-17 20:45:42 -0700 (Mon, 17 Mar 2008)
Log Message:
-----------
Add a bytes attribute to ByteQuantity
Modified Paths:
--------------
cedar-backup2/trunk/CedarBackup2/config.py
cedar-backup2/trunk/CedarBackup2/extend/split.py
Modified: cedar-backup2/trunk/CedarBackup2/config.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/config.py 2008-03-18 02:55:08 UTC (rev 860)
+++ cedar-backup2/trunk/CedarBackup2/config.py 2008-03-18 03:45:42 UTC (rev 861)
@@ -246,7 +246,7 @@
from CedarBackup2.writers.util import validateScsiId, validateDriveSpeed
from CedarBackup2.util import UnorderedList, AbsolutePathList, ObjectTypeList
from CedarBackup2.util import RegexMatchList, RegexList, encodePath
-from CedarBackup2.util import UNIT_BYTES, UNIT_KBYTES, UNIT_MBYTES, UNIT_GBYTES
+from CedarBackup2.util import convertSize, UNIT_BYTES, UNIT_KBYTES, UNIT_MBYTES, UNIT_GBYTES
from CedarBackup2.xmlutil import isElement, readChildren, readFirstChild
from CedarBackup2.xmlutil import readStringList, readString, readInteger, readBoolean
from CedarBackup2.xmlutil import addContainerNode, addStringNode, addIntegerNode, addBooleanNode
@@ -391,8 +391,15 @@
"""
return self._units
+ def _getBytes(self):
+ """
+ Property target used to return the byte quantity as a floating point number.
+ """
+ return float(convertSize(self.quantity, self.units, UNIT_BYTES))
+
quantity = property(_getQuantity, _setQuantity, None, doc="Byte quantity, as a string")
units = property(_getUnits, _setUnits, None, doc="Units for byte quantity, for instance UNIT_BYTES")
+ bytes = property(_getBytes, None, None, doc="Byte quantity, as a floating point number.")
########################################################################
Modified: cedar-backup2/trunk/CedarBackup2/extend/split.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/extend/split.py 2008-03-18 02:55:08 UTC (rev 860)
+++ cedar-backup2/trunk/CedarBackup2/extend/split.py 2008-03-18 03:45:42 UTC (rev 861)
@@ -65,7 +65,7 @@
# Cedar Backup modules
from CedarBackup2.filesystem import FilesystemList
-from CedarBackup2.util import resolveCommand, executeCommand, convertSize
+from CedarBackup2.util import resolveCommand, executeCommand
from CedarBackup2.util import changeOwnership, buildNormalizedPath
from CedarBackup2.util import UNIT_BYTES, UNIT_KBYTES, UNIT_MBYTES, UNIT_GBYTES
from CedarBackup2.xmlutil import createInputDom, addContainerNode, addStringNode
@@ -444,10 +444,9 @@
"""
logger.debug("Begin splitting contents of [%s]." % dailyDir)
fileList = getBackupFiles(dailyDir) # ignores indicator files
- limitBytes = float(convertSize(sizeLimit.quantity, sizeLimit.units, UNIT_BYTES))
for path in fileList:
size = float(os.stat(path).st_size)
- if size > limitBytes:
+ if size > sizeLimit.bytes:
_splitFile(path, splitSize, backupUser, backupGroup, removeSource=True)
logger.debug("Completed splitting contents of [%s]." % dailyDir)
@@ -479,7 +478,7 @@
dirname = os.path.dirname(sourcePath)
filename = os.path.basename(sourcePath)
prefix = "%s_" % filename
- bytes = int(convertSize(splitSize.quantity, splitSize.units, UNIT_BYTES))
+ bytes = int(splitSize.bytes)
os.chdir(dirname) # need to operate from directory that we want files written to
command = resolveCommand(SPLIT_COMMAND)
args = [ "--verbose", "--numeric-suffixes", "--suffix-length=5", "--bytes=%d" % bytes, filename, prefix, ]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|