From aee4025bae8eaeed7e4e190c2d6bd287cc1662aa Mon Sep 17 00:00:00 2001 From: bescoto Date: Sun, 3 Aug 2003 18:18:30 +0000 Subject: Merged fixes from 0.13 for --calculate-average, mac os x, and python 2.3 git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/branches/r0-12@372 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 12 ++++++++++++ rdiff-backup/rdiff_backup/Main.py | 7 ++++--- rdiff-backup/rdiff_backup/backup.py | 10 +++++----- rdiff-backup/rdiff_backup/cmodule.c | 12 +++++++++++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index ef2143c..3f5ce7f 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -1,3 +1,15 @@ +New in v0.12.3 (2003/08/??) +--------------------------- + +Patch by Jeffrey Marshall fixes socket/fifo recognition on Mac OS X +(which apparently has buggy macros). + +Patch by Jeffrey Marshall fixes --calculate-average mode, which seems +to have broken recently. + +rdiff-backup should now work with python 2.3. + + New in v0.12.2 (2003/07/24) --------------------------- diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py index d65667b..7edfdc3 100644 --- a/rdiff-backup/rdiff_backup/Main.py +++ b/rdiff-backup/rdiff_backup/Main.py @@ -24,7 +24,7 @@ import getopt, sys, re, os from log import Log, LoggerError, ErrorLog import Globals, Time, SetConnections, selection, robust, rpath, \ manage, backup, connection, restore, FilenameMapping, \ - Security, Hardlink, regress, C + Security, Hardlink, regress, C, statistics action = None @@ -518,8 +518,9 @@ def ListIncrements(rp): def CalculateAverage(rps): """Print out the average of the given statistics files""" - statobjs = map(lambda rp: StatsObj().read_stats_from_rp(rp), rps) - average_stats = StatsObj().set_to_average(statobjs) + statobjs = map(lambda rp: statistics.StatsObj().read_stats_from_rp(rp), + rps) + average_stats = statistics.StatsObj().set_to_average(statobjs) print average_stats.get_stats_logstring( "Average of %d stat files" % len(rps)) diff --git a/rdiff-backup/rdiff_backup/backup.py b/rdiff-backup/rdiff_backup/backup.py index 89d7bea..5040de6 100644 --- a/rdiff-backup/rdiff_backup/backup.py +++ b/rdiff-backup/rdiff_backup/backup.py @@ -49,7 +49,7 @@ def Mirror_and_increment(src_rpath, dest_rpath, inc_rpath): class SourceStruct: """Hold info used on source side when backing up""" - source_select = None # will be set to source Select iterator + _source_select = None # will be set to source Select iterator def set_source_select(cls, rpath, tuplelist, *filelists): """Initialize select object using tuplelist @@ -58,7 +58,7 @@ class SourceStruct: connection. Otherwise we will get an error because a list containing files can't be pickled. - Also, cls.source_select needs to be cached so get_diffs below + Also, cls._source_select needs to be cached so get_diffs below can retrieve the necessary rps. """ @@ -66,15 +66,15 @@ class SourceStruct: sel.ParseArgs(tuplelist, filelists) sel.set_iter() cache_size = Globals.pipeline_max_length * 3 # to and from+leeway - cls.source_select = rorpiter.CacheIndexable(sel, cache_size) + cls._source_select = rorpiter.CacheIndexable(sel, cache_size) def get_source_select(cls): """Return source select iterator, set by set_source_select""" - return cls.source_select + return cls._source_select def get_diffs(cls, dest_sigiter): """Return diffs of any files with signature in dest_sigiter""" - source_rps = cls.source_select + source_rps = cls._source_select error_handler = robust.get_error_handler("ListError") def attach_snapshot(diff_rorp, src_rp): """Attach file of snapshot to diff_rorp, w/ error checking""" diff --git a/rdiff-backup/rdiff_backup/cmodule.c b/rdiff-backup/rdiff_backup/cmodule.c index 45fb368..cd00521 100644 --- a/rdiff-backup/rdiff_backup/cmodule.c +++ b/rdiff-backup/rdiff_backup/cmodule.c @@ -35,13 +35,23 @@ #define PY_LONG_LONG LONG_LONG #endif +/* The following section is by Jeffrey A. Marshall and compensates for + * a bug in Mac OS X's S_ISFIFO and S_ISSOCK macros. + */ +#ifdef __APPLE__ +/* S_ISFIFO/S_ISSOCK macros from on mac osx are bogus */ +#undef S_ISSOCK /* their definition of a socket includes fifos */ +#undef S_ISFIFO /* their definition of a fifo includes sockets */ +#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) +#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) +#endif + static PyObject *UnknownFileTypeError; static PyObject *c_make_file_dict(PyObject *self, PyObject *args); static PyObject *long2str(PyObject *self, PyObject *args); static PyObject *str2long(PyObject *self, PyObject *args); static PyObject *my_sync(PyObject *self, PyObject *args); - /* Turn a stat structure into a python dictionary. The preprocessor stuff taken from Python's posixmodule.c */ static PyObject *c_make_file_dict(self, args) -- cgit v1.2.1