Esempio n. 1
0
from gabriel.common.config import DEBUG

from optparse import OptionParser
import multiprocessing
import traceback
import threading
import socket
import select
import struct
import json
import Queue
import time
import pprint


LOG = logging.getLogger(__name__)


def get_service_list(argv=None):
    upnp_client = UPnPClient()
    settings, args = process_command_line(sys.argv[1:])
    service_list = None
    if settings.address is None:
        upnp_client.start()
        upnp_client.join()
        service_list = upnp_client.service_list
    else:
        import urllib2

        ip_addr, port = settings.address.split(":", 1)
        port = int(port)
Esempio n. 2
0
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

import subprocess
import threading
import os
from gabriel.common import log as logging
from gabriel.common.config import Const as Const

LOG = logging.getLogger(__name__)


class UPnPError(Exception):
    pass


class UPnPServer(threading.Thread):

    def __init__(self):
        self.stop = threading.Event()
        self.upnp_bin = Const.UPnP_SERVER_PATH
        self.proc = None
        if os.path.exists(self.upnp_bin) == False:
            raise UPnPError("Cannot find binary: %s" % self.upnp_bin)
        threading.Thread.__init__(self, target=self.run_exec)