summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/utils/syncdaemon/__codecheck.py
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-08-10 20:04:20 +0300
committerVijay Bellur <vijay@gluster.com>2011-09-12 06:20:42 -0700
commite139eeeb627368112aa1341d2f0ef6770dd7078e (patch)
tree6473a0e0f163b7e3e4057798864286f6f0c517d2 /xlators/features/marker/utils/syncdaemon/__codecheck.py
parentf3081a22740c70485c50d3837fa93da5fd843f26 (diff)
gsyncd: python3 compat fixes
Also add __codecheck script which can verify if source is OK at the syntactical level with a given Python interpreter. Change-Id: Ieff34bcd3efd1cdc0e8f9a510c05488f35897bbe BUG: 1570 Reviewed-on: http://review.gluster.com/320 Reviewed-by: Kaushik BV <kaushikbv@gluster.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/marker/utils/syncdaemon/__codecheck.py')
-rw-r--r--xlators/features/marker/utils/syncdaemon/__codecheck.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/__codecheck.py b/xlators/features/marker/utils/syncdaemon/__codecheck.py
new file mode 100644
index 000000000..832e75c44
--- /dev/null
+++ b/xlators/features/marker/utils/syncdaemon/__codecheck.py
@@ -0,0 +1,27 @@
+import os
+import os.path
+import sys
+
+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')