Example #1
0
def runserver(argset=[], **kwargs):
    # Get the options
    options = SERVER_OPTIONS.copy()
    options.update(kwargs)

    from net.aircable.utils import getLogger
    logger = getLogger(__name__)

    if options['daemonize']:
        if not options['pidfile']:
            options['pidfile'] = '/var/run/openproximity_rpc_%s.pid' % \
                options['port']

        logger.info("storing pid file in %s" % options['pidfile'])
        from django.utils.daemonize import become_daemon
        
        logger.info("daemonizing")
        become_daemon()
        logger.info("daemonized")

        fp = open(options['pidfile'], 'w')
        fp.write("%d\n" % os.getpid())
        fp.close()

    # Start the rpc server
    logger.debug('starting server with options %s' % options)
    start_server(options)
Example #2
0
def runserver(argset=[], **kwargs):
    # Get the options
    options = SERVER_OPTIONS.copy()
    options.update(kwargs)

    from net.aircable.utils import getLogger
    logger = getLogger(__name__)

    if options['daemonize']:
        if not options['pidfile']:
            options['pidfile'] = '/var/run/openproximity_rpc_%s.pid' % \
                options['port']

        logger.info("storing pid file in %s" % options['pidfile'])
        from django.utils.daemonize import become_daemon

        logger.info("daemonizing")
        become_daemon()
        logger.info("daemonized")

        fp = open(options['pidfile'], 'w')
        fp.write("%d\n" % os.getpid())
        fp.close()

    # Start the rpc server
    logger.debug('starting server with options %s' % options)
    start_server(options)
Example #3
0
def runclient(argset=[], **kwargs):
    # Get the options
    options = CLIENT_OPTIONS.copy()
    options.update(kwargs)

    from net.aircable.utils import getLogger
    logger = getLogger(__name__)

    if options['daemonize']:
        if not options['pidfile']:
            options['pidfile'] = '/var/run/openproximity_client_%s_%s.pid' % ( \
                options['mode'], options['port'] )

        logger.info("storing pid file in %s" % options['pidfile'])
        from django.utils.daemonize import become_daemon

        logger.info("daemonizing")
        become_daemon()
        logger.info("daemonized")

        fp = open(options['pidfile'], 'w')
        fp.write("%d\n" % os.getpid())
        fp.close()

    # Start the rpc server
    logger.debug('starting client with options %s' % options)
    mode = options['mode']
    host = options['host']
    port = int(options['port'])
    valid_modes = ['scanner', 'uploader', 'pairing']
    from net.aircable.openproximity.pluginsystem import pluginsystem
    valid_modes.extend([ \
            i.provides['serverxr_type'] for i in \
                pluginsystem.get_plugins('serverxr')])
    if mode not in valid_modes:
        print "not a valid mode, use any of", valid_modes
        sys.exit(1)
    from rpc_clients import manager
    manager.run(host, port, mode)
Example #4
0
def runclient(argset=[], **kwargs):
    # Get the options
    options = CLIENT_OPTIONS.copy()
    options.update(kwargs)

    from net.aircable.utils import getLogger
    logger = getLogger(__name__)

    if options['daemonize']:
        if not options['pidfile']:
            options['pidfile'] = '/var/run/openproximity_client_%s_%s.pid' % ( \
                options['mode'], options['port'] )

        logger.info("storing pid file in %s" % options['pidfile'])
        from django.utils.daemonize import become_daemon
        
        logger.info("daemonizing")
        become_daemon()
        logger.info("daemonized")

        fp = open(options['pidfile'], 'w')
        fp.write("%d\n" % os.getpid())
        fp.close()

    # Start the rpc server
    logger.debug('starting client with options %s' % options)
    mode = options['mode']
    host = options['host']
    port = int(options['port'])
    valid_modes=['scanner', 'uploader', 'pairing']
    from net.aircable.openproximity.pluginsystem import pluginsystem
    valid_modes.extend([ \
            i.provides['serverxr_type'] for i in \
                pluginsystem.get_plugins('serverxr')])
    if mode not in valid_modes:
        print "not a valid mode, use any of", valid_modes
        sys.exit(1)
    from rpc_clients import manager
    manager.run(host, port, mode)
Example #5
0
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation version 2 of the License.
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from django.conf import settings
from django.utils.translation import ugettext as _
from net.aircable.openproximity.signals import uploader as signals
from net.aircable.utils import getLogger
logger = getLogger(__name__)
from openproximity.models import *

from common import do_upload, is_known_dongle, isAIRcable, found_action

#from pickle import loads

import traceback

def handle(signal, *args, **kwargs):
    logger.info("uploader signal: %s" % signals.TEXT[signal])
    logl = LogLine()
    logl.content += signals.TEXT[signal]
    
    if signal == signals.SDP_RESOLVED:
        logl.content += ' %s:%s' %( kwargs['address'], kwargs['port'])
    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 socket
import dbus

from errors import *
from sppBase import *
from xml.dom.minidom import parseString
import net.aircable.sdp as sdp
import net.aircable.const as const

from net.aircable.utils import getLogger
logger=getLogger(__name__)

class sppClient(sppBase):
	target = None
	
	def __init__( self, target, 
                        channel = -1,
                        service = 'spp',
                        device  = None  ):
	    sppBase.__init__(self, 
			    channel = channel, 
			    service = service, 
			    device  = device);
	    logger.info("sppClient.__init__")
	    logger.info("target: %s" % target )
	    self.target = target