Skip to content

Commit c31fe30

Browse files
committed
fix: use absolute imports
1 parent 9a87d4c commit c31fe30

File tree

6 files changed

+16
-86
lines changed

6 files changed

+16
-86
lines changed

Pilot/dirac-pilot.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,13 @@
2424
import time
2525
from io import StringIO
2626

27-
try:
28-
from Pilot.pilotTools import (
29-
Logger,
30-
PilotParams,
31-
RemoteLogger,
32-
getCommand,
33-
pythonPathCheck,
34-
)
35-
except ModuleNotFoundError:
36-
from pilotTools import (
37-
Logger,
38-
PilotParams,
39-
RemoteLogger,
40-
getCommand,
41-
pythonPathCheck,
42-
)
27+
from .pilotTools import (
28+
Logger,
29+
PilotParams,
30+
RemoteLogger,
31+
getCommand,
32+
pythonPathCheck,
33+
)
4334

4435
############################
4536

Pilot/pilotCommands.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,7 @@ def __init__(self, pilotParams):
3030
from http.client import HTTPSConnection
3131
from shlex import quote
3232

33-
try:
34-
from Pilot.pilotTools import (
35-
CommandBase,
36-
getSubmitterInfo,
37-
retrieveUrlTimeout,
38-
safe_listdir,
39-
sendMessage,
40-
)
41-
except ModuleNotFoundError:
42-
from pilotTools import (
33+
from .pilotTools import (
4334
CommandBase,
4435
getSubmitterInfo,
4536
retrieveUrlTimeout,

Pilot/pilotTools.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
from urllib.parse import urlencode
2323
from urllib.request import urlopen
2424

25-
try:
26-
from Pilot.proxyTools import getVO
27-
except ModuleNotFoundError:
28-
from proxyTools import getVO
25+
from .proxyTools import getVO
2926

3027
# Utilities functions
3128

Pilot/tests/Test_Pilot.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010
# imports
1111
import unittest
1212

13-
try:
14-
from Pilot.pilotCommands import CheckWorkerNode, ConfigureSite, NagiosProbes
15-
from Pilot.pilotTools import PilotParams
16-
except ModuleNotFoundError:
17-
from pilotCommands import CheckWorkerNode, ConfigureSite, NagiosProbes
18-
from pilotTools import PilotParams
13+
from ..pilotCommands import CheckWorkerNode, ConfigureSite, NagiosProbes
14+
from ..pilotTools import PilotParams
1915

2016

2117
class PilotTestCase(unittest.TestCase):

Pilot/tests/Test_proxyTools.py

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import unittest
88
from unittest.mock import patch
99

10-
try:
11-
from Pilot.proxyTools import getVO, parseASN1
12-
except ModuleNotFoundError:
13-
from proxyTools import getVO, parseASN1
10+
from ..proxyTools import getVO, parseASN1
1411

1512
class TestProxyTools(unittest.TestCase):
1613
def test_getVO(self):
@@ -84,46 +81,7 @@ def __createFakeProxy(self, proxyFile):
8481
"""
8582
Create a fake proxy locally.
8683
"""
87-
8884
basedir = os.path.dirname(__file__)
89-
shutil.copy(basedir + "/certs/user/userkey.pem", basedir + "/certs/user/userkey400.pem")
90-
os.chmod(basedir + "/certs/user/userkey400.pem", 0o400)
91-
ret = self.createFakeProxy(
92-
basedir + "/certs/user/usercert.pem",
93-
basedir + "/certs/user/userkey400.pem",
94-
"fakeserver.cern.ch:15000",
95-
"fakevo",
96-
basedir + "/certs//host/hostcert.pem",
97-
basedir + "/certs/host/hostkey.pem",
98-
basedir + "/certs/ca",
99-
proxyFile,
100-
)
101-
os.remove(basedir + "/certs/user/userkey400.pem")
102-
return ret
103-
104-
def createFakeProxy(self, usercert, userkey, serverURI, vo, hostcert, hostkey, CACertDir, proxyfile):
105-
"""
106-
voms-proxy-fake --cert usercert.pem
107-
--key userkey.pem
108-
-rfc
109-
-fqan "/fakevo/Role=user/Capability=NULL"
110-
-uri fakeserver.cern.ch:15000
111-
-voms fakevo
112-
-hostcert hostcert.pem
113-
-hostkey hostkey.pem
114-
-certdir ca
115-
"""
116-
opt = (
117-
'--cert %s --key %s -rfc -fqan "/fakevo/Role=user/Capability=NULL" -uri %s -voms %s -hostcert %s'
118-
" -hostkey %s -certdir %s -out %s"
119-
% (usercert, userkey, serverURI, vo, hostcert, hostkey, CACertDir, proxyfile)
120-
)
121-
proc = subprocess.Popen(
122-
shlex.split("voms-proxy-fake " + opt),
123-
bufsize=1,
124-
stdout=sys.stdout,
125-
stderr=sys.stderr,
126-
universal_newlines=True,
127-
)
128-
proc.communicate()
129-
return proc.returncode
85+
shutil.copy(basedir + "/certs/voms/proxy.pem", proxyFile)
86+
return 0
87+

Pilot/tests/Test_simplePilotLogger.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
import unittest
99
from unittest.mock import patch
1010

11-
try:
12-
from Pilot.pilotTools import CommandBase, Logger, PilotParams
13-
except ModuleNotFoundError:
14-
from pilotTools import CommandBase, Logger, PilotParams
11+
from ..pilotTools import CommandBase, Logger, PilotParams
1512

1613
class TestPilotParams(unittest.TestCase):
1714
@patch("sys.argv")

0 commit comments

Comments
 (0)