Skip to content

Commit 1e6c09f

Browse files
committed
Enforce formatting across the first batch of FHSeqsue directories.
1 parent 6e34732 commit 1e6c09f

112 files changed

Lines changed: 13994 additions & 10033 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ ifndef PY
66
PY = 3
77
endif
88

9-
FORMAT_ENFORCE_DIRS = state/
10-
FORMAT_EXCLUDE_REGEX = '.*'
11-
FORMAT_EXCLUDE_GLOB = '*'
9+
FORMAT_ENFORCE_DIRS = ./bin ./mig/lib ./sbin ./tests
10+
FORMAT_EXCLUDE_REGEX = '.git|tests/data/|tests/fixture/'
11+
FORMAT_EXCLUDE_GLOB = '.git/* tests/data/* tests/fixture/*'
1212
FORMAT_LINE_LENGTH = 80
13-
1413
LOCAL_PYTHON_BIN = './envhelp/lpython'
1514

1615
ifdef PYTHON_BIN

bin/addheader.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,11 @@ def add_header(path, var_dict, explicit_border=True, block_wrap=False):
159159
END_MARKER,
160160
)
161161
if block_wrap:
162-
lic = (
163-
"""
162+
lic = """
164163
/*
165164
%s
166165
*/
167-
"""
168-
% lic
169-
)
166+
""" % lic
170167

171168
module_header.append(lic)
172169
# Make sure there's a blank line between license header and code

bin/showaccounting.py

Lines changed: 68 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from mig.shared.defaults import gdp_distinguished_field
4040

4141

42-
def usage(name='showaccounting.py'):
42+
def usage(name="showaccounting.py"):
4343
"""Usage help"""
4444

4545
print("""Create accounting information based on quota.
@@ -53,33 +53,31 @@ def usage(name='showaccounting.py'):
5353
-m Minimum usage Only show accounts using more than
5454
minimum usage (TB).
5555
-t TIMESTAMP Use specific timestamp, latest if unset
56-
""" % {'name': name})
56+
""" % {"name": name})
5757

5858

59-
def show_accounting(configuration,
60-
timestamp,
61-
user_filter,
62-
minimum_usage,
63-
verbose):
59+
def show_accounting(
60+
configuration, timestamp, user_filter, minimum_usage, verbose
61+
):
6462
"""Print user accounting report"""
6563
user_filter_re = None
6664
if user_filter:
6765
try:
6866
user_filter_re = re.compile(user_filter)
6967
except Exception as err:
70-
print("ERROR: Failed to compile user_filter: %r error: %s"
71-
% (user_filter, err))
68+
print(
69+
"ERROR: Failed to compile user_filter: %r error: %s"
70+
% (user_filter, err)
71+
)
7272
return
7373

74-
usage = get_usage(configuration,
75-
timestamp=timestamp,
76-
verbose=verbose)
74+
usage = get_usage(configuration, timestamp=timestamp, verbose=verbose)
7775

78-
accounting = usage.get('accounting', {})
79-
accounting_timestamp = usage.get('timestamp', 0)
80-
accounting_datestr \
81-
= datetime.datetime.fromtimestamp(accounting_timestamp) \
82-
.strftime('%d/%m/%Y-%H:%M:%S')
76+
accounting = usage.get("accounting", {})
77+
accounting_timestamp = usage.get("timestamp", 0)
78+
accounting_datestr = datetime.datetime.fromtimestamp(
79+
accounting_timestamp
80+
).strftime("%d/%m/%Y-%H:%M:%S")
8381

8482
# Sorted by total bytes and print usage for users
8583

@@ -91,14 +89,19 @@ def show_accounting(configuration,
9189
for username, values in accounting.items():
9290
# Do not show GDP project users
9391
# projects are accounted for by the main user
94-
if configuration.site_enable_gdp \
95-
and username.find("/%s=" % gdp_distinguished_field) != -1:
92+
if (
93+
configuration.site_enable_gdp
94+
and username.find("/%s=" % gdp_distinguished_field) != -1
95+
):
9696
continue
9797
report_total_users += 1
98-
total_bytes = values.get('total_bytes', 0)
98+
total_bytes = values.get("total_bytes", 0)
9999
report_total_bytes += total_bytes
100-
if total_bytes < minimum_usage \
101-
or user_filter_re and not user_filter_re.fullmatch(username):
100+
if (
101+
total_bytes < minimum_usage
102+
or user_filter_re
103+
and not user_filter_re.fullmatch(username)
104+
):
102105
continue
103106
report_shown_users += 1
104107
report_shown_bytes += total_bytes
@@ -107,33 +110,36 @@ def show_accounting(configuration,
107110
total_bytes_map[total_bytes] = total_bytes_map_userlist
108111
sorted_total_bytes = sorted(list(total_bytes_map), reverse=True)
109112

110-
print("\nAccounting (%d) %s for storage quota(s):"
111-
% (accounting_timestamp, accounting_datestr))
112-
for quota_fs, values in usage.get('quota', {}).items():
113-
quota_mtime = values.get('mtime', 0)
114-
quota_datestr = datetime.datetime.fromtimestamp(quota_mtime) \
115-
.strftime('%d/%m/%Y-%H:%M:%S')
116-
print(" - %s (%d) %s" % (quota_fs,
117-
quota_mtime,
118-
quota_datestr))
119-
120-
print("Found a total of %s users using %s storage"
121-
% (report_total_users,
122-
human_readable_filesize(report_total_bytes)))
123-
print("Showing details for %s users using %s storage "
124-
% (report_shown_users,
125-
human_readable_filesize(report_shown_bytes)))
113+
print(
114+
"\nAccounting (%d) %s for storage quota(s):"
115+
% (accounting_timestamp, accounting_datestr)
116+
)
117+
for quota_fs, values in usage.get("quota", {}).items():
118+
quota_mtime = values.get("mtime", 0)
119+
quota_datestr = datetime.datetime.fromtimestamp(quota_mtime).strftime(
120+
"%d/%m/%Y-%H:%M:%S"
121+
)
122+
print(" - %s (%d) %s" % (quota_fs, quota_mtime, quota_datestr))
123+
124+
print(
125+
"Found a total of %s users using %s storage"
126+
% (report_total_users, human_readable_filesize(report_total_bytes))
127+
)
128+
print(
129+
"Showing details for %s users using %s storage "
130+
% (report_shown_users, human_readable_filesize(report_shown_bytes))
131+
)
126132
print("User filter: %r" % user_filter)
127133
print("Minimum usage: %s" % human_readable_filesize(minimum_usage))
128134
for total_bytes in sorted_total_bytes:
129135
total_bytes_human = human_readable_filesize(total_bytes)
130136
for username in total_bytes_map[total_bytes]:
131137
report = accounting[username]
132-
home_report = report.get('home_report', '')
133-
freeze_report = report.get('freeze_report', '')
134-
vgrid_report = report.get('vgrid_report', '')
135-
ext_users_report = report.get('ext_users_report', '')
136-
peers_report = report.get('peers_report', '')
138+
home_report = report.get("home_report", "")
139+
freeze_report = report.get("freeze_report", "")
140+
vgrid_report = report.get("vgrid_report", "")
141+
ext_users_report = report.get("ext_users_report", "")
142+
peers_report = report.get("peers_report", "")
137143
print("\n%s:" % username)
138144
print("Total usage: %s" % total_bytes_human)
139145
if home_report:
@@ -148,46 +154,44 @@ def show_accounting(configuration,
148154
print(peers_report)
149155

150156

151-
if '__main__' == __name__:
157+
if "__main__" == __name__:
152158
conf_path = None
153159
user_filter = None
154160
timestamp = 0
155161
minimum_usage = 0
156162
verbose = False
157-
opt_args = 'hvc:f:m:t:'
163+
opt_args = "hvc:f:m:t:"
158164
try:
159-
(opts, args) = getopt.getopt(sys.argv[1:], opt_args)
160-
for (opt, val) in opts:
161-
if opt == '-h':
165+
opts, args = getopt.getopt(sys.argv[1:], opt_args)
166+
for opt, val in opts:
167+
if opt == "-h":
162168
usage()
163169
sys.exit(0)
164-
if opt == '-v':
170+
if opt == "-v":
165171
verbose = True
166-
elif opt == '-c':
172+
elif opt == "-c":
167173
conf_path = val
168-
elif opt == '-f':
174+
elif opt == "-f":
169175
user_filter = val
170-
elif opt == '-m':
171-
minimum_usage = float(val)*(1024**4)
172-
elif opt == '-t':
176+
elif opt == "-m":
177+
minimum_usage = float(val) * (1024**4)
178+
elif opt == "-t":
173179
timestamp = int(val)
174180
else:
175-
print('Error: %s not supported!' % opt)
181+
print("Error: %s not supported!" % opt)
176182
usage()
177183
sys.exit(1)
178184
except getopt.GetoptError as err:
179-
print('Error: ', err.msg)
185+
print("Error: ", err.msg)
180186
usage()
181187
sys.exit(1)
182188

183-
configuration = get_configuration_object(config_file=conf_path,
184-
skip_log=True,
185-
disable_auth_log=True)
189+
configuration = get_configuration_object(
190+
config_file=conf_path, skip_log=True, disable_auth_log=True
191+
)
186192

187-
show_accounting(configuration,
188-
timestamp,
189-
user_filter,
190-
minimum_usage,
191-
verbose)
193+
show_accounting(
194+
configuration, timestamp, user_filter, minimum_usage, verbose
195+
)
192196

193197
sys.exit(0)

bin/verifyvgridformat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ def usage(name=sys.argv[0]):
4949
-v|--verbose Verbose output
5050
-c PATH|--config=PATH Path to config file
5151
-n NAME|--name=NAME Only verify specific vgrid
52-
"""
53-
% {"name": name},
52+
""" % {"name": name},
5453
file=sys.stderr,
5554
)
5655

@@ -78,7 +77,7 @@ def verify_vgrid_format(configuration, vgrid_name=None, verbose=False):
7877
vgrid_dirpath = os.path.join(root, dirent)
7978
owners_filepath = os.path.join(vgrid_dirpath, "owners")
8079
if os.path.isfile(owners_filepath):
81-
vgrid = vgrid_dirpath[len(configuration.vgrid_home):].strip(
80+
vgrid = vgrid_dirpath[len(configuration.vgrid_home) :].strip(
8281
os.sep
8382
)
8483
vgrid_mapping[vgrid] = vgrid_flat_name(vgrid, configuration)

0 commit comments

Comments
 (0)