/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

diff.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """
00003 
00004 Example, validation of partitioned backups vs direct dump::
00005 
00006     [blyth@belle7 DybPython]$ RANGE=0,35 ./diff.py /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000
00007     2013-06-26 15:23:42,558 __main__ INFO     rng ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34'] 
00008     2013-06-26 15:23:43,188 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/0 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/0 => 0 
00009     2013-06-26 15:23:44,708 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/1 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/1 => 0 
00010     2013-06-26 15:24:14,393 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/2 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/2 => 0 
00011     2013-06-26 15:24:40,702 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/3 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/3 => 0 
00012     2013-06-26 15:25:07,644 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/4 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/4 => 0 
00013     2013-06-26 15:25:36,576 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/5 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/5 => 0 
00014     2013-06-26 15:26:04,959 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/6 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/6 => 0 
00015     2013-06-26 15:26:30,391 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/7 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/7 => 0 
00016     2013-06-26 15:26:59,597 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/8 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/8 => 0 
00017     2013-06-26 15:27:26,654 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/9 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/9 => 0 
00018     2013-06-26 15:27:59,946 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/10 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/10 => 0 
00019     2013-06-26 15:28:30,351 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/11 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/11 => 0 
00020     2013-06-26 15:28:59,000 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/12 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/12 => 0 
00021     2013-06-26 15:29:28,941 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/13 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/13 => 0 
00022     2013-06-26 15:29:57,775 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/14 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/14 => 0 
00023     2013-06-26 15:30:27,899 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/15 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/15 => 0 
00024     2013-06-26 15:30:57,652 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/16 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/16 => 0 
00025     2013-06-26 15:31:26,704 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/17 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/17 => 0 
00026     2013-06-26 15:31:57,606 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/18 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/18 => 0 
00027     2013-06-26 15:32:25,482 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/19 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/19 => 0 
00028     2013-06-26 15:32:52,782 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/20 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/20 => 0 
00029     2013-06-26 15:33:20,600 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/21 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/21 => 0 
00030     2013-06-26 15:33:47,635 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/22 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/22 => 0 
00031     2013-06-26 15:34:16,491 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/23 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/23 => 0 
00032     2013-06-26 15:34:45,463 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/24 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/24 => 0 
00033     2013-06-26 15:35:13,254 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/25 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/25 => 0 
00034     2013-06-26 15:35:40,851 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/26 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/26 => 0 
00035     2013-06-26 15:36:10,699 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/27 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/27 => 0 
00036     2013-06-26 15:36:37,114 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/28 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/28 => 0 
00037     2013-06-26 15:37:05,515 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/29 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/29 => 0 
00038     2013-06-26 15:37:33,092 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/30 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/30 => 0 
00039     2013-06-26 15:38:03,650 __main__ INFO     diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/31 /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/31 => 0 
00040     [blyth@belle7 DybPython]$ 
00041     [blyth@belle7 DybPython]$ diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/_ /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/_
00042     [blyth@belle7 DybPython]$ echo $?
00043     0
00044     [blyth@belle7 DybPython]$ diff -r --brief /var/dbbackup/dbsrv/belle7.nuu.edu.tw/channelquality_db_dybdb2_direct/10000/last /var/dbbackup/dbsrv/dybdb2.ihep.ac.cn/channelquality_db_dybdb2/10000/last
00045     [blyth@belle7 DybPython]$ echo $?
00046     0
00047 
00048 
00049     
00050 
00051 """
00052 import os, sys, logging
00053 log = logging.getLogger(__name__)
00054 
00055 def int_(s):
00056     try:
00057         x = int(s)
00058     except ValueError:
00059         x = s
00060     return x 
00061 
00062 isorted_ = lambda _:sorted(_,key=int_)
00063 
00064 def do(cmd): 
00065     p = os.popen(cmd)
00066     ret = p.read()
00067     st = p.close()
00068     if st is None:
00069         rc = 0
00070     else: 
00071         rc = os.WEXITSTATUS(st)  
00072     return ret, rc
00073 
00074 class Dir(list):
00075     def __init__(self, base):
00076         self[:]=isorted_(os.listdir(base))   # subdir names relative to base
00077         self.base = base   
00078     def path(self, e):
00079         return os.path.join(self.base, e )
00080 
00081 
00082 class Diff(object):
00083     def __init__(self, a, b ):
00084         cmd = "diff -r --brief %(a)s %(b)s" % locals()
00085         ret, rc = do(cmd)
00086         log.info("%s => %s " % ( cmd, "\n".join(filter(len,[str(rc), ret])) )) 
00087 
00088 
00089 if __name__ == '__main__':
00090     logging.basicConfig(level=logging.INFO, format="%(asctime)s %(name)s %(levelname)-8s %(message)s")
00091     dirs = sys.argv[1:]
00092     assert len(dirs) == 2
00093 
00094     a = Dir(dirs[0])
00095     b = Dir(dirs[1])
00096     
00097     sa, sb = set(a), set(b)
00098     si, su = sa & sb, sa | sb   # intersection, union
00099 
00100     rng = map(str,range(*map(int,os.environ.get('RANGE',"0,1000").split(","))))
00101 
00102     log.info("rng %s " % repr(rng))
00103 
00104     for x in isorted_(su):
00105         if not x in rng:continue
00106         if x in si:
00107             pa, pb = a.path(x), b.path(x)
00108             Diff(pa, pb)
00109         else:
00110             log.warn("skip %s that is not in both" % x )
00111       
00112         
00113 
00114 
00115 
00116 
00117 
00118 
00119 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:55:40 for DybPython by doxygen 1.7.4