예제 #1
0
파일: teemon.py 프로젝트: Gpx/teemon
def get_connected_socket(use_default_socket):
    if not use_default_socket:
        service = lightblue.selectservice()
    else:
        service = DEFAULT_SERVICE

    if service == None:  # Used when user clicks on cancel
        sys.exit(0)

    socket = lightblue.socket()
    socket.connect((service[0], service[1]))
    signal.signal(signal.SIGINT, signal_handler)
    return socket
예제 #2
0
def main():
    """
    Usage: python obex_map_client.py [address channel]

    If the address and channel are not provided, the user will be prompted to
    choose a service.

    Once the client is connected, you can enter one of these commands:
        ls
        cd <directory>  (use '..' to change to parent, or '/' to change to root)
        put <file>
        get <file>
        rm <file>
        mkdir <directory>
        rmdir <directory>
        lsmsg [unread/read/both]
        getmsg <handle>
        setmsgread <handle>
        exit
        
    Some servers accept "/" path separators within the <file> or <filename> 
    arguments. Otherwise, you will have to just send either a single directory 
    or filename, without any paths.
    """
    if len(sys.argv) > 1:
        address = sys.argv[1]
        channel = int(sys.argv[2])
    else:
        # ask user to choose a service
        address, channel, servicename = lightblue.selectservice()
    print 'Connecting to %s on channel %d...' % (address, channel)

    mapclient = MAPClient(address, channel)
    mapclient.connect()
    print 'Connected.'

    try:
        processcommands(mapclient)
    finally:
        try:
            mapclient.disconnect()
        except Exception, e:
            print "Error while disconnecting:", e
            pass
예제 #3
0
def main():
    """
    Usage: python obex_ftp_client.py [address channel]

    If the address and channel are not provided, the user will be prompted to
    choose a service.

    Once the client is connected, you can enter one of these commands:
        ls
        cd <directory>  (use '..' to change to parent, or '/' to change to root)
        put <file>
        get <file>
        rm <file>
        mkdir <directory>
        rmdir <directory>
        exit
        
    Some servers accept "/" path separators within the <file> or <filename> 
    arguments. Otherwise, you will have to just send either a single directory 
    or filename, without any paths.
    """
    if len(sys.argv) > 1:
        address = sys.argv[1]
        channel = int(sys.argv[2])
    else:
        # ask user to choose a service
        # a FTP service is usually called 'FTP', 'OBEX File Transfer', etc.
        address, channel, servicename = lightblue.selectservice()
    print 'Connecting to %s on channel %d...' % (address, channel)

    ftpclient = FTPClient(address, channel)
    ftpclient.connect()
    print 'Connected.'

    try:
        processcommands(ftpclient)
    finally:
        try:
            ftpclient.disconnect()
        except Exception, e:
            print "Error while disconnecting:", e
            pass
예제 #4
0
"""
Shows how to send a file over OBEX.
"""

import lightblue
import sys

if len(sys.argv) == 1:
    print "Usage: file_send.py [filename]"
    sys.exit(1)

sourcefile = sys.argv[1]

# Ask user to choose the device and service to send the file to.
address, serviceport, servicename = lightblue.selectservice()

# Send the file
lightblue.obex.sendfile(address, serviceport, sourcefile)

print "Done!"


# Note:
# Instead of calling selectservice(), you could do:
#
#     services = lightblue.findservices(addr=lightblue.selectdevice()[0],
#                                       servicetype=lightblue.OBEX)
#     address, serviceport, servicename = services[0]
#     lightblue.obex.sendfile(address, serviceport, sourcefile)
#
# This will ask the user to select a device, and then just send the file to the
예제 #5
0
파일: file_send.py 프로젝트: pemar/lahacks
"""
Shows how to send a file over OBEX.
"""

import lightblue
import sys

if len(sys.argv) == 1:
    print "Usage: file_send.py [filename]"
    sys.exit(1)

sourcefile = sys.argv[1]

# Ask user to choose the device and service to send the file to.
address, serviceport, servicename = lightblue.selectservice()

# Send the file
lightblue.obex.sendfile(address, serviceport, sourcefile)

print "Done!"

# Note:
# Instead of calling selectservice(), you could do:
#
#     services = lightblue.findservices(addr=lightblue.selectdevice()[0],
#                                       servicetype=lightblue.OBEX)
#     address, serviceport, servicename = services[0]
#     lightblue.obex.sendfile(address, serviceport, sourcefile)
#
# This will ask the user to select a device, and then just send the file to the
# first OBEX service found on that device. Then you don't have to ask the