#272 inventory: There is no StringIO in python3
Merged 5 years ago by astepano. Opened 5 years ago by stefw.
stefw/standard-test-roles no-stringio  into  master

@@ -10,7 +10,6 @@ 

  import shlex

  import signal

  import logging

- import StringIO

  import random

  import socket

  import subprocess
@@ -171,7 +170,7 @@ 

      available_cpu = int(subprocess.check_output(['nproc']).strip())

      # https://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line

      core_sockets = set()

-     for line in StringIO.StringIO(subprocess.check_output(['lscpu', '-b', '-p=Core,Socket'])):

+     for line in subprocess.check_output(['lscpu', '-b', '-p=Core,Socket'], universal_newlines=True).split("\n"):

          if line.startswith('#'):

              continue

          core_sockets.add(line.strip())

We don't need to use StringIO in standard-inventory-qcow2
It's not available by default in python3 and it doesn't
have a useful use here.

Otherwise I see the following failure:

  [WARNING]:  * Failed to parse /data/src/standard-test-roles/inventory/standard-inventory-qcow2 with script plugin:
 Inventory script (/data/src/standard-test-roles/inventory/standard-inventory-qcow2) had an execution error: Traceback
 (most recent call last):   File "/data/src/standard-test-roles/inventory/standard-inventory-qcow2", line 13, in
 <module>     import StringIO ModuleNotFoundError: No module named 'StringIO'

Thank you. Look good. Merge.

Commit 659c7ce fixes this pull-request

Pull-Request has been merged by astepano

5 years ago

Pull-Request has been merged by astepano

5 years ago