File: lsblk.py

package info (click to toggle)
python3-dmm 0.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 540 kB
  • sloc: python: 441; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 940 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Show disk / partition information.
"""

import subprocess
import json

def list_scsi_devices():
    """
    Just return a list of available scsi disks.
    """
    lsblk_output = subprocess.check_output(["/bin/lsblk", "--scsi",
                                            "-noheadings", "--output",
                                            "NAME", "-n"]).decode("utf-8").split("\n")
    scsi_devices = [x for x in lsblk_output if x]
    return scsi_devices


def list_block_devices():
    """
    Get json data from lsbkl and convert it to a python dict.
    """
    lsblk_output = subprocess.check_output(["/bin/lsblk", "-J", "-O", "-b"])
    json_data = json.loads(lsblk_output)
    print(json_data)
    return(json_data)


def get_device_information(device):
    """
    Get ..."
    """


def list_partitions():
    """
    TODO: We need to list the partitions somehow
    so that we can present a disk to run cfdisk on.
    """