diff options
| author | Avra Sengupta <asengupt@redhat.com> | 2013-05-27 22:23:57 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2013-07-22 01:53:03 -0700 | 
| commit | 950371be29d029179ac5cd0ad2dfdbfcd4467b96 (patch) | |
| tree | a979d3c710c25074088bd05cef5b6a0ede9505a9 /geo-replication/syncdaemon/__codecheck.py | |
| parent | 11f6c56f83b977a08f9d74563249cef59e22a05d (diff) | |
move 'xlators/marker/utils/' to 'geo-replication/' directory
Change-Id: Ibd0faefecc15b6713eda28bc96794ae58aff45aa
BUG: 847839
Original Author: Amar Tumballi <amarts@redhat.com>
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/5133
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'geo-replication/syncdaemon/__codecheck.py')
| -rw-r--r-- | geo-replication/syncdaemon/__codecheck.py | 46 | 
1 files changed, 46 insertions, 0 deletions
diff --git a/geo-replication/syncdaemon/__codecheck.py b/geo-replication/syncdaemon/__codecheck.py new file mode 100644 index 00000000..e3386afb --- /dev/null +++ b/geo-replication/syncdaemon/__codecheck.py @@ -0,0 +1,46 @@ +import os +import os.path +import sys +import tempfile +import shutil + +ipd = tempfile.mkdtemp(prefix = 'codecheck-aux') + +try: +    # add a fake ipaddr module, we don't want to +    # deal with the real one (just test our code) +    f = open(os.path.join(ipd, 'ipaddr.py'), 'w') +    f.write(""" +class IPAddress(object): +    pass +class IPNetwork(list): +    pass +""") +    f.close() +    sys.path.append(ipd) + +    fl = os.listdir(os.path.dirname(sys.argv[0]) or '.') +    fl.sort() +    for f in fl: +        if f[-3:] != '.py' or f[0] == '_': +            continue +        m = f[:-3] +        sys.stdout.write('importing %s ...' %  m) +        __import__(m) +        print(' OK.') + +    def sys_argv_set(a): +        sys.argv = sys.argv[:1] + a + +    gsyncd = sys.modules['gsyncd'] +    for a in [['--help'], ['--version'], ['--canonicalize-escape-url', '/foo']]: +        print('>>> invoking program with args: %s' % ' '.join(a)) +        pid = os.fork() +        if not pid: +            sys_argv_set(a) +            gsyncd.main() +        _, r = os.waitpid(pid, 0) +        if r: +            raise RuntimeError('invocation failed') +finally: +    shutil.rmtree(ipd)  | 
