Commit 09b2f80f authored by owsla's avatar owsla

Take start and end times from same system so that the elapsed time printed in

the statistics is not affected by time zone.


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@994 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 0334142b
New in v1.3.0 (????/??/??)
---------------------------
Take start and end times from same system so that the elapsed time printed in
the statistics is not affected by time zone. (Andrew Ferguson)
Properly fix escaping DOS devices and trailing periods and spaces; now supports
native Windows and Linxu/FAT32. (Andrew Ferguson)
......
......@@ -20,7 +20,7 @@
"""Start (and end) here - read arguments, set global settings, etc."""
from __future__ import generators
import getopt, sys, re, os, cStringIO, tempfile
import getopt, sys, re, os, cStringIO, tempfile, time
from log import Log, LoggerError, ErrorLog
import Globals, Time, SetConnections, selection, robust, rpath, \
manage, backup, connection, restore, FilenameMapping, \
......@@ -345,6 +345,7 @@ def Backup(rpin, rpout):
else:
backup.Mirror(rpin, rpout)
rpout.conn.Main.backup_touch_curmirror_local(rpin, rpout)
rpout.conn.Main.backup_close_statistics(time.time())
def backup_quoted_rpaths(rpout):
"""Get QuotedRPath versions of important RPaths. Return rpout"""
......@@ -534,6 +535,19 @@ def backup_remove_curmirror_local():
C.sync() # Make sure everything is written before curmirror is removed
older_inc.delete()
def backup_close_statistics(end_time):
"""Close out the tracking of the backup statistics.
Moved to run at this point so that only the clock of the system on which
rdiff-backup is run is used (set by passing in time.time() from that
system). Use at end of session.
"""
assert Globals.rbdir.conn is Globals.local_connection
if Globals.print_statistics: statistics.print_active_stats(end_time)
if Globals.file_statistics: statistics.FileStats.close()
statistics.write_active_statfileobj(end_time)
def Restore(src_rp, dest_rp, restore_as_of = None):
"""Main restoring function
......
......@@ -173,6 +173,7 @@ def set_allowed_requests(sec_level):
"backup.DestinationStruct.patch_and_increment",
"Main.backup_touch_curmirror_local",
"Main.backup_remove_curmirror_local",
"Main.backup_close_statistics",
"regress.check_pids",
"Globals.ITRB.increment_stat",
"statistics.record_error",
......
......@@ -490,10 +490,6 @@ class CacheCollatedPostProcess:
self.metawriter.close()
metadata.ManagerObj.ConvertMetaToDiff()
if Globals.print_statistics: statistics.print_active_stats()
if Globals.file_statistics: statistics.FileStats.close()
statistics.write_active_statfileobj()
class PatchITRB(rorpiter.ITRBranch):
"""Patch an rpath with the given diff iters (use with IterTreeReducer)
......
......@@ -333,21 +333,21 @@ def process_increment(inc_rorp):
"""Add statistics of increment rp incrp if there is active statfile"""
if _active_statfileobj: _active_statfileobj.add_increment(inc_rorp)
def write_active_statfileobj():
def write_active_statfileobj(end_time = None):
"""Write active StatFileObj object to session statistics file"""
global _active_statfileobj
assert _active_statfileobj
rp_base = Globals.rbdir.append("session_statistics")
session_stats_rp = increment.get_inc(rp_base, 'data', Time.curtime)
_active_statfileobj.finish()
_active_statfileobj.finish(end_time)
_active_statfileobj.write_stats_to_rp(session_stats_rp)
_active_statfileobj = None
def print_active_stats():
def print_active_stats(end_time = None):
"""Print statistics of active statobj to stdout and log"""
global _active_statfileobj
assert _active_statfileobj
_active_statfileobj.finish()
_active_statfileobj.finish(end_time)
statmsg = _active_statfileobj.get_stats_logstring("Session statistics")
log.Log.log_to_file(statmsg)
Globals.client_conn.sys.stdout.write(statmsg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment