Skip to content

Commit ca4746e

Browse files
Merge pull request #292 from delphix/projects/merge-upstream/master
Merge remote-tracking branch '6.0/stage' into 'master'
2 parents 1d3bdba + 5a63d1a commit ca4746e

38 files changed

+391
-128
lines changed

.github/scripts/install-libkdumpfile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
sudo apt update
1010
sudo apt install autoconf automake liblzo2-dev libsnappy1v5 libtool pkg-config zlib1g-dev
11-
sudo apt install python3.6-dev python3.7-dev python3.8-dev
11+
sudo apt install python3.8-dev
1212

1313
git clone https://github.com/ptesarik/libkdumpfile.git
1414

.github/workflows/main.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
# Verify the build and installation of SDB.
1010
#
1111
install:
12-
runs-on: ubuntu-18.04
12+
runs-on: ubuntu-20.04
1313
strategy:
1414
matrix:
15-
python-version: [3.6, 3.7, 3.8]
15+
python-version: [3.8]
1616
steps:
1717
- uses: actions/checkout@v2
1818
- uses: actions/setup-python@v1
@@ -31,12 +31,12 @@ jobs:
3131
# the "drgn" from source (there's no package currently available).
3232
#
3333
pylint:
34-
runs-on: ubuntu-18.04
34+
runs-on: ubuntu-20.04
3535
steps:
3636
- uses: actions/checkout@v2
3737
- uses: actions/setup-python@v1
3838
with:
39-
python-version: '3.6'
39+
python-version: '3.8'
4040
- run: ./.github/scripts/install-drgn.sh
4141
- run: python3 -m pip install pylint pytest
4242
- run: pylint -d duplicate-code -d invalid-name sdb
@@ -52,10 +52,12 @@ jobs:
5252
# can open kdump-compressed crash dumps for the integration tests.
5353
#
5454
pytest:
55-
runs-on: ubuntu-18.04
55+
runs-on: ubuntu-20.04
5656
strategy:
5757
matrix:
58-
python-version: [3.6, 3.7, 3.8]
58+
python-version: [3.8]
59+
env:
60+
AWS_DEFAULT_REGION: 'us-west-2'
5961
steps:
6062
- uses: actions/checkout@v2
6163
- uses: actions/setup-python@v1
@@ -73,12 +75,12 @@ jobs:
7375
# Verify "yapf" runs successfully.
7476
#
7577
yapf:
76-
runs-on: ubuntu-18.04
78+
runs-on: ubuntu-20.04
7779
steps:
7880
- uses: actions/checkout@v2
7981
- uses: actions/setup-python@v1
8082
with:
81-
python-version: '3.6'
83+
python-version: '3.8'
8284
- run: python3 -m pip install yapf
8385
- run: yapf --diff --style google --recursive sdb
8486
- run: yapf --diff --style google --recursive tests
@@ -98,12 +100,12 @@ jobs:
98100
# pytest doesn't provide stubs on typeshed.
99101
#
100102
mypy:
101-
runs-on: ubuntu-18.04
103+
runs-on: ubuntu-20.04
102104
steps:
103105
- uses: actions/checkout@v2
104106
- uses: actions/setup-python@v1
105107
with:
106-
python-version: '3.6'
108+
python-version: '3.8'
107109
- run: ./.github/scripts/install-drgn.sh
108110
- run: python3 -m pip install mypy==0.730
109111
- run: python3 -m mypy --strict --show-error-codes -p sdb
@@ -112,7 +114,7 @@ jobs:
112114
# Verify that "shfmt" ran successfully against our shell scripts.
113115
#
114116
shfmt:
115-
runs-on: ubuntu-18.04
117+
runs-on: ubuntu-20.04
116118
steps:
117119
- uses: actions/checkout@v2
118120
- uses: delphix/actions/shfmt@master

sdb/command.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from sdb.target import type_canonicalize_name, type_canonical_name, type_canonicalize, get_prog
3232
from sdb.error import CommandError, SymbolNotFoundError
33-
import sdb.target as target
33+
from sdb import target
3434

3535
#
3636
# The register_command is used by the Command class when its
@@ -45,17 +45,13 @@ def register_command(name: str, class_: Type["Command"]) -> None:
4545
Register the specified command name and command class, such that the
4646
command will be available from the SDB REPL.
4747
"""
48-
# pylint: disable=global-statement
49-
global all_commands
5048
all_commands[name] = class_
5149

5250

5351
def get_registered_commands() -> Dict[str, Type["Command"]]:
5452
"""
5553
Return a dictionary of command names to command classes.
5654
"""
57-
# pylint: disable=global-statement
58-
global all_commands
5955
return all_commands
6056

6157

@@ -108,11 +104,12 @@ def help(cls, name: str) -> None:
108104
#
109105
if i == 0:
110106
line = line.replace('usage: ', '')
111-
print(" {}".format(line))
107+
print(f" {line}")
112108

113109
if len(cls.names) > 1:
110+
aliases = ", ".join(cls.names)
114111
print("ALIASES")
115-
print(" {}".format(", ".join(cls.names)))
112+
print(f" {aliases}")
116113
print()
117114

118115
indent = " "
@@ -168,7 +165,7 @@ def help(cls, name: str) -> None:
168165
f" case it will consume no objects as input; instead it"
169166
f" will locate all objects of type '{cls.output_type}',"
170167
f" and emit them as output.")
171-
types = list()
168+
types = []
172169
for (_, method) in inspect.getmembers(cls, inspect.isroutine):
173170
if hasattr(method, "input_typename_handled"):
174171
types.append(method.input_typename_handled)
@@ -203,7 +200,7 @@ def help(cls, name: str) -> None:
203200
#
204201
for line in inspect.getdoc( # type: ignore[union-attr]
205202
cls).splitlines()[2:]:
206-
print("{}".format(line))
203+
print(f"{line}")
207204
print()
208205

209206
#
@@ -588,12 +585,11 @@ class Walk(Command):
588585
def _help_message(input_type: drgn.Type = None) -> str:
589586
msg = ""
590587
if input_type is not None:
591-
msg = msg + "no walker found for input of type {}\n".format(
592-
input_type)
593-
msg = msg + "The following types have walkers:\n"
594-
msg = msg + "\t%-20s %-20s\n" % ("WALKER", "TYPE")
588+
msg += f"no walker found for input of type {input_type}\n"
589+
msg += "The following types have walkers:\n"
590+
msg += f"\t{'WALKER':-20s} {'TYPE':-20s}\n"
595591
for type_, class_ in Walker.allWalkers.items():
596-
msg = msg + "\t%-20s %-20s\n" % (class_.names[0], type_)
592+
msg += f"\t{class_.names[0]:-20s} {type_:-20s}\n"
597593
return msg
598594

599595
def _call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
@@ -645,11 +641,12 @@ def _call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
645641
assert self.input_type is not None
646642
expected_type = type_canonicalize_name(self.input_type)
647643
for obj in objs:
648-
if type_canonical_name(obj.type_) != expected_type:
644+
canonical_type = type_canonical_name(obj.type_)
645+
if canonical_type != expected_type:
649646
raise CommandError(
650647
self.name,
651-
'expected input of type {}, but received {}'.format(
652-
expected_type, type_canonical_name(obj.type_)))
648+
f'expected input of type {expected_type}, but received {canonical_type}'
649+
)
653650

654651
yield from self.walk(obj)
655652

@@ -724,7 +721,7 @@ def caller(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
724721
out_type = None
725722
if self.output_type is not None:
726723
out_type = target.get_type(self.output_type)
727-
baked = dict()
724+
baked = {}
728725
for (_, method) in inspect.getmembers(self, inspect.ismethod):
729726
if not hasattr(method, "input_typename_handled"):
730727
continue
@@ -762,8 +759,8 @@ def caller(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
762759
pass
763760

764761
# error
765-
raise CommandError(
766-
self.name, 'no handler for input of type {}'.format(i.type_))
762+
raise CommandError(self.name,
763+
f'no handler for input of type {i.type_}')
767764

768765
def _call(self,
769766
objs: Iterable[drgn.Object]) -> Optional[Iterable[drgn.Object]]:

sdb/commands/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import importlib
2121
import os
2222

23-
for path in glob.glob("{}/*.py".format(os.path.dirname(__file__))):
23+
for path in glob.glob(f"{os.path.dirname(__file__)}/*.py"):
2424
if path != __file__:
2525
module = os.path.splitext(os.path.basename(path))[0]
26-
importlib.import_module("sdb.commands.{}".format(module))
26+
importlib.import_module(f"sdb.commands.{module}")
2727

28-
for path in glob.glob("{}/*/__init__.py".format(os.path.dirname(__file__))):
28+
for path in glob.glob(f"{os.path.dirname(__file__)}/*/__init__.py"):
2929
module = os.path.basename(os.path.dirname(path))
30-
importlib.import_module("sdb.commands.{}".format(module))
30+
importlib.import_module(f"sdb.commands.{module}")

sdb/commands/exit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424

2525
class Exit(sdb.Command):
26-
2726
"Exit the application"
2827

2928
names = ["exit", "quit"]

sdb/commands/filter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ def _call_one(self, obj: drgn.Object) -> Iterable[drgn.Object]:
113113
if not isinstance(lhs, drgn.Object):
114114
raise sdb.CommandInvalidInputError(
115115
self.name,
116-
"left hand side has unsupported type ({})".format(
117-
type(lhs).__name__))
116+
f"left hand side has unsupported type ({type(lhs).__name__})"
117+
)
118118

119119
if isinstance(rhs, str):
120120
lhs = lhs.string_().decode("utf-8")
@@ -127,10 +127,10 @@ def _call_one(self, obj: drgn.Object) -> Iterable[drgn.Object]:
127127
else:
128128
raise sdb.CommandInvalidInputError(
129129
self.name,
130-
"right hand side has unsupported type ({})".format(
131-
type(rhs).__name__))
130+
f"right hand side has unsupported type ({type(rhs).__name__})"
131+
)
132132

133-
if eval("lhs {} rhs".format(self.compare), {'__builtins__': None}, {
133+
if eval(f"lhs {self.compare} rhs", {'__builtins__': None}, {
134134
'lhs': lhs,
135135
'rhs': rhs
136136
}):

sdb/commands/internal/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import importlib
2121
import os
2222

23-
for path in glob.glob("{}/*.py".format(os.path.dirname(__file__))):
23+
for path in glob.glob(f"{os.path.dirname(__file__)}/*.py"):
2424
if path != __file__:
2525
module = os.path.splitext(os.path.basename(path))[0]
26-
importlib.import_module("sdb.commands.internal.{}".format(module))
26+
importlib.import_module(f"sdb.commands.internal.{module}")

sdb/commands/linux/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import importlib
2121
import os
2222

23-
for path in glob.glob("{}/*.py".format(os.path.dirname(__file__))):
23+
for path in glob.glob(f"{os.path.dirname(__file__)}/*.py"):
2424
if path != __file__:
2525
module = os.path.splitext(os.path.basename(path))[0]
26-
importlib.import_module("sdb.commands.linux.{}".format(module))
26+
importlib.import_module(f"sdb.commands.linux.{module}")
2727

28-
for path in glob.glob("{}/*/__init__.py".format(os.path.dirname(__file__))):
28+
for path in glob.glob(f"{os.path.dirname(__file__)}/*/__init__.py"):
2929
module = os.path.basename(os.path.dirname(path))
30-
importlib.import_module("sdb.commands.linux.{}".format(module))
30+
importlib.import_module(f"sdb.commands.linux.{module}")

sdb/commands/linux/dmesg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ def pretty_print(self, objs: Iterable[drgn.Object]) -> None:
5454
message = drgn.cast("char *", obj) + obj.type_.type.size
5555
text = message.string_().decode('utf-8', 'ignore')
5656

57-
print("[{:5d}.{:06d}]: {:s}".format(secs, usecs, text))
57+
print(f"[{secs:5d}.{usecs:06d}]: {text}")

sdb/commands/linux/internal/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import importlib
2121
import os
2222

23-
for path in glob.glob("{}/*.py".format(os.path.dirname(__file__))):
23+
for path in glob.glob(f"{os.path.dirname(__file__)}/*.py"):
2424
if path != __file__:
2525
module = os.path.splitext(os.path.basename(path))[0]
26-
importlib.import_module("sdb.commands.linux.internal.{}".format(module))
26+
importlib.import_module(f"sdb.commands.linux.internal.{module}")

0 commit comments

Comments
 (0)