From e8e42b297242a63d7b1f4d128eaf7571c4e9d06c Mon Sep 17 00:00:00 2001 From: bescoto Date: Sun, 3 Aug 2003 18:13:52 +0000 Subject: Fixes for --calculate-average, python 2.3, and mac os x git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@371 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 8 ++++++++ rdiff-backup/rdiff_backup/Main.py | 7 ++++--- rdiff-backup/rdiff_backup/backup.py | 10 +++++----- rdiff-backup/rdiff_backup/cmodule.c | 12 +++++++++++- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index d89ffdf..94b0a0e 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -10,6 +10,14 @@ link information is not restored unless it is current in the mirror. Fixed problem with door files locally when repository is remote. (Reported by Robert Weber.) +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.13.0 (2003/07/22) --------------------------- diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py index dc63246..e8167d6 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, fs_abilities + Security, Hardlink, regress, C, fs_abilities, statistics action = None @@ -560,8 +560,9 @@ def ListIncrementSizes(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 98c6e67..33e97bf 100644 --- a/rdiff-backup/rdiff_backup/backup.py +++ b/rdiff-backup/rdiff_backup/backup.py @@ -50,7 +50,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 @@ -59,7 +59,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. """ @@ -67,15 +67,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 0df8763..30aac47 100644 --- a/rdiff-backup/rdiff_backup/cmodule.c +++ b/rdiff-backup/rdiff_backup/cmodule.c @@ -57,13 +57,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