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

Testing: Linting, Add pyupgrade and fix isort #6587

Merged
merged 13 commits into from Mar 21, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 23 additions & 11 deletions bin/rucio
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -27,27 +26,40 @@ import time
import traceback
import unittest
import uuid
from configparser import NoOptionError, NoSectionError
from copy import deepcopy
from datetime import datetime
from functools import wraps

from configparser import NoOptionError, NoSectionError
from tabulate import tabulate

# rucio module has the same name as this executable module, so this rule fails. pylint: disable=no-name-in-module
from rucio import version
from rucio.client import Client
from rucio.common.config import config_get, config_get_float
from rucio.common.exception import (DataIdentifierAlreadyExists, AccessDenied, DataIdentifierNotFound, InvalidObject,
RSENotFound, InvalidRSEExpression, InputValidationError, DuplicateContent,
RuleNotFound, CannotAuthenticate, MissingDependency, UnsupportedOperation,
RucioException, DuplicateRule, InvalidType, DuplicateCriteriaInDIDFilter,
DIDFilterSyntaxError)
from rucio.common.constants import ReplicaState
from rucio.common.exception import (
AccessDenied,
CannotAuthenticate,
DataIdentifierAlreadyExists,
DataIdentifierNotFound,
DIDFilterSyntaxError,
DuplicateContent,
DuplicateCriteriaInDIDFilter,
DuplicateRule,
InputValidationError,
InvalidObject,
InvalidRSEExpression,
InvalidType,
MissingDependency,
RSENotFound,
RucioException,
RuleNotFound,
UnsupportedOperation,
)
from rucio.common.extra import import_extras
from rucio.common.test_rucio_server import TestRucioServer
from rucio.common.utils import sizefmt, Color, detect_client_location, chunks, parse_did_filter_from_string, \
parse_did_filter_from_string_fe, extract_scope, setup_logger, StoreAndDeprecateWarningAction
from rucio.common.constants import ReplicaState
from rucio.common.utils import Color, StoreAndDeprecateWarningAction, chunks, detect_client_location, extract_scope, parse_did_filter_from_string, parse_did_filter_from_string_fe, setup_logger, sizefmt

EXTRA_MODULES = import_extras(['argcomplete'])

Expand Down Expand Up @@ -488,7 +500,7 @@ def attach(args):
try:
f = open(dids[0], 'r')
dids = [did.rstrip() for did in f.readlines()]
except IOError:
except OSError:
logger.error("Can't open file '" + dids[0] + "'.")
return FAILURE

Expand Down
1 change: 0 additions & 1 deletion bin/rucio-abacus-account
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-abacus-collection-replica
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-abacus-rse
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
38 changes: 24 additions & 14 deletions bin/rucio-admin
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -25,25 +24,36 @@ import signal
import sys
import time
import traceback
from textwrap import dedent
from configparser import NoOptionError, NoSectionError
from functools import wraps
from textwrap import dedent

from configparser import NoOptionError, NoSectionError
from tabulate import tabulate

from rucio import version
from rucio.client import Client
from rucio.common.config import config_get
from rucio.common.exception import (AccountNotFound, DataIdentifierAlreadyExists, AccessDenied,
DataIdentifierNotFound, InvalidObject, ReplicaNotFound,
RSENotFound, RSEOperationNotSupported, InvalidRSEExpression,
DuplicateContent, RuleNotFound, CannotAuthenticate,
Duplicate, ReplicaIsLocked, ConfigNotFound, ScopeNotFound,
InputValidationError)
from rucio.common.exception import (
AccessDenied,
AccountNotFound,
CannotAuthenticate,
ConfigNotFound,
DataIdentifierAlreadyExists,
DataIdentifierNotFound,
Duplicate,
DuplicateContent,
InputValidationError,
InvalidObject,
InvalidRSEExpression,
ReplicaIsLocked,
ReplicaNotFound,
RSENotFound,
RSEOperationNotSupported,
RuleNotFound,
ScopeNotFound,
)
from rucio.common.extra import import_extras
from rucio.common.utils import (chunks, construct_surl, sizefmt, get_bytes_value_from_string,
render_json, parse_response, extract_scope, clean_surls,
StoreAndDeprecateWarningAction)
from rucio.common.utils import StoreAndDeprecateWarningAction, chunks, clean_surls, construct_surl, extract_scope, get_bytes_value_from_string, parse_response, render_json, sizefmt
from rucio.rse import rsemanager as rsemgr

EXTRA_MODULES = import_extras(['argcomplete'])
Expand Down Expand Up @@ -1277,7 +1287,7 @@ def import_data(args):
print('There was problem with decoding your file.')
print(error)
return FAILURE
except IOError as error:
except OSError as error:
print('There was a problem with reading your file.')
print(error)
return FAILURE
Expand Down Expand Up @@ -1309,7 +1319,7 @@ def export_data(args):
print('File successfully written.')
print('Data successfully exported to %s' % args.file_path)
return SUCCESS
except IOError as error:
except OSError as error:
print('There was a problem with reading your file.')
print(error)
return FAILURE
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-atropos
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
3 changes: 1 addition & 2 deletions bin/rucio-auditor
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,7 +23,7 @@ import textwrap
import time
from datetime import datetime
from functools import partial
from multiprocessing import Queue, Process, Event, Pipe
from multiprocessing import Event, Pipe, Process, Queue

import rucio.common.config as config
import rucio.common.dumper as dumper
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-automatix
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-bb8
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-c3po
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-cache-client
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-cache-consumer
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-conveyor-finisher
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-conveyor-poller
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-conveyor-preparer
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-conveyor-receiver
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-conveyor-stager
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-conveyor-submitter
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-conveyor-throttler
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-dark-reaper
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
9 changes: 4 additions & 5 deletions bin/rucio-dumper
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,11 +17,11 @@ import argparse
import datetime
import logging
import sys

import tabulate

import rucio.common.dumper.consistency as consistency
import rucio.common.dumper.data_models as data_models

from rucio.common.dumper import error

logger = logging.getLogger('rucio-dumper')
Expand Down Expand Up @@ -130,7 +129,7 @@ if __name__ == "__main__":
fields.append(args.sum)
data = []
for key, value in data_dict.items():
total = sum((getattr(x, args.sum) for x in value))
total = sum(getattr(x, args.sum) for x in value)
# FIXME: Ugly hack to have some result
setattr(value[0], args.sum, total)
data.append(value[0])
Expand All @@ -139,12 +138,12 @@ if __name__ == "__main__":

if args.fields:
_show_fields = args.fields.split(',')
if not all((f in fields for f in _show_fields)):
if not all(f in fields for f in _show_fields):
error('Invalid field in --fields argument')
fields = _show_fields
elif args.hide:
_hide_fields = args.hide.split(',')
if not all((f in fields for f in _hide_fields)):
if not all(f in fields for f in _hide_fields):
error('Invalid field in --hide argument')
fields = [f for f in fields if f not in _hide_fields]

Expand Down
1 change: 0 additions & 1 deletion bin/rucio-follower
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-hermes
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-judge-cleaner
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-judge-evaluator
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-judge-injector
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-judge-repairer
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-kronos
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-minos
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-minos-temporary-expiration
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-necromancer
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-oauth-manager
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-reaper
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-replica-recoverer
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-rse-decommissioner
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-storage-consistency-actions
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-transmogrifier
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion bin/rucio-undertaker
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down