Skip to content

Commit 2de50e9

Browse files
Ken KundertKen Kundert
Ken Kundert
authored and
Ken Kundert
committed
clean up before release
1 parent b531541 commit 2de50e9

File tree

13 files changed

+110
-35
lines changed

13 files changed

+110
-35
lines changed

conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
# add command line options used to signal missing dependencies to pytest
1010
def pytest_addoption(parser):
11-
#parser.addoption(
12-
# "--borg-version", action="store", default="99.99.99", help="version number of borg"
13-
#)
11+
# parser.addoption(
12+
# "--borg-version", action="store", default="99.99.99", help="version number of borg"
13+
# )
1414
parser.addoption(
1515
"--no-fuse", action="store_true", default=None, help="fuse is not available"
1616
)

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14-
import sys, os
14+
# import sys, os
1515

1616
# If extensions (or modules to document with autodoc) are in another directory,
1717
# add these directories to sys.path here. If the directory is relative to the

doc/configuring.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,3 +1562,49 @@ be specified using absolute paths (ex: :ref:`default_mount_point`,
15621562

15631563
If specified, *working_dir* must be specified using an absolute path.
15641564
If not specified, *working_dir* defaults to ``/``.
1565+
1566+
1567+
Read Only Settings
1568+
------------------
1569+
1570+
These settings are set by *Emborg* itself. They are useful as place-holders in
1571+
other settings.
1572+
1573+
.. _cmd_name:
1574+
1575+
cmd_name
1576+
~~~~~~~~
1577+
1578+
The name of the *Emborg* command currently being run.
1579+
1580+
1581+
.. _config_dir:
1582+
1583+
config_dir
1584+
~~~~~~~~~~~
1585+
1586+
Absolute path to *Emborg*'s configuration directory.
1587+
1588+
1589+
.. _config_name:
1590+
1591+
config_name
1592+
~~~~~~~~~~~
1593+
1594+
Name of active configuration.
1595+
1596+
1597+
.. _home_dir:
1598+
1599+
home_dir
1600+
~~~~~~~~
1601+
1602+
Absolute path to user's home directory.
1603+
1604+
1605+
.. _log_dir:
1606+
1607+
log_dir
1608+
~~~~~~~
1609+
1610+
Absolute path to the *Emborg*'s logging directory.

doc/releases.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ Latest development release
77
| Released: 2024-01-01
88
99

10-
1.39 (2024-??-??)
10+
1.39 (2024-04-29)
1111
-----------------
1212
- Add date of last check to output of info command.
13+
- Added :ref:`cmd_name` setting.
1314
- Miscellaneous refinements.
1415

1516

emborg/command.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def run(cls, command, args, settings, options):
406406
repair = ['--repair'] if cmdline['--repair'] else []
407407
if repair:
408408
if 'dry-run' in options:
409-
raise Error(f"--dry-run is not available with check command.")
409+
raise Error("--dry-run is not available with check command.")
410410
os.environ['BORG_CHECK_I_KNOW_WHAT_I_AM_DOING'] = 'YES'
411411

412412
# identify archive or archives to check
@@ -467,7 +467,7 @@ def run(cls, command, args, settings, options):
467467
if cmdline["--progress"] or settings.show_progress:
468468
borg_opts.append("--progress")
469469
if 'dry-run' in options:
470-
raise Error(f"--dry-run is not available with compact command.")
470+
raise Error("--dry-run is not available with compact command.")
471471

472472
# run borg
473473
borg = settings.run_borg(
@@ -900,7 +900,7 @@ def run(cls, command, args, settings, options):
900900

901901
try:
902902
# compact the repository if requested
903-
if settings.compact_after_delete and not 'dry-run' in options:
903+
if settings.compact_after_delete and 'dry-run' not in options:
904904
narrate("Compacting repository ...")
905905
compact = CompactCommand()
906906
compact_status = compact.run("compact", [], settings, options)

emborg/emborg.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
codicil,
2929
comment,
3030
conjoin,
31+
cull,
3132
dedent,
3233
display,
3334
done,
@@ -90,7 +91,6 @@
9091
fullhostname = getfullhostname()
9192
username = getusername()
9293

93-
9494
# borg_options_arg_count {{{2
9595
borg_options_arg_count = {
9696
"borg": 1,
@@ -809,26 +809,35 @@ def run_borg_raw(self, args):
809809
# report_borg_error() {{{2
810810
def report_borg_error(self, e, cmd):
811811
narrate('Borg terminates with exit status:', e.status)
812+
if e.stdout:
813+
log('borg stdout:', indent(e.stdout), sep='\n')
814+
else:
815+
log('borg stdout: ❬empty❭')
816+
if e.stderr:
817+
log('borg stderr:', indent(e.stderr), sep='\n')
818+
else:
819+
log('borg stderr: ❬empty❭')
812820
codicil = None
813821
if e.stderr:
814822
if 'previously located at' in e.stderr:
815823
codicil = dedent(f'''
816824
If repository was intentionally relocated, re-run with --relocated:
817825
emborg --relocated {cmd} ...
818-
''')
826+
''', strip_nl='b')
819827
if 'Failed to create/acquire the lock' in e.stderr:
820-
codicil = [
821-
'If another Emborg or Borg process is using this repository,',
822-
'please wait for it to finish.',
823-
'Perhaps you still have an archive mounted?',
824-
'If so, use ‘emborg umount’ to unmount it.',
825-
'Perhaps a previous run was killed or terminated with an error?',
826-
'If so, use ‘emborg breaklock’ to clear the lock.',
827-
]
828+
codicil = dedent('''
829+
If another Emborg or Borg process is using this repository,
830+
please wait for it to finish.
831+
Perhaps you still have an archive mounted?
832+
If so, use ‘emborg umount’ to unmount it.
833+
Perhaps a previous run was killed or terminated with an error?
834+
If so, use ‘emborg breaklock’ to clear the lock.
835+
''', strip_nl='b')
828836

829837
if 'Mountpoint must be a writable directory' in e.stderr:
830838
codicil = 'Perhaps an archive is already mounted there?'
831-
e.reraise(culprit=cmd, codicil=codicil)
839+
840+
e.reraise(culprit=cull((cmd, self.config_name)), codicil=codicil)
832841

833842
# destination() {{{2
834843
def destination(self, archive=None):

emborg/main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ def main():
7171
) as inform:
7272

7373
try:
74+
worst_exit_status = 0
75+
76+
# emborg fails if the current working directory does not exist and
77+
# the message returned by OSError does not make the problem obvious.
78+
try:
79+
os.getcwd()
80+
except OSError as e:
81+
raise Error(os_error(e), codicil="Does the current working directory exist?")
82+
7483
# read command line
7584
cmdline = docopt(expanded_synopsis, options_first=True, version=version)
7685
config = cmdline["--config"]
@@ -94,7 +103,6 @@ def main():
94103
inform.narrate = True
95104

96105
Hooks.provision_hooks()
97-
worst_exit_status = 0
98106

99107
# find the command
100108
cmd, cmd_name = Command.find(command)
@@ -125,8 +133,8 @@ def main():
125133
worst_exit_status = exit_status
126134

127135
except Error as e:
128-
e.report()
129136
exit_status = 2
137+
e.report()
130138
except OSError as e:
131139
exit_status = 2
132140
error(os_error(e))

emborg/patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# Imports {{{1
2020
from os.path import expanduser as expand_user
21-
from inform import Error, error, log
21+
from inform import Error, error
2222
from .shlib import to_path
2323

2424

emborg/preferences.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
avendesora_field="name of field in Avendesora that holds the passphrase",
6060
borg_executable="path to borg",
6161
check_after_create="run check as the last step of an archive creation",
62-
cmd_name="name of command being run (read only)",
62+
cmd_name="name of Emborg command being run (read only)",
6363
colorscheme="the color scheme",
6464
config_dir="absolute path to configuration directory (read-only)",
65-
config_name="name of active configuration (set by program)",
65+
config_name="name of active configuration (read only)",
6666
configurations="available Emborg configurations",
6767
default_configuration="default Emborg configuration",
6868
default_mount_point="directory to use as mount point if one is not specified",

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,15 @@ changelog = "https://emborg.readthedocs.io/en/latest/releases.html"
4747
[build-system]
4848
requires = ["flit_core >=2,<4"]
4949
build-backend = "flit_core.buildapi"
50+
51+
[tool.ruff]
52+
exclude = [".tox", "doc"]
53+
54+
[tool.ruff.lint]
55+
select = ["F"]
56+
ignore = []
57+
58+
[tool.ruff.lint.per-file-ignores]
59+
"__init__.py" = ["F401"]
60+
"emborg/overdue.py" = ["F841"]
61+

tests/test-cases.nt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ emborg without configs:
7474
> borg_executable: path to borg
7575
> check_after_create: run check as the last step of an archive
7676
> creation
77-
> cmd_name: name of command being run (read only)
77+
> cmd_name: name of Emborg command being run (read only)
7878
> colorscheme: the color scheme
7979
> compact_after_delete: run compact after deleting an archive or
8080
> pruning a repository
8181
> config_dir: absolute path to configuration directory
8282
> (read-only)
83-
> config_name: name of active configuration (set by program)
83+
> config_name: name of active configuration (read only)
8484
> configurations: available Emborg configurations
8585
> cronhub_url: the cronhub.io URL for back-ups monitor
8686
> cronhub_uuid: the cronhub.io UUID for back-ups monitor
@@ -212,13 +212,13 @@ emborg with configs:
212212
> borg_executable: path to borg
213213
> check_after_create: run check as the last step of an archive
214214
> creation
215-
> cmd_name: name of command being run (read only)
215+
> cmd_name: name of Emborg command being run (read only)
216216
> colorscheme: the color scheme
217217
> compact_after_delete: run compact after deleting an archive or
218218
> pruning a repository
219219
> config_dir: absolute path to configuration directory
220220
> (read-only)
221-
> config_name: name of active configuration (set by program)
221+
> config_name: name of active configuration (read only)
222222
> configurations: available Emborg configurations
223223
> cronhub_url: the cronhub.io URL for back-ups monitor
224224
> cronhub_uuid: the cronhub.io UUID for back-ups monitor
@@ -667,7 +667,7 @@ emborg with configs:
667667
> run_before_borg on test0
668668
> run_after_backup on test0
669669
> run_after_last_backup on test0
670-
> emborg error: create:
670+
> emborg error: create, test0:
671671
> Failed to create/acquire the lock /⟪EMBORG⟫/tests/repositories/lock (timeout).
672672
> If another Emborg or Borg process is using this repository,
673673
> please wait for it to finish.
@@ -1101,7 +1101,7 @@ emborg with configs:
11011101
cleanser:
11021102
args: --config test7 list
11031103
expected:
1104-
> emborg error: list:
1104+
> emborg error: list, test7:
11051105
> Repository /⟪EMBORG⟫/tests/repositories does not exist.
11061106
expected_type: error
11071107

tests/test_emborg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# Imports {{{1
1919
import arrow
2020
import json
21-
import nestedtext as nt
2221
import os
2322
from parametrize_from_file import parametrize
2423
from functools import partial

tox.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ envlist = lint, pytest, mypy
33
isolated_build = True
44

55
[testenv:lint]
6-
deps = pylama
7-
skip_install = true
8-
commands = pylama --ignore C901,E116,E251,E203,E501,E741,E731 emborg/*.py
6+
deps =
7+
setuptools
8+
ruff
9+
commands = ruff check
910

1011
# Test environment
1112
[testenv]
@@ -18,7 +19,6 @@ deps =
1819
voluptuous
1920

2021
[testenv:pytest]
21-
# commands = py.test -vv --cov {posargs} --cov-branch --cov-report term-missing
2222
commands = py.test -vv --cov {posargs} --cov-branch --cov-report term
2323

2424
[testenv:mypy]

0 commit comments

Comments
 (0)