Skip to content

Commit 097499f

Browse files
committed
fix: Core/Base to py3 only
1 parent 108c25f commit 097499f

File tree

12 files changed

+23
-77
lines changed

12 files changed

+23
-77
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: 14 additions & 11 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
@@ -151,13 +147,20 @@ def __init__(self, agentName, loadName, baseAgentName=False, properties={}):
151147
self.__monitorLastStatsUpdate = -1
152148
self.monitor = None
153149
self.__initializeMonitor()
154-
self.__initialized = False
150+
self.__initialized = False
155151

156152
def __getCodeInfo(self):
157-
docVar = "__doc__"
158-
try:
153+
154+
try:
155+
self.__codeProperties["version"] = importlib.metadata.version(
156+
inspect.getmodule(self).__package__.split(".")[0]
157+
)
158+
except Exception:
159+
self.log.exception(f"Failed to find version for {self!r}")
160+
self.__codeProperties["version"] = "unset"
161+
try:
159162
self.__agentModule = __import__(self.__class__.__module__, globals(), locals(), "__doc__")
160-
except Exception as excp:
163+
except Exception as excp:
161164
self.log.exception("Cannot load agent module", lException=excp)
162165
try:
163166
self.__codeProperties["description"] = getattr(self.__agentModule, "__doc__")

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)