Skip to content

Commit

Permalink
Merge branch 'release/1.13.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
lueschem committed Dec 20, 2022
2 parents 08c39c9 + 28ebf49 commit cbc9d14
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 9 deletions.
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
edi (1.13.1) jammy; urgency=medium

[ Matthias Lüscher ]
* Fix get_profile_description for log level DEBUG. Closes #78.

-- Matthias Lüscher (Launchpad) <m.luescher@datacomm.ch> Tue, 20 Dec 2022 18:15:48 +0100

edi (1.13.0) jammy; urgency=medium

[ Matthias Lüscher ]
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
# built documents.
#
# The short X.Y version.
version = '1.13.0'
release = '1.13.0'
version = '1.13.1'
release = '1.13.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion edi/lib/lxchelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def is_profile_existing(name):
@require('lxc', lxd_install_hint, LxdVersion.check)
def get_profile_description(name):
cmd = [lxc_exec(), "profile", "show", name]
result = run(cmd, check=False, stderr=subprocess.PIPE)
result = run(cmd, check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode == 0:
return yaml.safe_load(result.stdout).get('description', '')
else:
Expand Down
5 changes: 5 additions & 0 deletions edi/lib/mockablerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# along with edi. If not, see <http://www.gnu.org/licenses/>.

import subprocess
import logging


def run_mockable(*popenargs, **kwargs):
Expand All @@ -30,3 +31,7 @@ def run_mockable(*popenargs, **kwargs):
:return: passes back the result of subprocess.run()
"""
return subprocess.run(*popenargs, **kwargs)


def is_logging_enabled_for(log_threshold):
return logging.getLogger().isEnabledFor(log_threshold)
4 changes: 2 additions & 2 deletions edi/lib/shellhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def run(popenargs, sudo=False, input=None, timeout=None, check=True, universal_n
subprocess_stdout = stdout

if subprocess_stdout == _ADAPTIVE:
if logging.getLogger().isEnabledFor(log_threshold):
if mockablerun.is_logging_enabled_for(log_threshold):
subprocess_stdout = None
else:
subprocess_stdout = subprocess.PIPE
Expand All @@ -66,7 +66,7 @@ def run(popenargs, sudo=False, input=None, timeout=None, check=True, universal_n
universal_newlines=universal_newlines,
stdout=subprocess_stdout, **kwargs)

if (logging.getLogger().isEnabledFor(log_threshold) and
if (mockablerun.is_logging_enabled_for(log_threshold) and
subprocess_stdout is subprocess.PIPE):
logging.log(log_threshold, result.stdout)

Expand Down
2 changes: 1 addition & 1 deletion edi/lib/versionhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# The do_release script will update this version!
# During launchpad debuild neither the git version nor the package version is available.
edi_fallback_version = '1.13.0'
edi_fallback_version = '1.13.1'


def get_edi_version():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
setup(
name='edi',

version='1.13.0',
version='1.13.1',

description='Embedded Development Infrastructure - edi',
long_description=long_description,
Expand Down
7 changes: 5 additions & 2 deletions tests/lib/test_lxchelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
is_container_running, get_profile_description, is_profile_existing,
write_lxc_profile)
from edi.lib.shellhelpers import mockablerun, run
from tests.libtesting.helpers import get_command, get_sub_command
from tests.libtesting.helpers import get_command, get_sub_command, log_during_run
from tests.libtesting.contextmanagers.mocked_executable import mocked_executable, mocked_lxd_version_check


Expand Down Expand Up @@ -193,14 +193,17 @@ def test_is_description_empty_on_created_profile():


@pytest.mark.requires_lxc
def test_write_profile():
@pytest.mark.parametrize("do_log", [True, False])
def test_write_profile(monkeypatch, do_log):
profile_text = """
name: this-is-an-unused-edi-pytest-profile
description: Some description
config: {}
devices: {}
"""

log_during_run(monkeypatch, do_log)

profile_name, _ = write_lxc_profile(profile_text)
assert is_profile_existing(profile_name)
assert "Some description" == get_profile_description(profile_name)
Expand Down
8 changes: 8 additions & 0 deletions tests/libtesting/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import random
import shutil
from edi.lib.helpers import get_user
from edi.lib import mockablerun


def get_random_string(length):
Expand Down Expand Up @@ -67,3 +68,10 @@ def fakechown(*_):

if get_user() == 'root': # debuild case
monkeypatch.setattr(shutil, 'chown', fakechown)


def log_during_run(monkeypatch, do_log):
def force_logging(*_):
return do_log

monkeypatch.setattr(mockablerun, 'is_logging_enabled_for', force_logging)

0 comments on commit cbc9d14

Please sign in to comment.