Skip to content

Commit d9da8cc

Browse files
authored
Merge pull request #8024 from fstagni/cherry-pick-2-059fe497a-integration
[sweep:integration] Fix return code
2 parents f85ba13 + a5691f6 commit d9da8cc

File tree

8 files changed

+20
-25
lines changed

8 files changed

+20
-25
lines changed

src/DIRAC/FrameworkSystem/scripts/dirac_admin_get_proxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
import os
1414

1515
import DIRAC
16-
from DIRAC import gLogger, S_OK, S_ERROR
16+
from DIRAC import S_ERROR, S_OK, gLogger
17+
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
1718
from DIRAC.Core.Base.Script import Script
1819
from DIRAC.Core.Security.DiracX import addTokenToPEM
1920
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
20-
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
2121

2222

2323
class Params:

src/DIRAC/FrameworkSystem/scripts/dirac_admin_proxy_upload.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
Example:
1010
$ dirac-admin-proxy-upload
1111
"""
12-
import sys
13-
12+
from DIRAC import exit as dExit
1413
from DIRAC.Core.Base.Script import Script
1514
from DIRAC.FrameworkSystem.Client.ProxyUpload import CLIParams, uploadProxy
1615

@@ -25,8 +24,8 @@ def main():
2524
retVal = uploadProxy(cliParams)
2625
if not retVal["OK"]:
2726
print(retVal["Message"])
28-
sys.exit(1)
29-
sys.exit(0)
27+
dExit(1)
28+
dExit(0)
3029

3130

3231
if __name__ == "__main__":

src/DIRAC/FrameworkSystem/scripts/dirac_proxy_info.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def main():
7171
Script.disableCS()
7272
Script.parseCommandLine()
7373

74-
from DIRAC import gLogger
74+
from DIRAC import gLogger, exit as dExit
7575
from DIRAC.Core.Security.ProxyInfo import getProxyInfo, getProxyStepsInfo
7676
from DIRAC.Core.Security.ProxyInfo import formatProxyInfoAsString, formatProxyStepsInfoAsString
7777
from DIRAC.Core.Security import VOMS
@@ -87,7 +87,7 @@ def main():
8787
result = getProxyInfo(params.proxyLoc, not params.vomsEnabled)
8888
if not result["OK"]:
8989
gLogger.error(result["Message"])
90-
sys.exit(1)
90+
dExit(1)
9191
infoDict = result["Value"]
9292
gLogger.notice(formatProxyInfoAsString(infoDict))
9393
if not infoDict["isProxy"]:
@@ -101,12 +101,13 @@ def main():
101101

102102
def invalidProxy(msg):
103103
gLogger.error("Invalid proxy:", msg)
104-
sys.exit(1)
104+
dExit(1)
105105

106106
if params.uploadedInfo:
107107
result = gProxyManager.getUserProxiesInfo()
108108
if not result["OK"]:
109109
gLogger.error("Could not retrieve the uploaded proxies info", result["Message"])
110+
dExit(1)
110111
else:
111112
uploadedInfo = result["Value"]
112113
if not uploadedInfo:
@@ -157,8 +158,6 @@ def invalidProxy(msg):
157158
except Exception as e:
158159
invalidProxy(f"Failed to access DiracX: {e}")
159160

160-
sys.exit(0)
161-
162161

163162
if __name__ == "__main__":
164163
main()

src/DIRAC/Interfaces/scripts/dirac_admin_list_users.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def printUsersInGroup(group=False):
4545
print("All users registered:")
4646
for username in result["Value"]:
4747
print(f" {username}")
48+
else:
49+
print(result["Message"])
50+
DIRAC.exit(1)
4851

4952
def describeUsersInGroup(group=False):
5053
result = diracAdmin.csListUsers(group)
@@ -55,6 +58,9 @@ def describeUsersInGroup(group=False):
5558
print("All users registered:")
5659
result = diracAdmin.csDescribeUsers(result["Value"])
5760
print(diracAdmin.pPrint.pformat(result["Value"]))
61+
else:
62+
print(result["Message"])
63+
DIRAC.exit(1)
5864

5965
for group in args:
6066
if "all" in args:
@@ -64,9 +70,6 @@ def describeUsersInGroup(group=False):
6470
else:
6571
describeUsersInGroup(group)
6672

67-
for error in errorList:
68-
print("ERROR %s: %s" % error)
69-
7073
DIRAC.exit(exitCode)
7174

7275

src/DIRAC/Interfaces/scripts/dirac_admin_pilot_summary.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ def main():
3838
diracAdmin = DiracAdmin()
3939

4040
result = diracAdmin.getPilotSummary()
41-
if result["OK"]:
42-
DIRAC.exit(0)
43-
else:
41+
if not result["OK"]:
4442
print(result["Message"])
4543
DIRAC.exit(2)
4644

src/DIRAC/Interfaces/scripts/dirac_dms_lfn_metadata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def main():
3737

3838
dirac = Dirac()
3939
exitCode = 0
40-
errorList = []
4140

4241
if len(lfns) == 1:
4342
try:

src/DIRAC/Interfaces/scripts/dirac_framework_ping_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def main():
7878
exitCode = 2
7979
elif not result["OK"]:
8080
print("ERROR: ", result["Message"])
81-
exitCode = 2
81+
exitCode = 1
8282

8383
DIRAC.exit(exitCode)
8484

src/DIRAC/Interfaces/scripts/dirac_wms_job_status.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
$ dirac-wms-job-status 2
1111
JobID=2 Status=Done; MinorStatus=Execution Complete; Site=EELA.UTFSM.cl;
1212
"""
13-
import os
1413
import datetime
14+
import os
15+
1516
from DIRAC.Core.Base.Script import Script
1617

1718

@@ -28,7 +29,6 @@ def main():
2829
from DIRAC.Interfaces.API.Dirac import Dirac, parseArguments
2930

3031
dirac = Dirac()
31-
exitCode = 0
3232

3333
jobs = []
3434
for key, value in sws:
@@ -58,12 +58,9 @@ def main():
5858
print("JobID=" + str(job), end=" ")
5959
for status in result["Value"][job].items():
6060
print("%s=%s;" % status, end=" ")
61-
print()
6261
else:
63-
exitCode = 2
6462
print(f"ERROR: {result['Message']}")
65-
66-
DIRACExit(exitCode)
63+
DIRACExit(2)
6764

6865

6966
if __name__ == "__main__":

0 commit comments

Comments
 (0)