Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion mig/server/checkcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Check warning on line 23 in mig/server/checkcloud.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 23 in mig/server/checkcloud.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# -- END_HEADER ---
#
Expand All @@ -31,7 +31,6 @@
from __future__ import absolute_import

import getopt
import pickle
import sys

from mig.shared.defaults import keyword_all
Expand Down
1 change: 0 additions & 1 deletion mig/server/checktwofactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Check warning on line 23 in mig/server/checktwofactor.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 23 in mig/server/checktwofactor.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# -- END_HEADER ---
#
Expand All @@ -31,7 +31,6 @@
from __future__ import absolute_import

import getopt
import pickle
import sys

from mig.shared.defaults import keyword_auto
Expand Down
1 change: 0 additions & 1 deletion mig/server/createuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Check warning on line 23 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 23 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# -- END_HEADER ---
#
Expand All @@ -36,10 +36,9 @@
import getopt
import os
import sys
import time

from mig.shared.accountstate import default_account_expire
from mig.shared.base import fill_distinguished_name, fill_user, canonical_user, \

Check warning on line 41 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 41 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
force_native_str_rec
from mig.shared.conf import get_configuration_object
from mig.shared.defaults import valid_auth_types, keyword_auto
Expand Down Expand Up @@ -217,7 +216,7 @@

raw_user = {}
if args:
#logger.debug('createuser called with args: %s' % args)

Check warning on line 219 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

block comment should start with '# '

Check warning on line 219 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

block comment should start with '# '
# logger.debug('createuser using default %s and fs %s encoding' %
# (sys.getdefaultencoding(), sys.getfilesystemencoding()))
try:
Expand Down Expand Up @@ -246,7 +245,7 @@
usage()
sys.exit(1)
elif default_renew and user_id:
#logger.debug('createuser called with user_id: %s' % [user_id])

Check warning on line 248 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

block comment should start with '# '

Check warning on line 248 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

block comment should start with '# '
saved = load_user_dict(logger, user_id, db_path, verbose)
if not saved:
print('Error: no such user in user db: %s' % user_id)
Expand Down Expand Up @@ -294,7 +293,7 @@
elif 'distinguished_name' not in user_dict:
fill_distinguished_name(user_dict)

#logger.debug('createuser with ID: %s' % [user_dict['distinguished_name']])

Check warning on line 296 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

block comment should start with '# '

Check warning on line 296 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

block comment should start with '# '
fill_user(user_dict)

force_native_str_rec(user_dict)
Expand All @@ -321,7 +320,7 @@
if configuration.site_enable_gdp:
(success_here, msg) = ensure_gdp_user(configuration,
"127.0.0.1",
user_dict['distinguished_name'])

Check warning on line 323 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)

Check warning on line 323 in mig/server/createuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
if not success_here:
raise Exception("Failed to ensure GDP user: %s" % msg)

Expand Down
5 changes: 1 addition & 4 deletions mig/server/importusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Check warning on line 23 in mig/server/importusers.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 23 in mig/server/importusers.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# -- END_HEADER ---
#
Expand All @@ -35,7 +35,6 @@
import re
import ssl
import sys
import time

from mig.shared import returnvalues
from mig.shared.accountstate import default_account_expire
Expand All @@ -46,9 +45,7 @@
from mig.shared.functionality.sendrequestaction import main
from mig.shared.handlers import get_csrf_limit, make_csrf_token
from mig.shared.output import format_output
from mig.shared.pwcrypto import generate_random_password, unscramble_password, \
scramble_password
from mig.shared.safeinput import valid_password_chars
from mig.shared.pwcrypto import generate_random_password, scramble_password
from mig.shared.url import urlopen
from mig.shared.useradm import init_user_adm, default_search, create_user, \
search_users
Expand Down Expand Up @@ -107,7 +104,7 @@

users = []
for user_creds in re.findall('/[a-zA-Z]+=[^<\n]+', user_data):
#print "DEBUG: handling user %s" % user_creds

Check warning on line 107 in mig/server/importusers.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

block comment should start with '# '

Check warning on line 107 in mig/server/importusers.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

block comment should start with '# '
user_dict = distinguished_name_to_user(user_creds.strip())
users.append(user_dict)
return users
Expand Down
5 changes: 2 additions & 3 deletions mig/server/managecloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from __future__ import absolute_import

import getopt
import pickle
import sys

from mig.shared.defaults import keyword_all
Expand Down Expand Up @@ -105,7 +104,7 @@ def usage(name='managecloud.py'):
action_map = {'start': start_cloud_instance, 'stop': stop_cloud_instance,
'restart': restart_cloud_instance,
'status': status_of_cloud_instance}
if not action in action_map:
if action not in action_map:
print('Error: action must be one of %s' % action_map.keys())
usage()
sys.exit(1)
Expand Down Expand Up @@ -142,7 +141,7 @@ def usage(name='managecloud.py'):
list(saved_instances), instance_fields)
action_helper = action_map[action]
for (instance_id, instance_dict) in saved_instances.items():
if not instance_id in instance_list:
if instance_id not in instance_list:
continue
instance_label = instance_dict.get('INSTANCE_LABEL',
instance_id)
Expand Down
4 changes: 2 additions & 2 deletions mig/server/notifyexpire.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def usage(name='notifyexpire.py'):

# Don't warn about already disabled or suspended accounts
account_state = user_dict.get('status', 'active')
if not account_state in ('active', 'temporal'):
if account_state not in ('active', 'temporal'):
if verbose:
print('Skip handling of already %s user %s' % (account_state,
user_id))
Expand Down Expand Up @@ -322,7 +322,7 @@ def usage(name='notifyexpire.py'):
(cloud_title, instance_id, user_id))
continue
else:
if not 'cloud' in affected:
if 'cloud' not in affected:
affected.append('cloud')

(_, username, full_name, addresses, errors) = user_account_notify(
Expand Down
7 changes: 3 additions & 4 deletions mig/server/reqacceptpeer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@
import sys

from mig.shared.accountreq import peers_permit_allowed, manage_pending_peers
from mig.shared.base import fill_distinguished_name, client_id_dir
from mig.shared.base import fill_distinguished_name
from mig.shared.conf import get_configuration_object
from mig.shared.defaults import keyword_auto, gdp_distinguished_field, \
pending_peers_filename
from mig.shared.defaults import keyword_auto, gdp_distinguished_field
from mig.shared.notification import notify_user
from mig.shared.serial import load, dump
from mig.shared.serial import load
from mig.shared.useradm import init_user_adm, search_users, default_search, \
user_account_notify
from mig.shared.validstring import valid_email_addresses
Expand Down
6 changes: 3 additions & 3 deletions mig/server/reset2fakey.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def enable2fa(configuration, user_id, verbose, force=False):

try:
os.remove(tmptopicfile)
except Exception as exc:
except Exception:
pass # probably deleted by parser!

return parse_status
Expand Down Expand Up @@ -251,7 +251,7 @@ def usage(name='reset2fakey.py'):
print("Detected HEX seed, re-encoding to base32")
try:
seed = base64.b32encode(base64.b16decode(seed))
except Exception as exc:
except Exception:
print("Failed to base32 encode seed")
if not force:
sys.exit(1)
Expand All @@ -263,7 +263,7 @@ def usage(name='reset2fakey.py'):
if interval:
try:
interval = int(interval)
except:
except Exception:
print("Skipping non-int interval: %s" % interval)
interval = None

Expand Down
1 change: 0 additions & 1 deletion mig/server/resetcaches.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import sys


from mig.shared.base import client_id_dir
from mig.shared.conf import get_configuration_object
from mig.shared.fileio import delete_file
from mig.shared.vgridaccess import refresh_vgrid_map, refresh_user_map, \
Expand Down
1 change: 0 additions & 1 deletion mig/server/searchusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from past.builtins import basestring
import getopt
import sys
import time

from mig.shared.useradm import init_user_adm, search_users, default_search

Expand Down
4 changes: 2 additions & 2 deletions mig/server/sftpfailinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ def dns_lookup(ip_addr):
match = extract_regex.match(line)
if match:
stamp, source_ip, source_port, err_cond = match.group(1, 2, 3, 4)
if not source_ip in ip_fail_map:
if source_ip not in ip_fail_map:
ip_fail_map[source_ip] = {'source_ip': source_ip}
if not err_cond in ip_fail_map[source_ip]:
if err_cond not in ip_fail_map[source_ip]:
ip_fail_map[source_ip][err_cond] = 0
ip_fail_map[source_ip][err_cond] += 1
ip_fail_map[source_ip]['last'] = stamp
Expand Down
6 changes: 2 additions & 4 deletions mig/server/usagestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@
import sys
import time

from mig.shared.base import extract_field
from mig.shared.defaults import freeze_meta_filename, keyword_auto
from mig.shared.fileio import unpickle, walk
from mig.shared.notification import send_email
from mig.shared.fileio import walk
from mig.shared.safeeval import subprocess_popen, subprocess_pipe
from mig.shared.serial import dump
from mig.shared.useradm import init_user_adm, search_users, default_search
Expand Down Expand Up @@ -305,10 +303,10 @@
text=True, env=cmd_env)
proc.wait()
for line in proc.stdout.readlines():
site_stats['disk']['use'].append(line.strip().split())

Check failure on line 306 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

Check failure on line 306 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]
if verbose:
print("=== Disk Use ===")
print('\n'.join(['\t'.join(i) for i in site_stats['disk']['use']]))

Check failure on line 309 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

Check failure on line 309 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

# NOTE: mount expects multiple file system types as single comma-sep arg
mount_opts = []
Expand All @@ -318,10 +316,10 @@
text=True)
proc.wait()
for line in proc.stdout.readlines():
site_stats['disk']['mounts'].append(line.strip().split())

Check failure on line 319 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

Check failure on line 319 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]
if verbose:
print("=== Disk Mounts ===")
print('\n'.join(['\t'.join(i) for i in site_stats['disk']['mounts']]))

Check failure on line 322 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

Check failure on line 322 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]
print("""Where
* vgrid_files_home is all vgrid shared folders
* vgrid_private_base/vgrid_public_base are all vgrid web portals
Expand All @@ -332,11 +330,11 @@
all_uids = [uid for (uid, user_dict) in all_hits]
# all_uids.sort()
# print("DEBUG: %s" % all_uids)
site_stats['totals']['all_users'] = len(all_uids)

Check failure on line 333 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Unsupported target for indexed assignment ("object") [index]

Check failure on line 333 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Unsupported target for indexed assignment ("object") [index]
if verbose:
print("== Totals ==")
print("=== Registered Local Users ===")
print(site_stats['totals']['all_users'])

Check failure on line 337 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

Check failure on line 337 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

search_filter['expire_after'] = now
(_, active_hits) = search_users(search_filter, conf_path, db_path)
Expand All @@ -348,11 +346,11 @@
# print(uid)
active_uids = [uid for (uid, user_dict) in active_hits]
# active_uids.sort()
site_stats['totals']['active_users'] = len(active_uids)

Check failure on line 349 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Unsupported target for indexed assignment ("object") [index]

Check failure on line 349 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Unsupported target for indexed assignment ("object") [index]
# print("DEBUG: %s" % active_uids)
if verbose:
print("=== Active Local Users ===")
print(site_stats['totals']['active_users'])

Check failure on line 353 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

Check failure on line 353 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

# Extract dirs recursively in root of vgrid_home
for (root, dirs, files) in walk(configuration.vgrid_home):
Expand All @@ -362,7 +360,7 @@
if not dirs:
continue
# print("DEBUG: %s %s" % (root, dirs))
site_stats['totals']['vgrids'] += len(dirs)

Check failure on line 363 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Unsupported target for indexed assignment ("object") [index]

Check failure on line 363 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]

Check failure on line 363 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Unsupported target for indexed assignment ("object") [index]

Check failure on line 363 in mig/server/usagestats.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Value of type "object" is not indexable [index]
if verbose:
print("=== Registered VGrids ===")
print(site_stats['totals']['vgrids'])
Expand Down Expand Up @@ -454,7 +452,7 @@
dirs.remove(i)
continue
if sub_parts[-1].find('archive-') == -1 or \
not freeze_meta_filename in files:
freeze_meta_filename not in files:
continue
meta_path = os.path.join(root, freeze_meta_filename)
meta_mtime = os.path.getmtime(meta_path)
Expand Down
2 changes: 1 addition & 1 deletion mig/server/verifyarchives.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def check_archive_integrity(configuration, user_id, freeze_path,
# NOTE: if archive has no actual files it has no cache file either
if not os.path.exists(cache_path):
archive_list = os.listdir(freeze_path)
if [i for i in archive_list if not i in ignore_files]:
if [i for i in archive_list if i not in ignore_files]:
print("Archive %s has data content but no file cache in %s" %
(freeze_path, cache_path))
return False
Expand Down
Loading