# -*- encoding: utf8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
# Copyright (C) 2017 Marek Marczykowski-Górecki
#                               <marmarek@invisiblethingslab.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.

'''Qubes OS management client.'''

import os

import qubesadmin.config
import qubesadmin.base
import qubesadmin.app

DEFAULT = qubesadmin.base.DEFAULT

if os.path.exists(qubesadmin.config.QUBESD_SOCKET):
    Qubes = qubesadmin.app.QubesLocal
else:
    Qubes = qubesadmin.app.QubesRemote

# -*- encoding: utf8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
# Copyright (C) 2017 Marek Marczykowski-Górecki
#                               <marmarek@invisiblethingslab.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.

'''Qubes OS management client.'''

import os

import qubesadmin.config
import qubesadmin.base
import qubesadmin.app

DEFAULT = qubesadmin.base.DEFAULT

if os.path.exists('/etc/qubes-release'):
    Qubes = qubesadmin.app.QubesLocal
else:
    Qubes = qubesadmin.app.QubesRemote

Choose QubesLocal or QubesRemote based on /etc/qubes-release presence
Choose QubesLocal or QubesRemote based on /etc/qubes-release presence

Do not check for qubesd socket (at module import time), because if not
running at this precise time, it will lead to wrong choice. And a weird
error message in consequence (looking for qrexec-client-vm in dom0).

Fixes QubesOS/qubes-issues#2917
