core: python3
see https://review.gluster.org/#/c/19788/,
https://review.gluster.org/#/c/19871/,
https://review.gluster.org/#/c/19952/,
https://review.gluster.org/#/c/20104/,
https://review.gluster.org/#/c/20162/,
https://review.gluster.org/#/c/20185/,
https://review.gluster.org/#/c/20207/,
https://review.gluster.org/#/c/20227/,
https://review.gluster.org/#/c/20307/,
https://review.gluster.org/#/c/20320/,
https://review.gluster.org/#/c/20332/,
https://review.gluster.org/#/c/20364/,
https://review.gluster.org/#/c/20441/, and
https://review.gluster.org/#/c/20484
shebangs changed from /usr/bin/python2 to /usr/bin/python3.
(Reminder, various distribution packaging guidelines require use
of explicit python version and don't allow '#!/usr/bin/env python',
regardless of how handy that idiom may be.)
glusterfs.spec(.in) package python{2,3}-gluster and python2 or
python3 dependencies as appropriate.
configure(.ac):
+ test for and use python2 or python3 as appropriate. If build
machine has python2 and python3, use python3. Override by
setting PYTHON=/usr/bin/python2 when running configure.
+ PYTHONDEV_CPPFLAGS from python[23]-config --includes is a
better match to the original python sysconfig.get_python_inc().
All those other extraneous flags breaks the build.
+ Only change the shebangs once. Changing them over and over
again, e.g., during a `make glusterrpms` in extras/LinuxRPM
just sends make (is it really make that's looping?) into an
infinite loop. If you figure out why, let me know.
+ Oldest python2 is python2.6 on CentOS 6 and Debian 8 (Jessie).
Everything else has 2.7 or 3.x
+ logic from https://review.gluster.org/c/glusterfs/+/21050, which
needs to be removed/merged after that patch is merged.
Builds on CentOS 6, CentOS 7, Fedora 28, Fedora rawhide, and the
mysterious RHEL > 7.
Change-Id: Idae21d3b6f58b32372e1daa0d234e491e563198f
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-08-29 11:09:27 -04:00
#!/usr/bin/python3
2018-04-13 09:13:16 -04:00
from __future__ import print_function
2015-12-15 00:19:41 -05:00
import os
import re
import sys
import string
import time
path = os . path . abspath ( os . path . dirname ( __file__ ) ) + ' /../../libglusterfs/src '
sys . path . append ( path )
from generator import ops , xlator_cbks , xlator_dumpops
MAKEFILE_FMT = """
xlator_LTLIBRARIES = @XL_NAME @ . la
xlatordir = $ ( libdir ) / glusterfs / $ ( PACKAGE_VERSION ) / xlator / @XL_TYPE @
2017-07-18 15:25:48 +05:30
@XL_NAME_NO_HYPHEN @_la_LDFLAGS = - module $ ( GF_XLATOR_DEFAULT_LDFLAGS )
2015-12-15 00:19:41 -05:00
@XL_NAME_NO_HYPHEN @_la_SOURCES = @XL_NAME @ . c
@XL_NAME_NO_HYPHEN @_la_LIBADD = $ ( top_builddir ) / libglusterfs / src / libglusterfs . la
noinst_HEADERS = @XL_NAME @ . h @XL_NAME @ - mem - types . h @XL_NAME @ - messages . h
2017-07-18 15:25:48 +05:30
AM_CPPFLAGS = $ ( GF_CPPFLAGS ) - I $ ( top_srcdir ) / libglusterfs / src \
- I $ ( top_srcdir ) / rpc / xdr / src - I $ ( top_builddir ) / rpc / xdr / src
2015-12-15 00:19:41 -05:00
AM_CFLAGS = - Wall - fno - strict - aliasing $ ( GF_CFLAGS )
CLEANFILES =
"""
fop_subs = { }
cbk_subs = { }
fn_subs = { }
def get_error_arg ( type_str ) :
if type_str . find ( " * " ) != - 1 :
return " NULL "
return " -1 "
def get_param ( names , types ) :
# Convert two separate tuples to one of (name, type) sub-tuples.
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/ and
https://review.gluster.org/#/c/19871/
Selected small fixes from 2to3 utility. Specifically apply, basestring,
funcattrs, idioms, numliterals, set_literal, types, urllib, zip
Note: these 2to3 fixes report no changes are necessary: exec, execfile,
exitfunc, filter, getcwdu, intern, itertools, metaclass, methodattrs, ne,
next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr,
standarderror, sys_exc, throw, tuple_params, xreadlines.
Any 2to3 fixes not in the above two lists have more extensive changes
which will follow in separate patches.
most unicode changes suggested by 2to3 will need to be applied at the
same time as changing the shebangs from python2 to python3. Prashanth
notes that unicode strings in py2 need 'u' prefix; unicode strings in
py3 3.0, 3.1, and 3.2 a 'u' prefix will throw an error, but in py3 3.3+
it is legal (or just ignored). All Linux dists we care about have 3.3
or later so we can leave 'u' prefixes on unicode strings.
Change-Id: I49bba2f328b0ee24b9a8115a7183be979981563e
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-05-02 08:48:32 -04:00
as_tuples = list ( zip ( types , names ) )
2015-12-15 00:19:41 -05:00
# Convert each sub-tuple into a "type name" string.
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/,
https://review.gluster.org/#/c/19871/,
https://review.gluster.org/#/c/19952/,
https://review.gluster.org/#/c/20104/,
https://review.gluster.org/#/c/20162/,
https://review.gluster.org/#/c/20185/,
https://review.gluster.org/#/c/20207/,
https://review.gluster.org/#/c/20227/,
https://review.gluster.org/#/c/20307/,
https://review.gluster.org/#/c/20320/,
https://review.gluster.org/#/c/20332/,
https://review.gluster.org/#/c/20364/, and
https://review.gluster.org/#/c/20441/
Fixes some overlooked string.join()s:
+ AFAICT extras/profiler/glusterfs-profiler, extras/prot_filter.py,
extras/rebalance.py, and extras/volfilter.py would only manifest at
runtime.
+ xlators/experimental/fdl/src/gen_recon.py is a build-time error when
using python3 during the build, thus was not noticed previously when
building with python2.
+ extras/create_new_xlator/generate_xlator.py seems to be example code
and does not affect the build or runtime AFAICT
Note: Fedora packaging guidelines and SUSE rpmlint require explicit
shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python
are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3
Note: Selected small fixes from 2to3 utility. Specifically apply,
basestring, funcattrs, has_key, idioms, map, numliterals, raise,
set_literal, types, urllib, and zip have already been applied. Also
version agnostic imports for urllib, cpickle, socketserver, _thread,
queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1
Note: these 2to3 fixes report no changes are necessary: asserts, buffer,
exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern,
itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren,
raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw,
tuple_params, xreadlines.
Change-Id: Ia1fe2958d136f4303e30f7e7e86b6fe7d7b52c81
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-07-09 10:01:06 -04:00
as_strings = [ ' ' . join ( item ) for item in as_tuples ]
2015-12-15 00:19:41 -05:00
# Join all of those into one big string.
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/,
https://review.gluster.org/#/c/19871/,
https://review.gluster.org/#/c/19952/,
https://review.gluster.org/#/c/20104/,
https://review.gluster.org/#/c/20162/,
https://review.gluster.org/#/c/20185/,
https://review.gluster.org/#/c/20207/,
https://review.gluster.org/#/c/20227/,
https://review.gluster.org/#/c/20307/,
https://review.gluster.org/#/c/20320/,
https://review.gluster.org/#/c/20332/,
https://review.gluster.org/#/c/20364/, and
https://review.gluster.org/#/c/20441/
Fixes some overlooked string.join()s:
+ AFAICT extras/profiler/glusterfs-profiler, extras/prot_filter.py,
extras/rebalance.py, and extras/volfilter.py would only manifest at
runtime.
+ xlators/experimental/fdl/src/gen_recon.py is a build-time error when
using python3 during the build, thus was not noticed previously when
building with python2.
+ extras/create_new_xlator/generate_xlator.py seems to be example code
and does not affect the build or runtime AFAICT
Note: Fedora packaging guidelines and SUSE rpmlint require explicit
shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python
are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3
Note: Selected small fixes from 2to3 utility. Specifically apply,
basestring, funcattrs, has_key, idioms, map, numliterals, raise,
set_literal, types, urllib, and zip have already been applied. Also
version agnostic imports for urllib, cpickle, socketserver, _thread,
queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1
Note: these 2to3 fixes report no changes are necessary: asserts, buffer,
exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern,
itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren,
raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw,
tuple_params, xreadlines.
Change-Id: Ia1fe2958d136f4303e30f7e7e86b6fe7d7b52c81
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-07-09 10:01:06 -04:00
return ' , \n \t ' . join ( as_strings )
2015-12-15 00:19:41 -05:00
def generate ( tmpl , name , table ) :
w_arg_names = [ a [ 1 ] for a in table [ name ] if a [ 0 ] == ' fop-arg ' ]
w_arg_types = [ a [ 2 ] for a in table [ name ] if a [ 0 ] == ' fop-arg ' ]
u_arg_names = [ a [ 1 ] for a in table [ name ] if a [ 0 ] == ' cbk-arg ' ]
u_arg_types = [ a [ 2 ] for a in table [ name ] if a [ 0 ] == ' cbk-arg ' ]
fn_arg_names = [ a [ 1 ] for a in table [ name ] if a [ 0 ] == ' fn-arg ' ]
fn_arg_types = [ a [ 2 ] for a in table [ name ] if a [ 0 ] == ' fn-arg ' ]
ret_type = [ a [ 1 ] for a in table [ name ] if a [ 0 ] == ' ret-val ' ]
ret_var = [ a [ 2 ] for a in table [ name ] if a [ 0 ] == ' ret-val ' ]
sdict = { }
#Parameters are (t1, var1), (t2, var2)...
#Args are (var1, var2,...)
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/,
https://review.gluster.org/#/c/19871/,
https://review.gluster.org/#/c/19952/,
https://review.gluster.org/#/c/20104/,
https://review.gluster.org/#/c/20162/,
https://review.gluster.org/#/c/20185/,
https://review.gluster.org/#/c/20207/,
https://review.gluster.org/#/c/20227/,
https://review.gluster.org/#/c/20307/,
https://review.gluster.org/#/c/20320/,
https://review.gluster.org/#/c/20332/,
https://review.gluster.org/#/c/20364/, and
https://review.gluster.org/#/c/20441/
Fixes some overlooked string.join()s:
+ AFAICT extras/profiler/glusterfs-profiler, extras/prot_filter.py,
extras/rebalance.py, and extras/volfilter.py would only manifest at
runtime.
+ xlators/experimental/fdl/src/gen_recon.py is a build-time error when
using python3 during the build, thus was not noticed previously when
building with python2.
+ extras/create_new_xlator/generate_xlator.py seems to be example code
and does not affect the build or runtime AFAICT
Note: Fedora packaging guidelines and SUSE rpmlint require explicit
shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python
are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3
Note: Selected small fixes from 2to3 utility. Specifically apply,
basestring, funcattrs, has_key, idioms, map, numliterals, raise,
set_literal, types, urllib, and zip have already been applied. Also
version agnostic imports for urllib, cpickle, socketserver, _thread,
queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1
Note: these 2to3 fixes report no changes are necessary: asserts, buffer,
exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern,
itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren,
raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw,
tuple_params, xreadlines.
Change-Id: Ia1fe2958d136f4303e30f7e7e86b6fe7d7b52c81
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-07-09 10:01:06 -04:00
sdict [ " @WIND_ARGS@ " ] = ' , ' . join ( w_arg_names )
sdict [ " @UNWIND_ARGS@ " ] = ' , ' . join ( u_arg_names )
sdict [ " @ERROR_ARGS@ " ] = ' , ' . join ( list ( map ( get_error_arg , u_arg_types ) ) )
2015-12-15 00:19:41 -05:00
sdict [ " @WIND_PARAMS@ " ] = get_param ( w_arg_names , w_arg_types )
sdict [ " @UNWIND_PARAMS@ " ] = get_param ( u_arg_names , u_arg_types )
sdict [ " @FUNC_PARAMS@ " ] = get_param ( fn_arg_names , fn_arg_types )
sdict [ " @NAME@ " ] = name
sdict [ " @FOP_PREFIX@ " ] = fop_prefix
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/,
https://review.gluster.org/#/c/19871/,
https://review.gluster.org/#/c/19952/,
https://review.gluster.org/#/c/20104/,
https://review.gluster.org/#/c/20162/,
https://review.gluster.org/#/c/20185/,
https://review.gluster.org/#/c/20207/,
https://review.gluster.org/#/c/20227/,
https://review.gluster.org/#/c/20307/,
https://review.gluster.org/#/c/20320/,
https://review.gluster.org/#/c/20332/,
https://review.gluster.org/#/c/20364/, and
https://review.gluster.org/#/c/20441/
Fixes some overlooked string.join()s:
+ AFAICT extras/profiler/glusterfs-profiler, extras/prot_filter.py,
extras/rebalance.py, and extras/volfilter.py would only manifest at
runtime.
+ xlators/experimental/fdl/src/gen_recon.py is a build-time error when
using python3 during the build, thus was not noticed previously when
building with python2.
+ extras/create_new_xlator/generate_xlator.py seems to be example code
and does not affect the build or runtime AFAICT
Note: Fedora packaging guidelines and SUSE rpmlint require explicit
shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python
are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3
Note: Selected small fixes from 2to3 utility. Specifically apply,
basestring, funcattrs, has_key, idioms, map, numliterals, raise,
set_literal, types, urllib, and zip have already been applied. Also
version agnostic imports for urllib, cpickle, socketserver, _thread,
queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1
Note: these 2to3 fixes report no changes are necessary: asserts, buffer,
exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern,
itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren,
raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw,
tuple_params, xreadlines.
Change-Id: Ia1fe2958d136f4303e30f7e7e86b6fe7d7b52c81
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-07-09 10:01:06 -04:00
sdict [ " @RET_TYPE@ " ] = ' ' . join ( ret_type )
sdict [ " @RET_VAR@ " ] = ' ' . join ( ret_var )
2015-12-15 00:19:41 -05:00
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/,
https://review.gluster.org/#/c/19871/,
https://review.gluster.org/#/c/19952/,
https://review.gluster.org/#/c/20104/,
https://review.gluster.org/#/c/20162/,
https://review.gluster.org/#/c/20185/,
https://review.gluster.org/#/c/20207/,
https://review.gluster.org/#/c/20227/,
https://review.gluster.org/#/c/20307/,
https://review.gluster.org/#/c/20320/,
https://review.gluster.org/#/c/20332/, and
https://review.gluster.org/#/c/20364/
Fixes glupy.py python2isms, iteritems -> items, and some overlooked
print() in georep/peer_mountbroker.in
Note: Fedora packaging guidelines and SUSE rpmlint require explicit
shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python
are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3
Note: Selected small fixes from 2to3 utility. Specifically apply,
basestring, funcattrs, has_key, idioms, map, numliterals, raise,
set_literal, types, urllib, and zip have already been applied. Also
version agnostic imports for urllib, cpickle, socketserver, _thread,
queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1
Note: these 2to3 fixes report no changes are necessary: asserts, buffer,
exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern,
itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren,
raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw,
tuple_params, xreadlines.
Change-Id: Idda031c1ec975417c79323aea33e7b694e752b2a
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-07-02 08:18:54 -04:00
for old , new in sdict . items ( ) :
2015-12-15 00:19:41 -05:00
tmpl = tmpl . replace ( old , new )
# TBD: reindent/reformat the result for maximum readability.
return tmpl
def gen_xlator ( ) :
xl = open ( src_dir_path + " / " + xl_name + " .c " , ' w+ ' )
2018-04-13 09:13:16 -04:00
print ( COPYRIGHT , file = xl )
print ( fragments [ " INCLUDE_IN_SRC_FILE " ] . replace ( " @XL_NAME@ " ,
xl_name ) , file = xl )
2015-12-15 00:19:41 -05:00
#Generate cbks and fops
2016-04-11 01:51:38 -04:00
for fop in ops :
2018-04-13 09:13:16 -04:00
print ( generate ( fragments [ " CBK_TEMPLATE " ] , fop , ops ) , file = xl )
print ( generate ( fragments [ " FOP_TEMPLATE " ] , fop , ops ) , file = xl )
2015-12-15 00:19:41 -05:00
2016-04-11 01:51:38 -04:00
for cbk in xlator_cbks :
2018-04-13 09:13:16 -04:00
print ( generate ( fragments [ " FUNC_TEMPLATE " ] , cbk ,
xlator_cbks ) , file = xl )
2015-12-15 00:19:41 -05:00
2016-04-11 01:51:38 -04:00
for dops in xlator_dumpops :
2018-04-13 09:13:16 -04:00
print ( generate ( fragments [ " FUNC_TEMPLATE " ] , dops ,
xlator_dumpops ) , file = xl )
2015-12-15 00:19:41 -05:00
#Generate fop table
2018-04-13 09:13:16 -04:00
print ( " struct xlator_fops fops = { " , file = xl )
2016-04-11 01:51:38 -04:00
for fop in ops :
2018-04-13 09:13:16 -04:00
print ( " . {0:20} = {1} _ {2} , " . format ( fop , fop_prefix , fop ) , file = xl )
print ( " }; " , file = xl )
2015-12-15 00:19:41 -05:00
#Generate xlator_cbks table
2018-04-13 09:13:16 -04:00
print ( " struct xlator_cbks cbks = { " , file = xl )
2016-04-11 01:51:38 -04:00
for cbk in xlator_cbks :
2018-04-13 09:13:16 -04:00
print ( " . {0:20} = {1} _ {2} , " . format ( cbk , fop_prefix , cbk ) , file = xl )
print ( " }; " , file = xl )
2015-12-15 00:19:41 -05:00
#Generate xlator_dumpops table
2018-04-13 09:13:16 -04:00
print ( " struct xlator_dumpops dumpops = { " , file = xl )
2016-04-11 01:51:38 -04:00
for dops in xlator_dumpops :
2018-04-13 09:13:16 -04:00
print ( " . {0:20} = {1} _ {2} , " . format ( dops , fop_prefix , dops ) , file = xl )
print ( " }; " , file = xl )
2015-12-15 00:19:41 -05:00
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/,
https://review.gluster.org/#/c/19871/,
https://review.gluster.org/#/c/19952/,
https://review.gluster.org/#/c/20104/,
https://review.gluster.org/#/c/20162/,
https://review.gluster.org/#/c/20185/,
https://review.gluster.org/#/c/20207/,
https://review.gluster.org/#/c/20227/,
https://review.gluster.org/#/c/20307/,
https://review.gluster.org/#/c/20320/, and
https://review.gluster.org/#/c/20332/
This patch fixes the remaining comma white space (ws_comma) as suggested
by the 2to3 utility. (Earlier attempts to fix all ws_comma in one
patch did not pass centos regression, hence multiple patches to identify
the change that causes the failure.)
Note: Fedora packaging guidelines and SUSE rpmlint require explicit
shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python
are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3
Note: Selected small fixes from 2to3 utility. Specifically apply,
basestring, funcattrs, has_key, idioms, map, numliterals, raise,
set_literal, types, urllib, and zip have already been applied. Also
version agnostic imports for urllib, cpickle, socketserver, _thread,
queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1
Note: these 2to3 fixes report no changes are necessary: asserts, buffer,
exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern,
itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren,
raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw,
tuple_params, xreadlines.
Change-Id: If5aca67084a7b1c06966fed35fb35e8bb2f7d67c
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-06-22 06:19:53 -04:00
xlator_methods = fragments [ " XLATOR_METHODS " ] . replace ( " @XL_NAME@ " , xl_name )
xlator_methods = xlator_methods . replace ( " @FOP_PREFIX@ " , fop_prefix )
2018-05-08 10:35:35 +05:30
print ( xlator_methods , file = xl )
2015-12-15 00:19:41 -05:00
xl . close ( )
def create_dir_struct ( ) :
if not os . path . exists ( dir_path + " /src " ) :
os . makedirs ( dir_path + " /src " )
def gen_header_files ( ) :
upname = xl_name_no_hyphen . upper ( )
h = open ( src_dir_path + " / " + xl_name + " .h " , ' w+ ' )
2018-04-13 09:13:16 -04:00
print ( COPYRIGHT , file = h )
2015-12-15 00:19:41 -05:00
txt = fragments [ " HEADER_FMT " ] . replace ( " @HFL_NAME@ " , upname )
2018-05-08 10:35:35 +05:30
txt = txt . replace ( " @XL_NAME@ " , xl_name )
2018-04-13 09:13:16 -04:00
print ( txt , file = h )
2015-12-15 00:19:41 -05:00
h . close ( )
h = open ( src_dir_path + " / " + xl_name + " -mem-types.h " , ' w+ ' )
2018-04-13 09:13:16 -04:00
print ( COPYRIGHT , file = h )
2018-05-08 10:35:35 +05:30
txt = fragments [ " MEM_HEADER_FMT " ] . replace ( " @HFL_NAME@ " , upname + " _MEM_TYPES " )
txt = txt . replace ( " @FOP_PREFIX@ " , fop_prefix )
2018-04-13 09:13:16 -04:00
print ( txt , file = h )
2015-12-15 00:19:41 -05:00
h . close ( )
h = open ( src_dir_path + " / " + xl_name + " -messages.h " , ' w+ ' )
2018-04-13 09:13:16 -04:00
print ( COPYRIGHT , file = h )
2018-05-08 10:35:35 +05:30
txt = fragments [ " MSG_HEADER_FMT " ] . replace ( " @HFL_NAME@ " , upname + " _MESSAGES " )
txt = txt . replace ( " @FOP_PREFIX@ " , fop_prefix . upper ( ) )
2018-04-13 09:13:16 -04:00
print ( txt , file = h )
2015-12-15 00:19:41 -05:00
h . close ( )
def gen_makefiles ( ) :
m = open ( dir_path + " /Makefile.am " , ' w+ ' )
2018-04-13 09:13:16 -04:00
print ( " SUBDIRS = src \n \n CLEANFILES = " , file = m )
2015-12-15 00:19:41 -05:00
m . close ( )
m = open ( src_dir_path + " /Makefile.am " , ' w+ ' )
txt = MAKEFILE_FMT . replace ( " @XL_NAME@ " , xl_name )
txt = txt . replace ( " @XL_NAME_NO_HYPHEN@ " , xl_name_no_hyphen )
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/,
https://review.gluster.org/#/c/19871/,
https://review.gluster.org/#/c/19952/,
https://review.gluster.org/#/c/20104/,
https://review.gluster.org/#/c/20162/,
https://review.gluster.org/#/c/20185/,
https://review.gluster.org/#/c/20207/,
https://review.gluster.org/#/c/20227/,
https://review.gluster.org/#/c/20307/,
https://review.gluster.org/#/c/20320/, and
https://review.gluster.org/#/c/20332/
This patch fixes the remaining comma white space (ws_comma) as suggested
by the 2to3 utility. (Earlier attempts to fix all ws_comma in one
patch did not pass centos regression, hence multiple patches to identify
the change that causes the failure.)
Note: Fedora packaging guidelines and SUSE rpmlint require explicit
shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python
are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3
Note: Selected small fixes from 2to3 utility. Specifically apply,
basestring, funcattrs, has_key, idioms, map, numliterals, raise,
set_literal, types, urllib, and zip have already been applied. Also
version agnostic imports for urllib, cpickle, socketserver, _thread,
queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1
Note: these 2to3 fixes report no changes are necessary: asserts, buffer,
exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern,
itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren,
raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw,
tuple_params, xreadlines.
Change-Id: If5aca67084a7b1c06966fed35fb35e8bb2f7d67c
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-06-22 06:19:53 -04:00
txt = txt . replace ( " @XL_TYPE@ " , xlator_type )
2018-04-13 09:13:16 -04:00
print ( txt , file = m )
2015-12-15 00:19:41 -05:00
m . close ( )
def get_copyright ( ) :
return fragments [ " CP " ] . replace ( " @CURRENT_YEAR@ " ,
time . strftime ( " % Y " ) )
def load_fragments ( ) :
pragma_re = re . compile ( ' pragma fragment (.*) ' )
cur_symbol = None
cur_value = " "
result = { }
basepath = os . path . abspath ( os . path . dirname ( __file__ ) )
fragpath = basepath + " /new-xlator-tmpl.c "
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/,
https://review.gluster.org/#/c/19871/,
https://review.gluster.org/#/c/19952/,
https://review.gluster.org/#/c/20104/,
https://review.gluster.org/#/c/20162/,
https://review.gluster.org/#/c/20185/,
https://review.gluster.org/#/c/20207/,
https://review.gluster.org/#/c/20227/,
https://review.gluster.org/#/c/20307/,
https://review.gluster.org/#/c/20320/, and
https://review.gluster.org/#/c/20332/
This patch fixes the remaining comma white space (ws_comma) as suggested
by the 2to3 utility. (Earlier attempts to fix all ws_comma in one
patch did not pass centos regression, hence multiple patches to identify
the change that causes the failure.)
Note: Fedora packaging guidelines and SUSE rpmlint require explicit
shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python
are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3
Note: Selected small fixes from 2to3 utility. Specifically apply,
basestring, funcattrs, has_key, idioms, map, numliterals, raise,
set_literal, types, urllib, and zip have already been applied. Also
version agnostic imports for urllib, cpickle, socketserver, _thread,
queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1
Note: these 2to3 fixes report no changes are necessary: asserts, buffer,
exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern,
itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren,
raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw,
tuple_params, xreadlines.
Change-Id: If5aca67084a7b1c06966fed35fb35e8bb2f7d67c
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-06-22 06:19:53 -04:00
for line in open ( fragpath , " r " ) . readlines ( ) :
2015-12-15 00:19:41 -05:00
m = pragma_re . search ( line )
if m :
if cur_symbol :
result [ cur_symbol ] = cur_value
cur_symbol = m . group ( 1 )
cur_value = " "
else :
cur_value + = line
if cur_symbol :
result [ cur_symbol ] = cur_value
return result
if __name__ == ' __main__ ' :
if len ( sys . argv ) < 3 :
2018-04-13 09:13:16 -04:00
print ( " USAGE: ./gen_xlator <XLATOR_DIR> <XLATOR_NAME> <FOP_PREFIX> " )
2015-12-15 00:19:41 -05:00
sys . exit ( 0 )
xl_name = sys . argv [ 2 ]
xl_name_no_hyphen = xl_name . replace ( " - " , " _ " )
if sys . argv [ 1 ] . endswith ( ' / ' ) :
dir_path = sys . argv [ 1 ] + xl_name
else :
dir_path = sys . argv [ 1 ] + " / " + xl_name
xlator_type = os . path . basename ( sys . argv [ 1 ] )
fop_prefix = sys . argv [ 3 ]
src_dir_path = dir_path + " /src "
fragments = load_fragments ( )
COPYRIGHT = get_copyright ( )
create_dir_struct ( )
gen_xlator ( )
gen_header_files ( )
gen_makefiles ( )