예제 #1
0
파일: _obex.py 프로젝트: pemar/lahacks
def sendfile(address, channel, source):
    if not isinstance(source, (types.StringTypes, types.FileType)):
        raise TypeError("source must be string or built-in file object")

    if isinstance(source, types.StringTypes):
        try:
            _socket.bt_obex_send_file(address, channel, unicode(source))
        except Exception, e:
            raise OBEXError(str(e))
def bt_send():
    device = socket.bt_obex_discover()
    print 'device:', device
    address = device[0]
    print 'address:', address
    channel = device[1][u'OBEX Object Push']
    print 'channel:', channel
    socket.bt_obex_send_file(address, channel, file)
    appuifw.note(u"Image sent!", "info")
예제 #3
0
파일: _obex.py 프로젝트: lhl/blueball
def sendfile(address, channel, source):
    if not isinstance(source, (types.StringTypes, types.FileType)):
        raise TypeError("source must be string or built-in file object")
        
    if isinstance(source, types.StringTypes):
        try:
            _socket.bt_obex_send_file(address, channel, unicode(source))
        except Exception, e:
            raise OBEXError(str(e))
예제 #4
0
def bt_send():
    file=(u'e:\\Images\\picture1.jpg')
    device=socket.bt_obex_discover()
    print 'device:', device 
    address=device[0]
    print 'address:', address 
    channel=device[1][u'OBEX Object Push']
    print 'channel:', channel 
    socket.bt_obex_send_file(address,channel,file)
    appuifw.note(u"Picture sent","info")
예제 #5
0
def start():
    image= camera.take_photo()
    appuifw.app.body=c=appuifw.Canvas()
    c.blit(image,scale=1)
    file=(u'e:\\Images\\picture1.jpg')
    image.save(file)
    device=socket.bt_obex_discover()
    address=device[0]
    channel=device[1][u'OBEX Object Push']
    socket.bt_obex_send_file(address,channel,file)
    appuifw.note(u"Picture sent","info")
예제 #6
0
def start():
    image = camera.take_photo()
    appuifw.app.body = c = appuifw.Canvas()
    c.blit(image, scale=1)
    file = u"e:\\Images\\Image.jpg"
    image.save(file)
    device = socket.bt_obex_discover()
    address = device[0]
    channel = device[1][u"OBEX Object Push"]
    socket.bt_obex_send_file(address, channel, file)
    appuifw.note(u"Picture sent", "info")
예제 #7
0
def send_photo():
    try:
        address, services = socket.bt_obex_discover()
    except:
        appuifw.note(u"OBEX Push not available", "error")
        return

    if u'OBEX Object Push' in services:
        channel = services[u'OBEX Object Push']
        socket.bt_obex_send_file(address, channel, PHOTO)
        appuifw.note(u"photo sent", "info")
    else:
        appuifw.note(u"OBEX Push not available", "error")
예제 #8
0
파일: _obex.py 프로젝트: pemar/lahacks
        except Exception, e:
            raise OBEXError(str(e))
    else:
        # given file object
        if hasattr(source, "name"):
            localpath = _tempfilename(source.name)
        else:
            localpath = _tempfilename()

        try:
            # write the source file object's data into a file, then send it
            f = file(localpath, "wb")
            f.write(source.read())
            f.close()
            try:
                _socket.bt_obex_send_file(address, channel, unicode(localpath))
            except Exception, e:
                raise OBEXError(str(e))
        finally:
            # remove temporary file
            if os.path.isfile(localpath):
                try:
                    os.remove(localpath)
                except Exception, e:
                    print "[lightblue.obex] unable to remove temporary file %s: %s" %\
                        (localpath, str(e))


def recvfile(sock, dest):
    if not isinstance(dest, (types.StringTypes, types.FileType)):
        raise TypeError("dest must be string or built-in file object")
예제 #9
0
파일: _obex.py 프로젝트: lhl/blueball
        except Exception, e:
            raise OBEXError(str(e))
    else:
        # given file object
        if hasattr(source, "name"):
            localpath = _tempfilename(source.name)
        else:
            localpath = _tempfilename()
        
        try:
            # write the source file object's data into a file, then send it
            f = file(localpath, "wb")
            f.write(source.read())
            f.close()
            try:            
                _socket.bt_obex_send_file(address, channel, unicode(localpath))
            except Exception, e:
                raise OBEXError(str(e))                
        finally:
            # remove temporary file
            if os.path.isfile(localpath):
                try:
                    os.remove(localpath)
                except Exception, e:
                    print "[lightblue.obex] unable to remove temporary file %s: %s" %\
                        (localpath, str(e))

def recvfile(sock, dest):
    if not isinstance(dest, (types.StringTypes, types.FileType)):
        raise TypeError("dest must be string or built-in file object")