#1155 cli: fix chroot-list command to work on both python2 and python3
Merged 4 years ago by praiskup. Opened 4 years ago by dturecek.
copr/ dturecek/copr chroot_list  into  master

file modified
+6 -4
@@ -11,7 +11,6 @@ 

  import simplejson

  import requests

  from collections import defaultdict

- from textwrap import indent

  

  import logging

  if six.PY2:
@@ -35,7 +34,7 @@ 

  from copr.v3 import (Client, config_from_file, CoprException, CoprRequestException, CoprNoConfigException,

                       CoprConfigException, CoprNoResultException)

  

- from .util import ProgressBar, json_dumps

+ from .util import ProgressBar, json_dumps, serializable

  from .build_config import MockProfile

  

  import pkg_resources
@@ -538,12 +537,15 @@ 

      def action_list_chroots(self, args):

          """List all currently available chroots.

          """

+         def indent(string):

+             return '\n'.join(['    ' + l for l in string.split('\n')])

+ 

          chroots = self.client.mock_chroot_proxy.get_list()

-         chroots = simplejson.loads(json_dumps(chroots))

+         chroots = serializable(chroots)

          for chroot, comment in chroots.items():

              print(chroot)

              if comment:

-                 print(indent(comment, '    '))

+                 print(indent(comment))

  

      #########################################################

      ###                   Package actions                 ###

file modified
+2 -1
@@ -684,7 +684,8 @@ 

  

  

  @mock.patch('copr.v3.proxies.mock_chroot.MockChrootProxy.get_list')

- def test_list_chroots(list_chroots):

+ @mock.patch('copr_cli.main.config_from_file', return_value=mock_config)

+ def test_list_chroots(config, list_chroots):

      list_chroots.return_value = Munch({

          "fedora-18-x86_64": "",

          "fedora-17-x86_64": "A short chroot comment",

This adds implementation of indent which is needed for formatting
the output as textwrap.indent() is not implemented in python2.

rebased onto 9061740400a7b857fafe594ca3263b7fb6e5c6c8

4 years ago

exc_info = (<type 'exceptions.TypeError'>, TypeError("init() got an unexpected keyword argument 'for_json'",), <traceback object at 0x3375878>)

Failed on RHEL6 https://copr-be.cloud.fedoraproject.org/results/@copr/copr-dev:pr:1155/epel-6-x86_64/01126768-copr-cli/builder-live.log.gz

rebased onto dd92da99c3d58e59fe72acdc65130e6228b557aa

4 years ago

rebased onto 9aa8f60

4 years ago

Pull-Request has been merged by praiskup

4 years ago