Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ConfigParser with configparser (Python3 compatibility) #28822

Merged
merged 1 commit into from Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
from __future__ import print_function
import ConfigParser
import configparser as ConfigParser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mteroerd can you please cross-check this change if this is still working for you?
Thx.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if Alignment/APEEstimation/test/autoSubmitter/config.ini is just a template, it should be enough to test the parsing of the INI file.
I tried with python autoSubmitter.py -c config.ini there are no crash due to ConfigParser.
If you have a real config.ini file, I can try again with that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmusich I tried one config file and it seems to work just fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mteroerd also in a CMSSW version compiled with Py3 e.g.: CMSSW_11_1_PY3_X_2020-01-28-2300? thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmusich When running in that CMSSW version, I get an error, which however is not because of this change. It is because of the enableCAF function call that is done. It executes /usr/share/Modules/init/python.py, which produces a syntax error as in that file there is an exec statement without parantheses.
I get other errors from using "has_key" on dictionaries instead of "x in dictionary", which apparently is not allowed in Py3 anymore.

However, the configparser itself seems to work fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mteroerd thanks for the investigation.
We eventually need to migrate all tools to be Py3 compliant, see issue: #28830.
When you have time would be available to try to migrate the APE submission code to be Py2 and Py3 compliant? Thanks!

import argparse
import shelve
import sys
Expand Down
@@ -1,6 +1,6 @@
from __future__ import absolute_import
import os
import ConfigParser # needed for exceptions in this module
import configparser as ConfigParser # needed for exceptions in this module
from . import configTemplates
from .genericValidation import GenericValidation
from .helperFunctions import replaceByMap, getCommandOutput2, cppboolstring, pythonboolstring, clean_name
Expand Down
2 changes: 1 addition & 1 deletion Alignment/OfflineValidation/test/submitAllJobs.py
Expand Up @@ -17,7 +17,7 @@
import os,sys
import copy
import string, re
import ConfigParser, json
import configparser as ConfigParser, json
from optparse import OptionParser
from subprocess import Popen, PIPE

Expand Down
2 changes: 1 addition & 1 deletion CondCore/DBOutputService/scripts/cmscond_logdb_dump
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from ConfigParser import ConfigParser
from ConfigParser import configparser as ConfigParser
from copy import copy
from optparse import OptionParser, Option, OptionValueError
import coral
Expand Down
2 changes: 1 addition & 1 deletion DQM/Integration/python/config/environment_cfi.py
@@ -1,7 +1,7 @@
from __future__ import print_function
import os
import FWCore.ParameterSet.Config as cms
import ConfigParser
import configparser as ConfigParser

def loadDQMRunConfigFromFile():
# try reading the config
Expand Down
2 changes: 1 addition & 1 deletion DQMOffline/Alignment/test/alcarecoTester.py
Expand Up @@ -3,7 +3,7 @@
from __future__ import print_function
import os
import sys
import ConfigParser
import configparser as ConfigParser
import optparse
import datetime

Expand Down
@@ -1,6 +1,6 @@
#!/usr/bin/env python

import ConfigParser
import configparser as ConfigParser
import argparse
import numpy

Expand Down
2 changes: 1 addition & 1 deletion Geometry/TrackerCommonData/test/twikiExport.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python

import optparse
import ConfigParser
import configparser as ConfigParser

from os.path import expandvars

Expand Down
2 changes: 1 addition & 1 deletion HLTriggerOffline/Btag/python/helper.py
Expand Up @@ -5,7 +5,7 @@
"""
from __future__ import print_function

import ConfigParser as cp
import configparser as cp

Config=cp.ConfigParser()

Expand Down
2 changes: 1 addition & 1 deletion RecoVertex/BeamSpotProducer/scripts/BeamSpotWorkflow.py
Expand Up @@ -37,7 +37,7 @@
import sys,os
import commands, re, time
import datetime
import ConfigParser
import configparser as ConfigParser
import xmlrpclib
from BeamSpotObj import BeamSpot
from IOVObj import IOV
Expand Down
2 changes: 1 addition & 1 deletion RecoVertex/BeamSpotProducer/test/InspectFwBeamSpot.py
Expand Up @@ -10,7 +10,7 @@


from __future__ import print_function
import ConfigParser
import configparser as ConfigParser
import ROOT
import sys
import math
Expand Down