platypush/plugins/bluetooth/__init__.py
def send_file(self, filename: str, device: str, port: int = None, data=None, service_name='OBEX Object Push',
                  binary: bool = False):
        """
        Send a local file to a device that exposes an OBEX Object Push service

        :param filename: Path of the file to be sent
        :param data: Alternatively to a file on disk you can send raw (string or binary) content
        :param device: Device address or name
        :param port: Port number
        :param service_name: Service name
        :param binary: Set to true if data is a base64-encoded binary string
        """
        from PyOBEX.client import Client

        if not data:
            filename = os.path.abspath(os.path.expanduser(filename))
            with open(filename, 'r') as f:
                data = f.read()
            filename = os.path.basename(filename)
        else:
            if binary:
                data = base64.decodebytes(data.encode() if isinstance(data, str) else data)

        addr, port, protocol = self._get_addr_port_protocol(device=device, port=port,
                                                            service_name=service_name)

        client = Client(addr, port)
        self.logger.info('Connecting to device {}'.format(addr))
        client.connect()
        self.logger.info('Sending file {} to device {}'.format(filename, addr))
        client.put(filename, data)
        self.logger.info('File {} sent to device {}'.format(filename, addr))
        client.disconnect()

        Send a local file to a device that exposes an OBEX Object Push service

        :param filename: Path of the file to be sent
        :param data: Alternatively to a file on disk you can send raw (string or binary) content
        :param device: Device address or name
        :param port: Port number
        :param service_name: Service name
        :param binary: Set to true if data is a base64-encoded binary string
        
Send a local file to a device that exposes an OBEX Object Push service
Send a local file to a device that exposes an OBEX Object Push service
def send_file(self, filename: str, device: str, port: int = None, data=None, service_name='OBEX Object Push',
                  binary: bool = False):
        from PyOBEX.client import Client
        if not data:
            filename = os.path.abspath(os.path.expanduser(filename))
            with open(filename, 'r') as f:
                data = f.read()
            filename = os.path.basename(filename)
        else:
            if binary:
                data = base64.decodebytes(data.encode() if isinstance(data, str) else data)
        addr, port, protocol = self._get_addr_port_protocol(device=device, port=port,
                                                            service_name=service_name)
        client = Client(addr, port)
        self.logger.info('Connecting to device {}'.format(addr))
        client.connect()
        self.logger.info('Sending file {} to device {}'.format(filename, addr))
        client.put(filename, data)
        self.logger.info('File {} sent to device {}'.format(filename, addr))
        client.disconnect()
def send_file ( self , filename : str , device : str , port : int = None , data = None , service_name = 'OBEX Object Push' , binary : bool = False ) : from PyOBEX . client import Client if not data : filename = os . path . abspath ( os . path . expanduser ( filename ) ) with open ( filename , 'r' ) as f : data = f . read ( ) filename = os . path . basename ( filename ) else : if binary : data = base64 . decodebytes ( data . encode ( ) if isinstance ( data , str ) else data ) addr , port , protocol = self . _get_addr_port_protocol ( device = device , port = port , service_name = service_name ) client = Client ( addr , port ) self . logger . info ( 'Connecting to device {}' . format ( addr ) ) client . connect ( ) self . logger . info ( 'Sending file {} to device {}' . format ( filename , addr ) ) client . put ( filename , data ) self . logger . info ( 'File {} sent to device {}' . format ( filename , addr ) ) client . disconnect ( )
Send a local file to a device that exposes an OBEX Object Push service
Send a local file to a device that exposes an OBEX Object Push service
"""
        Send a local file to a device that exposes an OBEX Object Push service

        :param filename: Path of the file to be sent
        :param data: Alternatively to a file on disk you can send raw (string or binary) content
        :param device: Device address or name
        :param port: Port number
        :param service_name: Service name
        :param binary: Set to true if data is a base64-encoded binary string
        """
self
filename
str
Path of the file to be sent
Path of the file to be sent
device
str
Device address or name
Device address or name
port
int
None
data
Alternatively to a file on disk you can send raw (string or binary) content
Alternatively to a file on disk you can send raw ( string or binary ) content
service_name
None
binary
bool
Set to true if data is a base64-encoded binary string
Set to true if data is a base64 - encoded binary string