Skip to content

Commit

Permalink
Testing: Extend linter to Python files without extension (e.g. bin/) …
Browse files Browse the repository at this point in the history
…and lint them; rucio#6538
  • Loading branch information
rdimaio committed Mar 18, 2024
1 parent 9643194 commit 93b341f
Show file tree
Hide file tree
Showing 40 changed files with 61 additions and 77 deletions.
37 changes: 24 additions & 13 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,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'])

Expand Down Expand Up @@ -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

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
41 changes: 25 additions & 16 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,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'])

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
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
2 changes: 0 additions & 2 deletions 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 Expand Up @@ -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
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
10 changes: 4 additions & 6 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,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')
Expand Down Expand Up @@ -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])
Expand All @@ -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]

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

0 comments on commit 93b341f

Please sign in to comment.