summaryrefslogtreecommitdiff
path: root/test-cli/test/tasks/generatedmesg.py
blob: aa9d9ce076591dab29ee4da9f209883c712900ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import sh


def generate_dmesg(tidctl, pgObj):
    print("Start getting DMESG...")
    p = sh.dmesg("--color=never")
    if p.exit_code != 0:
        print("DMESG: Unknown error.")
        return 1
    else:
        # save dmesg in a file
        with open('/tmp/dmesg.txt', 'w') as outfile:
            n = outfile.write(p.stdout.decode('ascii'))
        # save dmesg result in DB
        pgObj.upload_dmesg(tidctl, '/tmp/dmesg.txt')
        print("DMESG: saved succesfully.")
        return 0