Skip to content

Commit

Permalink
refactor 'QUBESD_SOCKET' into separate module
Browse files Browse the repository at this point in the history
This will avoid cyclic imports in upcoming events implementation
  • Loading branch information
marmarek committed Apr 28, 2017
1 parent 36d8ee9 commit d8b0ff3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
4 changes: 3 additions & 1 deletion qubesmgmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
'''Qubes OS management client.'''

import os

import qubesmgmt.config
import qubesmgmt.base
import qubesmgmt.app

DEFAULT = qubesmgmt.base.DEFAULT

if os.path.exists(qubesmgmt.app.QUBESD_SOCK):
if os.path.exists(qubesmgmt.config.QUBESD_SOCKET):
Qubes = qubesmgmt.app.QubesLocal
else:
Qubes = qubesmgmt.app.QubesRemote
11 changes: 5 additions & 6 deletions qubesmgmt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import subprocess

import qubesmgmt.base
import qubesmgmt.vm
import qubesmgmt.label
import qubesmgmt.exc
import qubesmgmt.utils
import qubesmgmt.label
import qubesmgmt.storage
import qubesmgmt.utils
import qubesmgmt.vm
import qubesmgmt.config

QUBESD_SOCK = '/var/run/qubesd.sock'
BUF_SIZE = 4096


Expand Down Expand Up @@ -103,7 +103,6 @@ def keys(self):
return self._vm_list.keys()



class QubesBase(qubesmgmt.base.PropertyHolder):
'''Main Qubes application'''

Expand Down Expand Up @@ -182,7 +181,7 @@ class QubesLocal(QubesBase):
def qubesd_call(self, dest, method, arg=None, payload=None):
try:
client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client_socket.connect(QUBESD_SOCK)
client_socket.connect(qubesmgmt.config.QUBESD_SOCKET)
except IOError:
# TODO:
raise
Expand Down
24 changes: 24 additions & 0 deletions qubesmgmt/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- encoding: utf8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
# Copyright (C) 2017 Marek Marczykowski-Górecki
# <[email protected]>
#
# 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/>.

'''Configuration variables/constants'''

#: path to qubesd socket
QUBESD_SOCKET = '/var/run/qubesd.sock'

0 comments on commit d8b0ff3

Please sign in to comment.