#139 tests: Migrate tests helpers to Python3
Closed 3 months ago by slev. Opened 3 months ago by slev.
slev/certmonger python3_test_helpers  into  master

file modified
+11 -11

@@ -187,13 +187,13 @@ 

  dbus.Array([dbus.ObjectPath('/org/fedorahosted/certmonger/requests/Request2')], signature=dbus.Signature('o'))

  

  [ /org/fedorahosted/certmonger: org.fedorahosted.certmonger.get_supported_key_types ]

- dbus.Array([dbus.String(u'RSA'), dbus.String(u'DSA'), dbus.String(u'EC')], signature=dbus.Signature('s'))

+ dbus.Array([dbus.String('RSA'), dbus.String('DSA'), dbus.String('EC')], signature=dbus.Signature('s'))

  

  [ /org/fedorahosted/certmonger: org.fedorahosted.certmonger.get_supported_key_storage ]

- dbus.Array([dbus.String(u'NSSDB'), dbus.String(u'FILE')], signature=dbus.Signature('s'))

+ dbus.Array([dbus.String('NSSDB'), dbus.String('FILE')], signature=dbus.Signature('s'))

  

  [ /org/fedorahosted/certmonger: org.fedorahosted.certmonger.get_supported_cert_storage ]

- dbus.Array([dbus.String(u'NSSDB'), dbus.String(u'FILE')], signature=dbus.Signature('s'))

+ dbus.Array([dbus.String('NSSDB'), dbus.String('FILE')], signature=dbus.Signature('s'))

  

  [ /org/fedorahosted/certmonger : org.fedorahosted.certmonger.remove_known_ca ]

  OK

@@ -433,19 +433,19 @@ 

  

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_cert_info ]

- (dbus.String(u'CN=$UUID,CN=Local Signing Authority'), dbus.String(u'$UUID'), dbus.String(u'CN=localhost'), dbus.Int64(tomorrow), dbus.Array([], signature=dbus.Signature('s')), dbus.Array([dbus.String(u'localhost')], signature=dbus.Signature('s')), dbus.Array([dbus.String(u'host/localhost@LOCALHOST')], signature=dbus.Signature('s')), dbus.Int64(9L), dbus.Array([dbus.String(u'1.3.6.1.5.5.7.3.1')], signature=dbus.Signature('s')))

+ (dbus.String('CN=$UUID,CN=Local Signing Authority'), dbus.String('$UUID'), dbus.String('CN=localhost'), dbus.Int64(tomorrow), dbus.Array([], signature=dbus.Signature('s')), dbus.Array([dbus.String('localhost')], signature=dbus.Signature('s')), dbus.Array([dbus.String('host/localhost@LOCALHOST')], signature=dbus.Signature('s')), dbus.Int64(9), dbus.Array([dbus.String('1.3.6.1.5.5.7.3.1')], signature=dbus.Signature('s')))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_cert_last_checked ]

  recently

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_cert_storage_info ]

- (dbus.String(u'FILE'), dbus.String(u'$tmpdir/test.crt'))

+ (dbus.String('FILE'), dbus.String('$tmpdir/test.crt'))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_csr_data ]

  

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_csr_info ]

- (dbus.String(u'CN=localhost'), dbus.Array([], signature=dbus.Signature('s')), dbus.Array([dbus.String(u'localhost')], signature=dbus.Signature('s')), dbus.Array([dbus.String(u'host/localhost@LOCALHOST')], signature=dbus.Signature('s')), dbus.Int64(9L), dbus.Array([dbus.String(u'id-kp-serverAuth')], signature=dbus.Signature('s')))

+ (dbus.String('CN=localhost'), dbus.Array([], signature=dbus.Signature('s')), dbus.Array([dbus.String('localhost')], signature=dbus.Signature('s')), dbus.Array([dbus.String('host/localhost@LOCALHOST')], signature=dbus.Signature('s')), dbus.Int64(9), dbus.Array([dbus.String('id-kp-serverAuth')], signature=dbus.Signature('s')))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_key_pin ]

  

@@ -454,19 +454,19 @@ 

  

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_key_storage_info ]

- (dbus.String(u'FILE'), dbus.String(u'$tmpdir/test.key'))

+ (dbus.String('FILE'), dbus.String('$tmpdir/test.key'))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_key_type_and_size ]

- (dbus.String(u'RSA'), dbus.Int64(512L))

+ (dbus.String('RSA'), dbus.Int64(512))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_monitoring ]

  1

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_notification_info ]

- (dbus.String(u'stdout'), dbus.String(u'daemon.notice'))

+ (dbus.String('stdout'), dbus.String('daemon.notice'))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_status ]

- (dbus.String(u'MONITORING'), dbus.Boolean(False))

+ (dbus.String('MONITORING'), dbus.Boolean(False))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_ca ]

  /org/fedorahosted/certmonger/cas/CA1

@@ -482,7 +482,7 @@ 

  

  [ /org/fedorahosted/certmonger/requests/Request2 : org.fedorahosted.certmonger.request.modify ]

  1 on /org/fedorahosted/certmonger/requests/Request2

- After setting template-eku to 1.2.3.4.5.6.7.8.9.10, we got dbus.Array([dbus.String(u'1.2.3.4.5.6.7.8.9.10')], signature=dbus.Signature('s'), variant_level=1)

+ After setting template-eku to 1.2.3.4.5.6.7.8.9.10, we got dbus.Array([dbus.String('1.2.3.4.5.6.7.8.9.10')], signature=dbus.Signature('s'), variant_level=1)

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.rekey ]

  1

@@ -187,13 +187,13 @@ 

  dbus.Array([dbus.ObjectPath('/org/fedorahosted/certmonger/requests/Request2')], signature=dbus.Signature('o'))

  

  [ /org/fedorahosted/certmonger: org.fedorahosted.certmonger.get_supported_key_types ]

- dbus.Array([dbus.String(u'RSA'), dbus.String(u'EC')], signature=dbus.Signature('s'))

+ dbus.Array([dbus.String('RSA'), dbus.String('EC')], signature=dbus.Signature('s'))

  

  [ /org/fedorahosted/certmonger: org.fedorahosted.certmonger.get_supported_key_storage ]

- dbus.Array([dbus.String(u'NSSDB'), dbus.String(u'FILE')], signature=dbus.Signature('s'))

+ dbus.Array([dbus.String('NSSDB'), dbus.String('FILE')], signature=dbus.Signature('s'))

  

  [ /org/fedorahosted/certmonger: org.fedorahosted.certmonger.get_supported_cert_storage ]

- dbus.Array([dbus.String(u'NSSDB'), dbus.String(u'FILE')], signature=dbus.Signature('s'))

+ dbus.Array([dbus.String('NSSDB'), dbus.String('FILE')], signature=dbus.Signature('s'))

  

  [ /org/fedorahosted/certmonger : org.fedorahosted.certmonger.remove_known_ca ]

  OK

@@ -433,19 +433,19 @@ 

  

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_cert_info ]

- (dbus.String(u'CN=$UUID,CN=Local Signing Authority'), dbus.String(u'$UUID'), dbus.String(u'CN=localhost'), dbus.Int64(tomorrow), dbus.Array([], signature=dbus.Signature('s')), dbus.Array([dbus.String(u'localhost')], signature=dbus.Signature('s')), dbus.Array([dbus.String(u'host/localhost@LOCALHOST')], signature=dbus.Signature('s')), dbus.Int64(9L), dbus.Array([dbus.String(u'1.3.6.1.5.5.7.3.1')], signature=dbus.Signature('s')))

+ (dbus.String('CN=$UUID,CN=Local Signing Authority'), dbus.String('$UUID'), dbus.String('CN=localhost'), dbus.Int64(tomorrow), dbus.Array([], signature=dbus.Signature('s')), dbus.Array([dbus.String('localhost')], signature=dbus.Signature('s')), dbus.Array([dbus.String('host/localhost@LOCALHOST')], signature=dbus.Signature('s')), dbus.Int64(9), dbus.Array([dbus.String('1.3.6.1.5.5.7.3.1')], signature=dbus.Signature('s')))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_cert_last_checked ]

  recently

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_cert_storage_info ]

- (dbus.String(u'FILE'), dbus.String(u'$tmpdir/test.crt'))

+ (dbus.String('FILE'), dbus.String('$tmpdir/test.crt'))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_csr_data ]

  

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_csr_info ]

- (dbus.String(u'CN=localhost'), dbus.Array([], signature=dbus.Signature('s')), dbus.Array([dbus.String(u'localhost')], signature=dbus.Signature('s')), dbus.Array([dbus.String(u'host/localhost@LOCALHOST')], signature=dbus.Signature('s')), dbus.Int64(9L), dbus.Array([dbus.String(u'id-kp-serverAuth')], signature=dbus.Signature('s')))

+ (dbus.String('CN=localhost'), dbus.Array([], signature=dbus.Signature('s')), dbus.Array([dbus.String('localhost')], signature=dbus.Signature('s')), dbus.Array([dbus.String('host/localhost@LOCALHOST')], signature=dbus.Signature('s')), dbus.Int64(9), dbus.Array([dbus.String('id-kp-serverAuth')], signature=dbus.Signature('s')))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_key_pin ]

  

@@ -454,19 +454,19 @@ 

  

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_key_storage_info ]

- (dbus.String(u'FILE'), dbus.String(u'$tmpdir/test.key'))

+ (dbus.String('FILE'), dbus.String('$tmpdir/test.key'))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_key_type_and_size ]

- (dbus.String(u'RSA'), dbus.Int64(512L))

+ (dbus.String('RSA'), dbus.Int64(512))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_monitoring ]

  1

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_notification_info ]

- (dbus.String(u'stdout'), dbus.String(u'daemon.notice'))

+ (dbus.String('stdout'), dbus.String('daemon.notice'))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_status ]

- (dbus.String(u'MONITORING'), dbus.Boolean(False))

+ (dbus.String('MONITORING'), dbus.Boolean(False))

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.get_ca ]

  /org/fedorahosted/certmonger/cas/CA1

@@ -482,7 +482,7 @@ 

  

  [ /org/fedorahosted/certmonger/requests/Request2 : org.fedorahosted.certmonger.request.modify ]

  1 on /org/fedorahosted/certmonger/requests/Request2

- After setting template-eku to 1.2.3.4.5.6.7.8.9.10, we got dbus.Array([dbus.String(u'1.2.3.4.5.6.7.8.9.10')], signature=dbus.Signature('s'), variant_level=1)

+ After setting template-eku to 1.2.3.4.5.6.7.8.9.10, we got dbus.Array([dbus.String('1.2.3.4.5.6.7.8.9.10')], signature=dbus.Signature('s'), variant_level=1)

  

  [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.rekey ]

  1

file modified
+11 -8

@@ -9,19 +9,22 @@ 

  	echo dbus-daemon not found

  	exit 1

  fi

- if ! python -c 'import os' 2> /dev/null ; then

- 	echo python not found

+ 

+ PYTHON=${PYTHON:-python3}

+ 

+ if ! $PYTHON -c 'import os' 2> /dev/null ; then

+ 	echo $PYTHON not found

  	exit 1

  fi

- if ! python -c 'import dbus' 2> /dev/null ; then

- 	echo python-dbus not found

+ if ! $PYTHON -c 'import dbus' 2> /dev/null ; then

+ 	echo $PYTHON-dbus not found

  	exit 1

  fi

- if ! python -c 'import xml' 2> /dev/null ; then

- 	echo python-xml not found

+ if ! $PYTHON -c 'import xml' 2> /dev/null ; then

+ 	echo $PYTHON-xml not found

  	exit 1

  fi

- if ! python -c 'import xml.etree.ElementTree' 2> /dev/null ; then

- 	echo python-xml does not include etree.ElementTree

+ if ! $PYTHON -c 'import xml.etree.ElementTree' 2> /dev/null ; then

+ 	echo $PYTHON-xml does not include etree.ElementTree

  	exit 1

  fi

file modified
+3 -3

@@ -33,8 +33,8 @@ 

  for i in `seq 240` ; do

  	recently=$(($now-$i))

  	tomorrow=$(($now-$i+24*60*60))

- 	sed -i -e s/^$recently'$/recently/g' -e s/"("$recently"L)"/'(recently)'/g \

- 	       -e s/^$tomorrow'$/tomorrow/g' -e s/"("$tomorrow"L)"/'(tomorrow)'/g $tmpdir/runsub.out

+ 	sed -i -e s/^$recently'$/recently/g' -e s/"("$recently")"/'(recently)'/g \

+ 	       -e s/^$tomorrow'$/tomorrow/g' -e s/"("$tomorrow")"/'(tomorrow)'/g $tmpdir/runsub.out

  done

  

  cat $tmpdir/runsub.out | \

@@ -43,4 +43,4 @@ 

         -e "s|$libexecdir|\$libexecdir|g" \

         -e "s|$tmpdir|\$tmpdir|g" \

         -e "s|expires:.*|expires: sometime|g" \

-        -e "s|u'(00)?[0-9a-fA-F]{32}|u'"'$UUID|g'

+        -e "s|'(00)?[0-9a-fA-F]{32}|'"'$UUID|g'

file modified
+1 -1

@@ -22,5 +22,5 @@ 

  echo "[[ API ]]"

  for i in ./*.py ; do

  	echo "[" `basename "$i"` "]"

- 	python $i

+ 	$PYTHON $i

  done

file modified
+6 -7

@@ -1,4 +1,3 @@ 

- #!/usr/bin/python

  import dbus

  

  # Get a handle for the main certmonger interface.

@@ -19,7 +18,7 @@ 

  

  # Toggle the helper a couple of times.

  ca_ext_h = o.Get('org.fedorahosted.certmonger.ca', 'external-helper')

- print ca_ext_h, "->",

+ print(ca_ext_h, "->", end=' ')

  

  if ca_ext_h.split()[0] == ca_ext_h:

      ca_ext_h += ' -k admin@localhost'

@@ -28,7 +27,7 @@ 

  ca.Set('org.fedorahosted.certmonger.ca', 'external-helper', ca_ext_h)

  

  ca_ext_h = o.Get('org.fedorahosted.certmonger.ca', 'external-helper')

- print ca_ext_h, "->",

+ print(ca_ext_h, "->", end=' ')

  

  if ca_ext_h.split()[0] == ca_ext_h:

      ca_ext_h += ' -k admin@localhost'

@@ -37,20 +36,20 @@ 

  ca.Set('org.fedorahosted.certmonger.ca', 'external-helper', ca_ext_h)

  

  ca_ext_h = o.Get('org.fedorahosted.certmonger.ca', 'external-helper')

- print ca_ext_h

+ print(ca_ext_h)

  

  # Toggle the "is-default" value a couple of times.

  isdef = ca.Get('org.fedorahosted.certmonger.ca', 'is-default')

- print isdef, "->",

+ print(isdef, "->", end=' ')

  

  ca.Set('org.fedorahosted.certmonger.ca', 'is-default', not isdef)

  

  isdef = ca.Get('org.fedorahosted.certmonger.ca', 'is-default')

- print isdef, "->",

+ print(isdef, "->", end=' ')

  

  ca.Set('org.fedorahosted.certmonger.ca', 'is-default', not isdef)

  

  isdef = ca.Get('org.fedorahosted.certmonger.ca', 'is-default')

- print isdef

+ print(isdef)

  

  cm.remove_known_ca(path)

file modified
+73 -32

@@ -1,4 +1,3 @@ 

- #!/usr/bin/python

  import dbus

  import xml.etree.ElementTree

  import os

@@ -15,7 +14,10 @@ 

  	for prop in props.keys():

  		value = props[prop]

  		if value != i.Get(interface, prop):

- 			print("%s: property %s.%s mismatch (%s, %s)" % (objpath, interface, prop, value, i.Get(interface, prop)))

+ 			print("%s: property %s.%s mismatch (%s, %s)" % (

+ 				objpath, interface,

+ 				prop, value,

+ 				i.Get(interface, prop)))

  			return False

  	return True

  

@@ -25,7 +27,7 @@ 

  	out_args = 0

  	o = bus.get_object('org.fedorahosted.certmonger', objpath)

  	i = dbus.Interface(o, interface)

- 	for child in idata.getchildren():

+ 	for child in idata:

  		if child.tag == 'arg':

  			if child.get('direction') != 'out':

  				in_args = in_args + 1

@@ -36,13 +38,16 @@ 

  		m = i.get_dbus_method(method)

  		if out_args == 0:

  			m()

- 			print("[ %s: %s.%s ]\n" % (objpath, interface, method))

+ 			print("[ %s: %s.%s ]\n" % (

+ 				objpath, interface, method))

  		elif out_args == 1:

  			result = m()

- 			print("[ %s: %s.%s ]\n%s\n" % (objpath, interface, method, result))

+ 			print("[ %s: %s.%s ]\n%s\n" % (

+ 				objpath, interface, method, result))

  		else:

  			result = m()

- 			print("[ %s: %s.%s ]\n%s\n" % (objpath, interface, method, result))

+ 			print("[ %s: %s.%s ]\n%s\n" % (

+ 				objpath, interface, method, result))

  	elif method == 'Get' or method == 'Set' or method == 'GetAll':

  		# We check on properties elsewhere.

  		return True

@@ -50,11 +55,13 @@ 

  	elif method == 'add_known_ca' or method == 'remove_known_ca':

  		(result, path) = i.add_known_ca('Test CA', '/usr/bin/env', [])

  		if not result:

- 			print("[ %s : %s.%s ]: add_known_ca error\n" % (objpath, interface, method))

+ 			print("[ %s : %s.%s ]: add_known_ca error\n" % (

+ 				objpath, interface, method))

  			return False

  		result = i.remove_known_ca(path)

  		if not result:

- 			print("[ %s : %s.%s ]: remove_known_ca error\n" % (objpath, interface, method))

+ 			print("[ %s : %s.%s ]: remove_known_ca error\n" % (

+ 				objpath, interface, method))

  			return False

  		print("[ %s : %s.%s ]\nOK\n" % (objpath, interface, method))

  	elif method == 'add_request' or method == 'remove_request':

@@ -71,11 +78,13 @@ 

  		}

  		(result, path) = i.add_request(properties)

  		if not result:

- 			print("[ %s : %s.%s ]: add_request error\n" % (objpath, interface, method))

+ 			print("[ %s : %s.%s ]: add_request error\n" % (

+ 				objpath, interface, method))

  			return False

  		result = i.remove_request(path)

  		if not result:

- 			print("[ %s : %s.%s ]: remove_request error\n" % (objpath, interface, method))

+ 			print("[ %s : %s.%s ]: remove_request error\n" % (

+ 				objpath, interface, method))

  			return False

  		print("[ %s : %s.%s ]\nOK\n" % (objpath, interface, method))

  	elif method == 'find_ca_by_nickname':

@@ -83,7 +92,10 @@ 

  		o = bus.get_object('org.fedorahosted.certmonger', capath)

  		i = dbus.Interface(o, 'org.freedesktop.DBus.Properties')

  		if i.Get('org.fedorahosted.certmonger.ca', 'nickname') != 'local':

- 			print("[ %s : %s.%s ] error: %s\n" % (objpath, interface, method, i.Get('org.fedorahosted.certmonger.ca', 'nickname')))

+ 			print("[ %s : %s.%s ] error: %s\n" % (

+ 				objpath, interface, method,

+ 				i.Get('org.fedorahosted.certmonger.ca',

+ 				      'nickname')))

  			return False

  		print("[ %s : %s.%s ]\nOK\n" % (objpath, interface, method))

  	elif method == 'find_request_by_nickname':

@@ -91,7 +103,10 @@ 

  		o = bus.get_object('org.fedorahosted.certmonger', reqpath)

  		i = dbus.Interface(o, 'org.freedesktop.DBus.Properties')

  		if i.Get('org.fedorahosted.certmonger.request', 'nickname') != 'Buddy':

- 			print("[ %s : %s.%s ] error: %s\n" % (objpath, interface, method, i.Get('org.fedorahosted.certmonger.request', 'nickname')))

+ 			print("[ %s : %s.%s ] error: %s\n" % (

+ 				objpath, interface, method,

+ 				i.Get('org.fedorahosted.certmonger.request',

+ 				      'nickname')))

  			return False

  		print("[ %s : %s.%s ]\nOK\n" % (objpath, interface, method))

  	elif method == 'modify':

@@ -101,23 +116,26 @@ 

  		mods[propname] = [propval,]

  		status, path = i.modify(mods)

  		if not status:

- 			print("[ %s : %s.%s ] error\n" % (objpath, interface, method))

+ 			print("[ %s : %s.%s ] error\n" % (

+ 				objpath, interface, method))

  			return False

- 		print("[ %s : %s.%s ]\n%d on %s" % (objpath, interface, method, status, path))

+ 		print("[ %s : %s.%s ]\n%d on %s" % (

+ 			objpath, interface, method, status, path))

  		props = dbus.Interface(o, 'org.freedesktop.DBus.Properties')

  		prop = props.Get(interface, 'template-eku')

- 		print("After setting %s to %s, we got %s\n" % (propname, propval, prop))

+ 		print("After setting %s to %s, we got %s\n" % (

+ 			propname, propval, prop))

  	else:

  		# We're in FIXME territory.

  		print('FIXME: need support for "%s"' % method)

  		return False

  	# If we caused things to start churning, wait for them to settle.

-         if method == 'resubmit':

-             props = dbus.Interface(o, 'org.freedesktop.DBus.Properties')

-             prop = props.Get(interface, 'status')

-             while prop != 'MONITORING':

-                 time.sleep(1)

-                 prop = props.Get(interface, 'status')

+ 	if method == 'resubmit':

+ 		props = dbus.Interface(o, 'org.freedesktop.DBus.Properties')

+ 		prop = props.Get(interface, 'status')

+ 		while prop != 'MONITORING':

+ 			time.sleep(1)

+ 			prop = props.Get(interface, 'status')

  	return True

  

  def iget(child, proxy, interface, prop):

@@ -132,14 +150,15 @@ 

  		elif child.get('type') == 'as':

  			value = ['']

  		else:

- 			print("%s.%s: %s" % (interface, prop, child.get('type')))

+ 			print("%s.%s: %s" % (

+ 				interface, prop, child.get('type')))

  			return False

  	return value

  

  def examine_interface(objpath, interface, idata):

  	o = bus.get_object('org.fedorahosted.certmonger', objpath)

  	i = dbus.Interface(o, 'org.freedesktop.DBus.Properties')

- 	for child in idata.getchildren():

+ 	for child in idata:

  		if child.tag == 'property':

  			prop = child.get('name')

  			if child.get('access') == 'read':

@@ -149,7 +168,12 @@ 

  				if prop == 'external-helper' or prop == 'scep-ca-identifier':

  					cai = dbus.Interface(o, 'org.fedorahosted.certmonger.ca')

  					if cai.get_type() != 'EXTERNAL':

- 						print("%s: warning: property %s.%s not settable on this object" % (objpath, interface, prop))

+ 						print("%s: warning: property "

+ 						      "%s.%s not settable on "

+ 						      "this object" % (

+ 								objpath,

+ 								interface,

+ 								prop))

  						continue

  				# Check that we can read it, tweak it, and then reset it.

  				value = iget(child, i, interface, prop)

@@ -164,19 +188,36 @@ 

  				elif child.get('type') == 'as':

  					newvalue = ['x'] + value

  				else:

- 					print("%s.%s: %s" % (interface, prop, child.get('type')))

+ 					print("%s.%s: %s" % (

+ 						    interface, prop,

+ 						    child.get('type')))

  					return False

  				if newvalue:

  					if newvalue == value:

- 						print("%s: error determining new value: (%s, %s): %s" % (objpath, interface, prop, value))

+ 						print("%s: error determining "

+ 						      "new value: (%s, %s): "

+ 						      "%s" % (

+ 								objpath,

+ 								interface,

+ 								prop, value))

  						return False

  					i.Set(interface, prop, newvalue)

  					if newvalue != iget(child, i, interface, prop):

- 						print("%s: property %s.%s not set: (%s, %s)" % (objpath, interface, prop, value, newvalue))

+ 						print("%s: property %s.%s not"

+ 						      " set: (%s, %s)" % (

+ 								objpath,

+ 								interface,

+ 								prop, value,

+ 								newvalue))

  						return False

  					i.Set(interface, prop, value)

  					if value != iget(child, i, interface, prop):

- 						print("%s: property %s.%s not reset: (%s, %s)" % (objpath, interface, prop, newvalue, value))

+ 						print("%s: property %s.%s not"

+ 						      " reset: (%s, %s)" % (

+ 								objpath,

+ 								interface,

+ 								prop, newvalue,

+ 								value))

  						return False

  		elif child.tag == 'method':

  			method = child.get('name')

@@ -185,7 +226,7 @@ 

  		elif child.tag == 'signal':

  			continue

  		else:

- 			print "FIXME: handle child tag %s" % child.tag

+ 			print("FIXME: handle child tag %s" % child.tag)

  			return False

  	return True

  

@@ -197,13 +238,13 @@ 

  

  	# Check if the object supports properties interfaces.

  	props = False

- 	for child in x.getchildren():

+ 	for child in x:

  		if child.tag == 'interface':

  			if child.get('name') == 'org.freedesktop.DBus.Properties':

  				props = True

  

  	# Look at the interfaces and child nodes.

- 	for child in x.getchildren():

+ 	for child in x:

  		if child.tag == 'interface':

  			if props and not check_props(objpath, child.get('name')):

  				return False

@@ -216,7 +257,7 @@ 

  				childpath = objpath + '/' + child.get('name')

  			examine_object(childpath)

  		else:

- 			print "FIXME: handle child tag %s" % child.tag

+ 			print("FIXME: handle child tag %s" % child.tag)

  			return False

  	return True

  

@@ -1,4 +1,4 @@ 

- #!/usr/bin/python2

+ #!/usr/bin/python3

  

  # Given `openssl asn1parse` output of a CSR, look for the V2 Template

  # extension and output its data if found.  Nonzero exit status if

@@ -21,7 +21,7 @@ 

      #

      if state == STATE_FOUND and 'OCTET STRING' in line:

          result = re.search(r'\[HEX DUMP\]:(\w*)', line)

-         sys.stdout.write(binascii.unhexlify(result.group(1)))

+         sys.stdout.buffer.write(binascii.unhexlify(result.group(1)))

          state = STATE_DONE

          break

  

As it is commonly known, Python2 reaches its EOL in 2020.
For this reason, many distributions massively drop Python2
packages.

Certmonger utilizes by itself only python-dbus (among standard modules) and only at
build time for testing. With some help of 2to3 utility
several tests helpers have been migrated to Python3:
- converts the print statement to the print() function (reindented)
- remove u"..." literals
- remove Integer literals l and L
- change shebang to python3

TODO: migrate examples of helpers.

Fixes: https://pagure.io/certmonger/issue/138

Close PR as duplicate (not officially released yet).

Pull-Request has been closed by slev

3 months ago