Skip to content

Commit 6977aaa

Browse files
authored
Merge pull request #5694 from fstagni/80_fixes6
[8.0] do no look anymore for __RCSID__ (and many other py3 fixes)
2 parents a118a97 + 50bfde0 commit 6977aaa

File tree

116 files changed

+85
-609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+85
-609
lines changed

src/DIRAC/Core/Base/API.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
""" DIRAC API Base Class """
22

3-
from __future__ import print_function
4-
from __future__ import absolute_import
5-
from __future__ import division
6-
73
import pprint
84
import sys
95

@@ -13,8 +9,6 @@
139
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getDNForUsername
1410
from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSites
1511

16-
__RCSID__ = "$Id$"
17-
1812
COMPONENT_NAME = "API"
1913

2014

@@ -58,7 +52,7 @@ def _printFormattedDictList(dictList, fields, uniqueField, orderBy):
5852
# TODO: some of these can just be functions, and moved out of here
5953

6054

61-
class API(object):
55+
class API:
6256
"""An utilities class for APIs"""
6357

6458
#############################################################################

src/DIRAC/Core/Base/AgentModule.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
"""
66
Base class for all agent modules
77
"""
8-
from __future__ import absolute_import
9-
from __future__ import division
10-
from __future__ import print_function
11-
12-
__RCSID__ = "$Id$"
13-
148
import os
159
import threading
1610
import time
1711
import signal
12+
import importlib
13+
import inspect
1814

1915
import DIRAC
2016
from DIRAC import S_OK, S_ERROR, gConfig, gLogger, rootPath
@@ -29,7 +25,7 @@
2925
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
3026

3127

32-
class AgentModule(object):
28+
class AgentModule:
3329
"""Base class for all agent modules
3430
3531
This class is used by the AgentReactor Class to steer the execution of
@@ -71,9 +67,8 @@ class AgentModule(object):
7167
def __init__(self, agentName, loadName, baseAgentName=False, properties={}):
7268
"""
7369
Common __init__ method for all Agents.
74-
All Agent modules must define:
75-
__doc__
76-
__RCSID__
70+
All Agent modules must define: __doc__
71+
7772
They are used to populate __codeProperties
7873
7974
The following Options are used from the Configuration:
@@ -154,18 +149,23 @@ def __init__(self, agentName, loadName, baseAgentName=False, properties={}):
154149
self.__initialized = False
155150

156151
def __getCodeInfo(self):
157-
versionVar = "__RCSID__"
158-
docVar = "__doc__"
152+
159153
try:
160-
self.__agentModule = __import__(self.__class__.__module__, globals(), locals(), versionVar)
154+
self.__codeProperties["version"] = importlib.metadata.version(
155+
inspect.getmodule(self).__package__.split(".")[0]
156+
)
157+
except Exception:
158+
self.log.exception(f"Failed to find version for {self!r}")
159+
self.__codeProperties["version"] = "unset"
160+
try:
161+
self.__agentModule = __import__(self.__class__.__module__, globals(), locals(), "__doc__")
161162
except Exception as excp:
162163
self.log.exception("Cannot load agent module", lException=excp)
163-
for prop in ((versionVar, "version"), (docVar, "description")):
164-
try:
165-
self.__codeProperties[prop[1]] = getattr(self.__agentModule, prop[0])
166-
except Exception:
167-
self.log.error("Missing property", prop[0])
168-
self.__codeProperties[prop[1]] = "unset"
164+
try:
165+
self.__codeProperties["description"] = getattr(self.__agentModule, "__doc__")
166+
except Exception:
167+
self.log.error("Missing property __doc__")
168+
self.__codeProperties["description"] = "unset"
169169
self.__codeProperties["DIRACVersion"] = DIRAC.version
170170
self.__codeProperties["platform"] = DIRAC.getPlatform()
171171

@@ -198,7 +198,6 @@ def am_initialize(self, *initArgs):
198198
self.log.notice("Loaded agent module %s" % self.__moduleProperties["fullName"])
199199
self.log.notice(" Site: %s" % DIRAC.siteName())
200200
self.log.notice(" Setup: %s" % gConfig.getValue("/DIRAC/Setup"))
201-
self.log.notice(" Base Module version: %s " % __RCSID__)
202201
self.log.notice(" Agent version: %s" % self.__codeProperties["version"])
203202
self.log.notice(" DIRAC version: %s" % DIRAC.version)
204203
self.log.notice(" DIRAC platform: %s" % DIRAC.getPlatform())

src/DIRAC/Core/Base/AgentReactor.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
must inherit from the base class AgentModule
2525
2626
"""
27-
from __future__ import absolute_import
28-
from __future__ import division
29-
from __future__ import print_function
3027
import time
3128

3229
from DIRAC import S_OK, S_ERROR, gLogger
@@ -35,10 +32,8 @@
3532
from DIRAC.Core.Utilities import ThreadScheduler
3633
from DIRAC.Core.Base.AgentModule import AgentModule
3734

38-
__RCSID__ = "$Id$"
3935

40-
41-
class AgentReactor(object):
36+
class AgentReactor:
4237
"""
4338
Main interface to DIRAC Agents. It allows to :
4439
- define a Agents modules to be executed

src/DIRAC/Core/Base/CLI.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
several utilities and signal handlers of general purpose.
88
"""
99

10-
from __future__ import print_function
11-
from __future__ import absolute_import
12-
from __future__ import division
13-
14-
__RCSID__ = "$Id$"
15-
1610
import cmd
1711
import sys
1812
import os

src/DIRAC/Core/Base/Client.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
33
This class exposes possible RPC calls, given a url of a service.
44
"""
5-
from __future__ import absolute_import
6-
from __future__ import division
7-
from __future__ import print_function
8-
9-
__RCSID__ = "$Id$"
10-
115
import ast
126
from functools import partial
137

@@ -40,7 +34,7 @@ def __get__(self, instance, owner):
4034
return func
4135

4236

43-
class Client(object):
37+
class Client:
4438
"""Simple class to redirect unknown actions directly to the server. Arguments
4539
to the constructor are passed to the RPCClient constructor as they are.
4640
Some of them can however be overwritten at each call (url and timeout).

src/DIRAC/Core/Base/DB.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
""" DB is a base class for multiple DIRAC databases that are based on MySQL.
22
It uniforms the way the database objects are constructed
33
"""
4-
from __future__ import absolute_import
5-
from __future__ import division
6-
from __future__ import print_function
7-
84
from DIRAC.Core.Base.DIRACDB import DIRACDB
95
from DIRAC.Core.Utilities.MySQL import MySQL
106
from DIRAC.ConfigurationSystem.Client.Utilities import getDBParameters
117

12-
__RCSID__ = "$Id$"
13-
148

159
class DB(DIRACDB, MySQL):
1610
"""All DIRAC DB classes should inherit from this one (unless using sqlalchemy)"""

src/DIRAC/Core/Base/DIRACDB.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from DIRAC.ConfigurationSystem.Client.PathFinder import getDatabaseSection
77

88

9-
class DIRACDB(object):
9+
class DIRACDB:
1010
"""Extended in DB, SQLAlchemyDB, ElasticDB"""
1111

1212
def __init__(self, *args, **kwargs):

src/DIRAC/Core/Base/ElasticDB.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
""" ElasticDB is a base class used to connect an Elasticsearch database and manages queries.
22
"""
3-
from __future__ import absolute_import
4-
from __future__ import division
5-
from __future__ import print_function
6-
7-
__RCSID__ = "$Id$"
8-
93
from DIRAC.Core.Base.DIRACDB import DIRACDB
104
from DIRAC.Core.Utilities.ElasticSearchDB import ElasticSearchDB
115
from DIRAC.ConfigurationSystem.Client.Utilities import getElasticDBParameters

src/DIRAC/Core/Base/ExecutorModule.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22
33
Just provides a number of functions used by all executors
44
"""
5-
from __future__ import absolute_import
6-
from __future__ import division
7-
from __future__ import print_function
8-
95
import os
106
from DIRAC import S_OK, S_ERROR, gConfig, gLogger, rootPath
117
from DIRAC.ConfigurationSystem.Client import PathFinder
128
from DIRAC.Core.Utilities.Shifter import setupShifterProxyInEnv
139
from DIRAC.Core.Utilities.ReturnValues import isReturnStructure
1410

15-
__RCSID__ = "$Id$"
16-
1711

18-
class ExecutorModule(object):
12+
class ExecutorModule:
1913
"""All executors should inherit from this module"""
2014

2115
@classmethod

src/DIRAC/Core/Base/ExecutorReactor.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
must inherit from the base class ExecutorModule
2121
2222
"""
23-
from __future__ import absolute_import
24-
from __future__ import division
25-
from __future__ import print_function
26-
2723
import time
2824
import threading
2925
from DIRAC import S_OK, S_ERROR, gLogger
@@ -32,11 +28,9 @@
3228
from DIRAC.Core.Base.private.ModuleLoader import ModuleLoader
3329
from DIRAC.Core.Base.ExecutorModule import ExecutorModule
3430

35-
__RCSID__ = "$Id$"
36-
3731

38-
class ExecutorReactor(object):
39-
class AliveLock(object):
32+
class ExecutorReactor:
33+
class AliveLock:
4034
def __init__(self):
4135
self.__alive = 0
4236
self.__cond = threading.Condition(threading.Lock())
@@ -60,7 +54,7 @@ def lockUntilAllDead(self):
6054
self.__cond.wait(1)
6155
self.__cond.release()
6256

63-
class MindCluster(object):
57+
class MindCluster:
6458
def __init__(self, mindName, aliveLock):
6559
self.__mindName = mindName
6660
self.__modules = {}

0 commit comments

Comments
 (0)