summaryrefslogtreecommitdiff
path: root/test-cli/test/tasks/generatedmesg.py
blob: f0a341820996350e60194ee74dcef0fa01a7aa3f (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()
    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