'Wrapper method for the "oc" command'

def oc_command(self, sub, kind, namespace=None, name=None, add_options=None):

    cmd = [self.binary, sub, kind]
    if (name is not None):
        cmd = (cmd + [name])
    if (namespace is not None):
        cmd = (cmd + ['-n', namespace])
    if (add_options is None):
        add_options = []
    cmd = (((cmd + [('--user=' + self.user), ('--config=' + self.kubeconfig)]) + DEFAULT_OC_OPTIONS) + add_options)
    try:
        process = Popen(cmd, stdout=PIPE, stderr=PIPE)
        (out, err) = process.communicate(cmd)
        if (len(err) > 0):
            if ('not    found' in err):
                return {'items': []}
            if ('No    resources    found' in err):
                return {'items': []}
            raise Exception(err)
    except Exception as excp:
        err = ((("There    was    an    exception    trying    to    run    the    command    '" + '    '.join(cmd)) + "'    ") + str(excp))
        raise Exception(err)
    return json.loads(out)
