aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/arch.py
blob: b1b88fd89c28e18f223524a01bfdf542d8c97ca8 (plain) (blame)
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
from popen2 import Popen4
import os
import config
client = config.get_val("arch_client")
if client is None:
    client = "tla"
    config.set_val("arch_client", client)

def invoke(args):
    q=Popen4(args)
    output = q.fromchild.read()
    status = q.wait()
    if os.WIFEXITED(status):
        return os.WEXITSTATUS(status)
    raise Exception("Command failed")

def invoke_client(*args, **kwargs):
    status = invoke((client,) + args)
    if status not in (0,):
        raise Exception("Command failed")

def add_id(filename):
    invoke_client("add-id", filename)

def delete_id(filename):
    invoke_client("delete-id", filename)