Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
stev9171 committed Jun 22, 2022
1 parent 6cd85af commit 5dd6de6
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 36 deletions.
8 changes: 5 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ disable=raw-checker-failed,
unspecified-encoding,
no-name-in-module,
import-error,
subprocess-popen-preexec-fn,
consider-using-generator,
consider-using-f-string

# Enable the message, report, category or checker with the given id(s). You can
Expand All @@ -180,10 +182,10 @@ exclude-too-few-public-methods=
ignored-parents=

# Maximum number of arguments for function / method.
max-args=5
max-args=10

# Maximum number of attributes for a class (see R0902).
max-attributes=7
max-attributes=10

# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5
Expand Down Expand Up @@ -320,7 +322,7 @@ ignore-imports=yes
ignore-signatures=yes

# Minimum lines number of a similarity.
min-similarity-lines=10
min-similarity-lines=40


[SPELLING]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __call__(self, event, snapshot_fsm, snapshot_vol):

if process.returncode != 0:
LOG.error("dir exited with non-zero status: %d", process.returncode)
LOG.error("Tailing up to the last 10 lines of archive.log for " "troubleshooting:")
LOG.error("Tailing up to the last 10 lines of archive.log for troubleshooting:")
for line in open(archive_log, "r").readlines()[-10:]:
LOG.error(" ! %s", line.rstrip())
raise CalledProcessError(process.returncode, "dir")
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ def record_slave_status(client, config):
config["slave_master_log_file"] = binlog
config["slave_master_log_pos"] = position
LOG.info(
"Recorded slave replication status: " "master_binlog = %s master_position = %s",
"Recorded slave replication status: master_binlog = %s master_position = %s",
binlog,
position,
)
else:
LOG.info(
"This MySQL server is not a slave. " "Nothing to record from SHOW SLAVE STATUS"
)
LOG.info("This MySQL server is not a slave. Nothing to record from SHOW SLAVE STATUS")
except MySQLError as exc:
raise BackupError(
"MySQL error while acquiring slave replication " "status [%d] %s" % exc.args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __call__(self, event, snapshot_fsm, snapshot_vol):
if pre_args or post_args:
warning_readme = os.path.join(archive_dirname, "NONSTD_TAR.txt")
warning_log = open(warning_readme, "w")
print(("This tar file was generated with non-std " "args:"), file=warning_log)
print(("This tar file was generated with non-std args:"), file=warning_log)
print(list2cmdline(argv), file=warning_log)
archive_log = os.path.join(archive_dirname, "archive.log")
process = Popen(
Expand All @@ -80,7 +80,7 @@ def __call__(self, event, snapshot_fsm, snapshot_vol):

if process.returncode != 0:
LOG.error("tar exited with non-zero status: %d", process.returncode)
LOG.error("Tailing up to the last 10 lines of archive.log for " "troubleshooting:")
LOG.error("Tailing up to the last 10 lines of archive.log for troubleshooting:")
for line in open(archive_log, "r").readlines()[-10:]:
LOG.error(" ! %s", line.rstrip())
raise CalledProcessError(process.returncode, "tar")
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def build_snapshot(config, logical_volume, suppress_tmpdir=False):
_snapshot_size = snapshot_size
snapshot_size = parse_bytes(snapshot_size) / extent_size
LOG.info(
"Using requested snapshot-size %s " "rounded by extent-size %s to %s.",
"Using requested snapshot-size %s rounded by extent-size %s to %s.",
_snapshot_size,
format_bytes(extent_size),
format_bytes(snapshot_size * extent_size),
)
if snapshot_size < 1:
raise BackupError(
"Requested snapshot-size (%s) is " "less than 1 extent" % _snapshot_size
"Requested snapshot-size (%s) is less than 1 extent" % _snapshot_size
)
if snapshot_size > int(logical_volume.vg_free_count):
LOG.info(
Expand Down Expand Up @@ -135,7 +135,7 @@ def _dry_run(target_directory, volume, snapshot, datadir):
LOG.info("* Would mount on %s", snapshot.mountpoint or "generated temporary directory")
if getmount(target_directory) == getmount(datadir):
LOG.error(
"Backup directory %s is on the same filesystem as " "the source logical volume %s.",
"Backup directory %s is on the same filesystem as the source logical volume %s.",
target_directory,
volume.device_name(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ def check_innodb(pathinfo, ensure_subdir_of_datadir=False):
space_mp = getmount(tablespace)
if space_mp != datadir_mp:
LOG.error(
"InnoDB shared tablespace %s is not on the same " "filesystem as the datadir %s",
"InnoDB shared tablespace %s is not on the same filesystem as the datadir %s",
tablespace,
datadir,
)
is_unsafe_for_lvm = True
if ensure_subdir_of_datadir and not is_subdir(tablespace, datadir):
LOG.error(
"InnoDB shared tablespace %s is not within a " "subdirectory of the datadir %s.",
"InnoDB shared tablespace %s is not within a subdirectory of the datadir %s.",
tablespace,
datadir,
)
Expand All @@ -223,14 +223,14 @@ def check_innodb(pathinfo, ensure_subdir_of_datadir=False):

if ib_logdir_mp != datadir_mp:
LOG.error(
"innodb-log-group-home-dir %s is not on the same filesystem " "as the MySQL datadir %s",
"innodb-log-group-home-dir %s is not on the same filesystem as the MySQL datadir %s",
ib_logdir,
datadir,
)
is_unsafe_for_lvm = True
if ensure_subdir_of_datadir and not is_subdir(ib_logdir, datadir):
LOG.error(
"innodb-log-group-home-dir %s is not a subdirectory of " "the datadir %s.",
"innodb-log-group-home-dir %s is not a subdirectory of the datadir %s.",
ib_logdir,
datadir,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def backup(self):
if self.config["mysqldump"]["bin-log-position"]:
LOG.warning("bin-log-position is not supported with mysqldump-lvm.")
LOG.warning(
"Replication status will be saved to the " "[mysql:replication] section in %s",
"Replication status will be saved to the [mysql:replication] section in %s",
self.config.filename,
)
self.config["mysqldump"]["bin-log-position"] = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
def check_master_data(version, arg):
"""Validate --master-data against a mysqldump version"""
if version < (4, 1, 8) and arg:
raise MyOptionError("--master-data only takes an argument in MySQL " ">= 4.1.8")
raise MyOptionError("--master-data only takes an argument in MySQL >= 4.1.8")
if arg:
try:
value = int(arg)
assert value in (1, 2)
except ValueError:
raise MyOptionError("Invalid argument to --master-data: %r" % arg)
except AssertionError:
raise MyOptionError("Argument to --master-data must be 1 or 2 " "not %r" % arg)
raise MyOptionError("Argument to --master-data must be 1 or 2 not %r" % arg)


class MySQLDumpError(Exception):
Expand Down
32 changes: 22 additions & 10 deletions plugins/holland.backup.mysqldump/holland/backup/mysqldump/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
extra-defaults = boolean(default=no)
mysql-binpath = force_list(default=list())
lock-method = option('flush-lock', 'lock-tables', 'single-transaction', 'auto-detect', 'none', default='auto-detect')
lock-method = option('flush-lock',
'lock-tables',
'single-transaction',
'auto-detect',
'none',
default='auto-detect')
databases = force_list(default=list('*'))
exclude-databases = force_list(default=list())
Expand Down Expand Up @@ -185,9 +190,9 @@ def backup(self):
if self.config["mysqldump"]["stop-slave"]:
slave_status = self.client.show_slave_status()
if not slave_status:
raise BackupError("stop-slave enabled, but 'show slave " "status' failed")
raise BackupError("stop-slave enabled, but 'show slave status' failed")
if slave_status and slave_status["slave_sql_running"] != "Yes":
raise BackupError("stop-slave enabled, but replication is " "not running")
raise BackupError("stop-slave enabled, but replication is not running")
if not self.dry_run:
_stop_slave(self.client, self.config)
elif self.config["mysqldump"]["bin-log-position"]:
Expand Down Expand Up @@ -225,7 +230,10 @@ def _backup(self):
extra_defaults = config["extra-defaults"]
try:
mysqldump = MySQLDump(
defaults_file, mysqldump_bin, extra_defaults=extra_defaults, mock_env=self.mock_env
defaults_file,
mysqldump_bin,
extra_defaults=extra_defaults,
mock_env=self.mock_env,
)
except MySQLDumpError as exc:
raise BackupError(str(exc))
Expand Down Expand Up @@ -336,7 +344,7 @@ def collect_mysqldump_options(config, mysqldump, client):
options.append("--flush-logs")
if config["flush-privileges"]:
if mysqldump.version < (5, 0, 26):
LOG.warning("--flush privileges is available only for mysqldump " "in 5.0.26+")
LOG.warning("--flush privileges is available only for mysqldump in 5.0.26+")
else:
options.append("--flush-privileges")
if config["dump-routines"]:
Expand All @@ -360,7 +368,7 @@ def collect_mysqldump_options(config, mysqldump, client):
options.append("--max-allowed-packet=" + config["max-allowed-packet"])
if config["bin-log-position"]:
if client.show_variable("log_bin") != "ON":
raise BackupError("bin-log-position requested but " "bin-log on server not active")
raise BackupError("bin-log-position requested but bin-log on server not active")
options.append("--master-data=2")
options.extend(config["additional-options"])
return options
Expand Down Expand Up @@ -484,7 +492,7 @@ def exclude_invalid_views(schema, client, definitions_file):
invalid_view = True
else:
LOG.error(
"Unexpected error when checking invalid " "view %s.%s: [%d] %s",
"Unexpected error when checking invalid view %s.%s: [%d] %s",
schema_db.name,
table.name,
*exc.args
Expand All @@ -498,18 +506,22 @@ def exclude_invalid_views(schema, client, definitions_file):
)
if view_definition is None:
LOG.error(
"!!! Failed to retrieve view definition for " "`%s`.`%s`",
"!!! Failed to retrieve view definition for `%s`.`%s`",
schema_db.name,
table.name,
)
LOG.warning(
"!!! View definition for `%s`.`%s` will " "not be included in this backup",
"!!! View definition for `%s`.`%s` will not be included in this backup",
schema_db.name,
table.name,
)
continue

LOG.info("* Saving view definition for " "`%s`.`%s`", schema_db.name, table.name)
LOG.info(
"* Saving view definition for `%s`.`%s`",
schema_db.name,
table.name,
)
invalid_views = invalid_views + "--\n-- Current View: `%s`.`%s`\n--\n%s;\n" % (
schema_db.name,
table.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def backup_pgsql(backup_directory, config):
pgpass_file = generate_pgpassfile(backup_directory, config["pgauth"]["password"])
if "PGPASSFILE" in pgenv:
LOG.warning(
"Overriding PGPASSFILE in environment with %s because " "a password is specified.",
"Overriding PGPASSFILE in environment with %s because a password is specified.",
pgpass_file,
)
pgenv["PGPASSFILE"] = pgpass_file
Expand Down
4 changes: 2 additions & 2 deletions plugins/holland.backup.pgdump/holland/backup/pgdump/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def pgauth2args(config):
args.extend(["--role", config["pgdump"]["role"]])
else:
raise BackupError(
"The --role option is available only in Postgres" " versions 8.4 and higher."
"The --role option is available only in Postgres versions 8.4 and higher."
)

return args
Expand Down Expand Up @@ -255,7 +255,7 @@ def backup_pgsql(backup_directory, config, databases):
pgpass_file = generate_pgpassfile(backup_directory, config["pgauth"]["password"])
if "PGPASSFILE" in pgenv:
LOG.warning(
"Overriding PGPASSFILE in environment with %s because " "a password is specified.",
"Overriding PGPASSFILE in environment with %s because a password is specified.",
pgpass_file,
)
pgenv["PGPASSFILE"] = pgpass_file
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.lib.lvm/holland/lib/lvm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Volume(object):
def __new__(cls, attributes=()):
if cls is Volume:
raise NotImplementedError(
"Volume is an abstract base class and " "should not be directly instantiated"
"Volume is an abstract base class and should not be directly instantiated"
)
return super(Volume, cls).__new__(cls)

Expand Down
4 changes: 2 additions & 2 deletions plugins/holland.lib.lvm/holland/lib/lvm/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def mount_snapshot(self, snapshot):

if filesystem == "xfs":
LOG.info(
"xfs filesystem detected on %s. " "Using mount -o nouuid",
"xfs filesystem detected on %s. Using mount -o nouuid",
snapshot.device_name(),
)
options = "nouuid"
Expand Down Expand Up @@ -127,7 +127,7 @@ def error(self, snapshot, exc):
snapshot.reload()
if "S" in snapshot.lv_attr:
LOG.error(
"Snapshot space (%s) exceeded. " "Snapshot %s is no longer valid",
"Snapshot space (%s) exceeded. Snapshot %s is no longer valid",
snapshot.device_name(),
format_bytes(int(snapshot.lv_size)),
)
Expand Down

0 comments on commit 5dd6de6

Please sign in to comment.