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

Add/update headers for all active files, add pre-commit #142

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
- repo: local
hooks:
- id: add-header
name: Run `add_header` script
description: Run the `add_header` script to verify the file headers
entry: ./add_header.sh
language: system
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
hooks:
- id: ruff
args: [ --fix ]
4 changes: 4 additions & 0 deletions add_header.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

curl 'https://raw.githubusercontent.com/rucio/rucio/master/tools/add_header' > add_header
python3 add_header $(find atlas/* -type f ) $(find cms/* -type f ) $(find common/* -type f -maxdepth 2)
27 changes: 16 additions & 11 deletions atlas/check_ami
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
#!/usr/bin/env python
'''
Copyright European Organization for Nuclear Research (CERN) 2013

Licensed under the Apache License, Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Authors:
- Vincent Garonne, <[email protected]>, 2015
- Cedric Serfon, <[email protected]>, 2018
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


'''
Probe to check datatype, project and convention from AMI
'''

import sys
import traceback

from rucio.db.sqla.session import get_session
from rucio.core.scope import add_scope
from rucio.db.sqla.session import get_session

# Exit statuses
OK, WARNING, CRITICAL, UNKNOWN = 0, 1, 2, 3
Expand Down
18 changes: 11 additions & 7 deletions atlas/check_disabled_rses
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
#!/usr/bin/env python
# Copyright European Organization for Nuclear Research (CERN)
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Authors:
# - Cedric Serfon, <[email protected]>, 2015-2016
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import requests
import sys
import traceback

import requests

from rucio.client import Client
from rucio.common.config import config_get
from rucio.common.exception import RSENotFound


UNKNOWN = 3
CRITICAL = 2
WARNING = 1
Expand Down
2 changes: 0 additions & 2 deletions atlas/check_injecting_rules
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ from rucio.db.sqla import models
from rucio.db.sqla.constants import RuleState
from rucio.db.sqla.session import get_session

from utils import probe_metrics

# Exit statuses
OK, WARNING, CRITICAL, UNKNOWN = 0, 1, 2, 3

Expand Down
34 changes: 19 additions & 15 deletions atlas/check_lost_files
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
#!/usr/bin/env python
# Copyright European Organization for Nuclear Research (CERN) 2015
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# Authors:
# - Tomas Javurek, Cedric Serfon, 2015
# - Alexander Bogdanchikov, 2019-2020
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import calendar
import mimetypes # to guess mimetype
import os
import sys
import smtplib
import sys
import time
import requests
import calendar
# from rucio.common.config import config_get
from datetime import date, datetime
from email import Encoders
from email.mime.text import MIMEText
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email import Encoders
import mimetypes # to guess mimetype
# from rucio.common.config import config_get
from datetime import datetime
from datetime import date
from email.MIMEMultipart import MIMEMultipart

# pandas to prepare statistics RSE:scope:count, may be used to re-implement all the script
import pandas as pd
import requests

from rucio.db.sqla.session import get_session

Expand Down
31 changes: 15 additions & 16 deletions atlas/check_map_voms_roles
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#!/usr/bin/env python
"""
Copyright European Organization for Nuclear Research (CERN)

Licensed under the Apache License, Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0

Authors:
- Cedric Serfon, <[email protected]>, 2014, 2017
- Joaquin Bogado, <[email protected]>, 2014
- Mario Lassnig, <[email protected]>, 2015
- Dimitrios Christidis, <[email protected]>, 2019-2020
"""
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys

from VOMSAdmin.VOMSCommands import VOMSAdminProxy

from rucio.client import Client
from rucio.common.config import config_get
from rucio.common.exception import Duplicate

from VOMSAdmin.VOMSCommands import VOMSAdminProxy

UNKNOWN = 3
CRITICAL = 2
WARNING = 1
Expand Down
29 changes: 15 additions & 14 deletions atlas/check_quotas
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
#!/usr/bin/env python3
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Copyright European Organization for Nuclear Research (CERN)

# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Authors:
# - David Cameron, <[email protected]>, 2015
# - Vincent Garonne, <[email protected]>, 2015
# - Cedric Serfon, <[email protected]>, 2016-2019
# - Dimitrios Christidis, <[email protected]>, 2021
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# Set quotas for physgroups
# Set quotas for users on their country's localgroupdisk
# Set quotas for all users on scratchdisk

from __future__ import print_function

import json
import sys

import requests

from rucio.api.rse import get_rse, parse_rse_expression, get_rse_usage, list_rse_attributes
from rucio.api.account import list_accounts
from rucio.api.account_limit import set_local_account_limit
from rucio.api.config import get
from rucio.db.sqla.session import get_session
from rucio.api.rse import (get_rse, get_rse_usage, list_rse_attributes,
parse_rse_expression)
from rucio.common.config import config_get
from rucio.common.exception import RucioException, RSENotFound, AccountNotFound

from rucio.common.exception import AccountNotFound, RSENotFound, RucioException
from rucio.db.sqla.session import get_session

UNKNOWN = 3
CRITICAL = 2
Expand Down
21 changes: 6 additions & 15 deletions atlas/check_rse_attributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright 2012-2019 CERN for the benefit of the ATLAS collaboration.
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,15 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Authors:
# - Vincent Garonne <[email protected]>, 2013-2014
# - David Cameron <[email protected]>, 2014-2015,2020
# - Tomas Kouba <[email protected]>, 2014
# - Cedric Serfon <[email protected]>, 2016-2019
# - Dimitrios Christidis <[email protected]>, 2019
# - Mario Lassnig <[email protected]>, 2019
#

# PY3K COMPATIBLE

from __future__ import print_function
Expand All @@ -29,15 +21,14 @@ import json
import sys
import traceback


import requests

from rucio.db.sqla.session import get_session
from rucio.common.exception import RucioException, RSENotFound
from rucio.common.config import config_get
from rucio.core.rse import add_rse_attribute, get_rses_with_attribute, del_rse_attribute, get_rse_usage, get_rse
from rucio.common.exception import RSENotFound, RucioException
from rucio.core.rse import (add_rse_attribute, del_rse_attribute, get_rse,
get_rse_usage, get_rses_with_attribute)
from rucio.core.rse_expression_parser import parse_expression

from rucio.db.sqla.session import get_session

UNKNOWN = 3
CRITICAL = 2
Expand Down
15 changes: 10 additions & 5 deletions atlas/check_rules
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/usr/bin/env python
# Copyright European Organization for Nuclear Research (CERN) 2013
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# Authors:
# - Wen Guan, <[email protected]>, 2014
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

'''
Probe to check rules.
Expand Down
28 changes: 16 additions & 12 deletions atlas/check_set_rse_space_limits
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/usr/bin/env python
"""
Copyright European Organization for Nuclear Research (CERN) 2014

Licensed under the Apache License, Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Authors:
- David Cameron, <[email protected]>, 2014-2016
- Mario Lassnig, <[email protected]>, 2015
- Cedric Serfon, <[email protected]>, 2017
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Sets the minimum free space on RSEs according to the policy, which is set in
the configuration table of Rucio server. A relative and absolute limit are
set for the relevant endpoints, for example:
Expand All @@ -31,8 +34,9 @@

import json
import sys
from urlparse import urlparse

import requests
from urlparse import urlparse

# Try to use server environment (direct database access). If that fails use
# client.
Expand Down
Loading