diff --git a/bin/rucio b/bin/rucio index 03758e56a9..a5126969c0 100755 --- a/bin/rucio +++ b/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"); @@ -27,27 +26,39 @@ 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 +from tabulate import tabulate EXTRA_MODULES = import_extras(['argcomplete']) @@ -488,7 +499,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 diff --git a/bin/rucio-abacus-account b/bin/rucio-abacus-account index 5070087e24..37cc76468a 100755 --- a/bin/rucio-abacus-account +++ b/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"); diff --git a/bin/rucio-abacus-collection-replica b/bin/rucio-abacus-collection-replica index 023e0f00de..fa383db973 100755 --- a/bin/rucio-abacus-collection-replica +++ b/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"); diff --git a/bin/rucio-abacus-rse b/bin/rucio-abacus-rse index 41809b86d8..5a5c586ec6 100755 --- a/bin/rucio-abacus-rse +++ b/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"); diff --git a/bin/rucio-admin b/bin/rucio-admin index 5caf3b2796..84fee6bb5c 100755 --- a/bin/rucio-admin +++ b/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"); @@ -25,26 +24,36 @@ import signal import sys import time import traceback -from textwrap import dedent -from functools import wraps - from configparser import NoOptionError, NoSectionError -from tabulate import tabulate +from functools import wraps +from textwrap import dedent 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 +from tabulate import tabulate EXTRA_MODULES = import_extras(['argcomplete']) @@ -1277,7 +1286,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 @@ -1309,7 +1318,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 diff --git a/bin/rucio-atropos b/bin/rucio-atropos index f70abd412a..0e6b17f8f7 100755 --- a/bin/rucio-atropos +++ b/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"); diff --git a/bin/rucio-auditor b/bin/rucio-auditor index 5324684f8c..25ab4adc70 100755 --- a/bin/rucio-auditor +++ b/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"); @@ -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 diff --git a/bin/rucio-automatix b/bin/rucio-automatix index 31285a96cd..a07d0d3a86 100755 --- a/bin/rucio-automatix +++ b/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"); diff --git a/bin/rucio-bb8 b/bin/rucio-bb8 index ee05c57246..aaef1c1655 100755 --- a/bin/rucio-bb8 +++ b/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"); diff --git a/bin/rucio-c3po b/bin/rucio-c3po index b2e28715bc..8f1480dd30 100755 --- a/bin/rucio-c3po +++ b/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"); diff --git a/bin/rucio-cache-client b/bin/rucio-cache-client index 3e740eecd5..39004e2a81 100755 --- a/bin/rucio-cache-client +++ b/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"); @@ -27,7 +26,6 @@ import sys import stomp from jsonschema import validate - from rucio.client.didclient import DIDClient from rucio.client.rseclient import RSEClient from rucio.common.config import config_get, config_get_int diff --git a/bin/rucio-cache-consumer b/bin/rucio-cache-consumer index 7fc5ab40e9..2f51c1a3a4 100755 --- a/bin/rucio-cache-consumer +++ b/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"); diff --git a/bin/rucio-conveyor-finisher b/bin/rucio-conveyor-finisher index 39ee47c642..f46a6a1d14 100755 --- a/bin/rucio-conveyor-finisher +++ b/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"); diff --git a/bin/rucio-conveyor-poller b/bin/rucio-conveyor-poller index 0e7535ddb0..eea03a76f1 100755 --- a/bin/rucio-conveyor-poller +++ b/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"); diff --git a/bin/rucio-conveyor-preparer b/bin/rucio-conveyor-preparer index 5964d904d9..9a6ad8b575 100755 --- a/bin/rucio-conveyor-preparer +++ b/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"); diff --git a/bin/rucio-conveyor-receiver b/bin/rucio-conveyor-receiver index 0109d2ed34..01a9473c4f 100755 --- a/bin/rucio-conveyor-receiver +++ b/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"); diff --git a/bin/rucio-conveyor-stager b/bin/rucio-conveyor-stager index 27db42498a..a379d9fee0 100755 --- a/bin/rucio-conveyor-stager +++ b/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"); diff --git a/bin/rucio-conveyor-submitter b/bin/rucio-conveyor-submitter index 18831373ff..aacb1fe34c 100755 --- a/bin/rucio-conveyor-submitter +++ b/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"); diff --git a/bin/rucio-conveyor-throttler b/bin/rucio-conveyor-throttler index 56277abab7..333dc35be6 100755 --- a/bin/rucio-conveyor-throttler +++ b/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"); diff --git a/bin/rucio-dark-reaper b/bin/rucio-dark-reaper index eb347bfb88..a4da2e1c6a 100755 --- a/bin/rucio-dark-reaper +++ b/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"); diff --git a/bin/rucio-dumper b/bin/rucio-dumper index f8170de839..c0654dd9e7 100755 --- a/bin/rucio-dumper +++ b/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"); @@ -18,11 +17,10 @@ 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 - +import tabulate from rucio.common.dumper import error logger = logging.getLogger('rucio-dumper') @@ -130,7 +128,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]) @@ -139,12 +137,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] diff --git a/bin/rucio-follower b/bin/rucio-follower index 6a3b066878..93f70bd448 100755 --- a/bin/rucio-follower +++ b/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"); diff --git a/bin/rucio-hermes b/bin/rucio-hermes index 4ae4c01fd2..ff885aebac 100755 --- a/bin/rucio-hermes +++ b/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"); diff --git a/bin/rucio-judge-cleaner b/bin/rucio-judge-cleaner index 4f6b03c7fd..52a1422bb1 100755 --- a/bin/rucio-judge-cleaner +++ b/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"); diff --git a/bin/rucio-judge-evaluator b/bin/rucio-judge-evaluator index ef7b954602..fc743b9297 100755 --- a/bin/rucio-judge-evaluator +++ b/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"); diff --git a/bin/rucio-judge-injector b/bin/rucio-judge-injector index d62c97de66..89193772ae 100755 --- a/bin/rucio-judge-injector +++ b/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"); diff --git a/bin/rucio-judge-repairer b/bin/rucio-judge-repairer index 8eeef90730..4fa8bbd15e 100755 --- a/bin/rucio-judge-repairer +++ b/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"); diff --git a/bin/rucio-kronos b/bin/rucio-kronos index c082a74650..3dad3fa310 100755 --- a/bin/rucio-kronos +++ b/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"); diff --git a/bin/rucio-minos b/bin/rucio-minos index 21dc385f3d..ee5fbcd2eb 100755 --- a/bin/rucio-minos +++ b/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"); diff --git a/bin/rucio-minos-temporary-expiration b/bin/rucio-minos-temporary-expiration index 653b8fb06c..1b7222c5df 100755 --- a/bin/rucio-minos-temporary-expiration +++ b/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"); diff --git a/bin/rucio-necromancer b/bin/rucio-necromancer index 19a01cf0ec..19c6bc3f85 100755 --- a/bin/rucio-necromancer +++ b/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"); diff --git a/bin/rucio-oauth-manager b/bin/rucio-oauth-manager index d4e16e705c..42ac018cca 100755 --- a/bin/rucio-oauth-manager +++ b/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"); diff --git a/bin/rucio-reaper b/bin/rucio-reaper index 711fa836e2..ca54c3c2f9 100755 --- a/bin/rucio-reaper +++ b/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"); diff --git a/bin/rucio-replica-recoverer b/bin/rucio-replica-recoverer index 05fe7d9802..8112408946 100755 --- a/bin/rucio-replica-recoverer +++ b/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"); diff --git a/bin/rucio-rse-decommissioner b/bin/rucio-rse-decommissioner index 31945eb44b..4a027bfe54 100755 --- a/bin/rucio-rse-decommissioner +++ b/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"); diff --git a/bin/rucio-storage-consistency-actions b/bin/rucio-storage-consistency-actions index ec8eda4fdc..05b5d701bb 100755 --- a/bin/rucio-storage-consistency-actions +++ b/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"); diff --git a/bin/rucio-transmogrifier b/bin/rucio-transmogrifier index f38d02f161..9e6d41b618 100755 --- a/bin/rucio-transmogrifier +++ b/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"); diff --git a/bin/rucio-undertaker b/bin/rucio-undertaker index 15003ff85e..768acc6613 100755 --- a/bin/rucio-undertaker +++ b/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"); diff --git a/pyproject.toml b/pyproject.toml index 3d7069bd4e..7a3aea538e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,10 @@ build-backend = "setuptools.build_meta" [tool.ruff] line-length = 256 +extend-include = [ + "bin/*", +] + # Exclude a variety of commonly ignored directories. exclude = [ ".bzr", @@ -50,7 +54,5 @@ ignore = [ "UP030", # Use implicit references for positional format fields "UP031", # Use format specifiers instead of percent format "UP032", # Use f-string instead of `format` call - "SIM210", + "SIM210", ] - -extend-safe-fixes = ["I001"] diff --git a/tools/generate-release-notes b/tools/generate-release-notes index e2cdd3b77a..6f853bb4fb 100755 --- a/tools/generate-release-notes +++ b/tools/generate-release-notes @@ -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"); @@ -14,10 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import subprocess import sys + import requests -import json if __name__ == "__main__": requests.packages.urllib3.disable_warnings()