Merge pull request #2704 from coolo/remove_bare_excepts

Remove bare excepts - https://www.flake8rules.com/rules/E722.html
This commit is contained in:
Stephan Kulow 2022-02-18 12:50:05 +01:00 committed by GitHub
commit c1a66f9997
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 8 additions and 107 deletions

View File

@ -1,4 +1,4 @@
[flake8] [flake8]
exclude = abichecker exclude = abichecker
max-line-length = 100 max-line-length = 100
ignore = E501,F401,E128,E251,E201,E202,E302,E305,F841,E261,E712,E126,E711,E125,E123,E101,E124,E127,E701,E714,W504,E129,E741,E722 ignore = E501,F401,E128,E251,E201,E202,E302,E305,F841,E261,E712,E126,E711,E125,E123,E101,E124,E127,E701,E714,W504,E129,E741

View File

@ -342,11 +342,3 @@ directly.
* Package: openSUSE-release-tools * Package: openSUSE-release-tools
* Usage: obsolete * Usage: obsolete
#### k8s-secret.py
Applies kubernetes secrets for OSRT tool osc configuration.
* Sources: [k8s-secret.py](k8s-secret.py)
* Documentation: --
* Package: openSUSE-release-tools
* Usage: obsolete

View File

@ -116,7 +116,7 @@ def main(args):
with open(reminded_json) as json_data: with open(reminded_json) as json_data:
RemindedLoaded = json.load(json_data) RemindedLoaded = json.load(json_data)
json_data.close() json_data.close()
except: except FileNotFoundError:
RemindedLoaded = {} RemindedLoaded = {}
pass pass

View File

@ -432,7 +432,7 @@ class CheckSource(ReviewBot.ReviewBot):
if not f.get('name').endswith('.changes'): if not f.get('name').endswith('.changes'):
return False return False
return True return True
except: except HTTPError:
pass pass
return False return False

View File

@ -1,13 +0,0 @@
#!/usr/bin/python3
try:
from osc import conf
except:
import sys
sys.exit()
apiurl = conf.config['apiurl']
cp = conf.get_configParser()
for key in ('apiurl', 'user', 'pass', 'email'):
print('{}="{}"'.format(key, cp.get(apiurl, key, raw=True)))

19
dist/ci/osc-init vendored
View File

@ -1,19 +0,0 @@
#!/bin/bash
: ${OSCRC:=~/.oscrc}
OBS_API="${OBS_API:-https://api.opensuse.org}"
if [ -z ${OBS_PASS+x} ] || [ -z "$OBS_PASS" ] ; then
OBS_API="$OBS_API/public"
fi
echo "OBS_API=$OBS_API"
echo "OBS_USER=$OBS_USER"
cat << eom > "$OSCRC"
[general]
apiurl = $OBS_API
[$OBS_API]
user = ${OBS_USER:-example}
pass = ${OBS_PASS:-example}
email = ${OBS_EMAIL:-example@example.com}
eom

View File

@ -376,7 +376,6 @@ exit 0
%{_bindir}/osrt-deptool %{_bindir}/osrt-deptool
%{_bindir}/osrt-fcc_submitter %{_bindir}/osrt-fcc_submitter
%{_bindir}/osrt-issue-diff %{_bindir}/osrt-issue-diff
%{_bindir}/osrt-k8s-secret
%{_bindir}/osrt-legal-auto %{_bindir}/osrt-legal-auto
%{_bindir}/osrt-openqa-maintenance %{_bindir}/osrt-openqa-maintenance
%{_bindir}/osrt-requestfinder %{_bindir}/osrt-requestfinder

View File

@ -1,56 +0,0 @@
#!/usr/bin/python3
import argparse
import os
from osclib.cache_manager import CacheManager
import subprocess
import sys
CACHE_DIR = CacheManager.directory('k8s-secret')
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
def secret_create(cache_file):
environment = {'OSCRC': cache_file}
print('Username: ', end='')
environment['OBS_USER'] = input()
print('Password: ', end='')
environment['OBS_PASS'] = input()
osc_init = os.path.join(SCRIPT_PATH, 'dist/ci/osc-init')
subprocess.Popen([osc_init], env=environment).wait()
def secret_apply(prefix, cache_file):
print(subprocess.check_output([
'kubectl', 'create', 'secret', 'generic',
'{}-oscrc'.format(prefix), '--from-file={}={}'.format('.oscrc', cache_file)]))
def main(args):
cache_file = os.path.join(CACHE_DIR, args.prefix)
if not os.path.exists(cache_file) or args.create:
secret_create(cache_file)
with open(cache_file, 'r') as f:
print(f.read())
print('Apply secret for {} [y/n] (y): '.format(args.prefix), end='')
response = input().lower()
if response != '' and response != 'y':
return
secret_apply(args.prefix, cache_file)
if args.delete:
os.remove(cache_file)
if __name__ == '__main__':
description = 'Apply kubernetes secrets for OSRT tool osc configuration.'
parser = argparse.ArgumentParser(description=description)
parser.add_argument('--create', action='store_true', help='create regardless of existing file')
parser.add_argument('--delete', action='store_true', help='delete cached secret after application')
parser.add_argument('prefix', help='prefix for which to create secret (ex. check-source, repo-checker)')
args = parser.parse_args()
sys.exit(main(args))

View File

@ -2,6 +2,7 @@ import osc.core
from osc.core import get_dependson from osc.core import get_dependson
from xml.etree import cElementTree as ET from xml.etree import cElementTree as ET
from osc import cmdln from osc import cmdln
from urllib.error import HTTPError
@cmdln.option('-p', '--project', metavar='PROJECT', dest='project', default='openSUSE:Factory') @cmdln.option('-p', '--project', metavar='PROJECT', dest='project', default='openSUSE:Factory')
@cmdln.option('-r', '--repository', metavar='REPOSITORY', dest='repository', default='standard') @cmdln.option('-r', '--repository', metavar='REPOSITORY', dest='repository', default='standard')
@ -30,7 +31,7 @@ def do_cycle(self, subcmd, opts, *args):
for deps in pkg.findall('pkgdep'): for deps in pkg.findall('pkgdep'):
if deps.text in args: if deps.text in args:
print("\"%s\" -> \"%s\"" % (deps.text, pkgname)) print("\"%s\" -> \"%s\"" % (deps.text, pkgname))
except: except HTTPError:
# Ignore packages that do not exist # Ignore packages that do not exist
print("[color=red]") print("[color=red]")
continue continue

View File

@ -4,10 +4,7 @@ from functools import wraps
import os import os
from osclib.cache_manager import CacheManager from osclib.cache_manager import CacheManager
import shelve import shelve
try: import pickle
import cPickle as pickle
except:
import pickle
# Where the cache files are stored # Where the cache files are stored
CACHEDIR = CacheManager.directory('memoize') CACHEDIR = CacheManager.directory('memoize')

View File

@ -1328,7 +1328,7 @@ class StagingAPI(object):
try: try:
print("tried to trigger rebuild for project '%s' package '%s'" % (prj, pkg)) print("tried to trigger rebuild for project '%s' package '%s'" % (prj, pkg))
http_POST(u) http_POST(u)
except: except HTTPError:
print("could not trigger rebuild for project '%s' package '%s'" % (prj, pkg)) print("could not trigger rebuild for project '%s' package '%s'" % (prj, pkg))
def _candidate_adi_project(self): def _candidate_adi_project(self):

View File

@ -574,7 +574,7 @@ class StagingWorkflow(ABC):
return return
try: try:
self.remove() self.remove()
except: except Exception:
# normally exceptions in destructors are ignored but a info # normally exceptions in destructors are ignored but a info
# message is displayed. Make this a little more useful by # message is displayed. Make this a little more useful by
# printing it into the capture log # printing it into the capture log