API documentation

pyquickshare

Quick Share implementation in Python.

class pyquickshare.ShareRequest(header: PayloadHeader, pin: str)

Bases: object

Parameters:
  • header (offline_wire_formats_pb2.PayloadTransferFrame.PayloadHeader)

  • pin (str)

async accept() list[FileResult | TextResult | WifiResult]
Return type:

list[FileResult | TextResult | WifiResult]

async reject() None
Return type:

None

async pyquickshare.discover_services() AsyncIterator[AsyncServiceInfo]

Discover services on the network.

Example

async for service in discover_services():
    print(service)
Return type:

AsyncIterator[AsyncServiceInfo]

pyquickshare.generate_enpoint_id() bytes

Generate a random 4-byte endpoint ID.

Example

endpoint_id = generate_enpoint_id()
async for request in receive(endpoint_id=endpoint_id):
    ...
Returns:

The generated endpoint ID

Return type:

bytes

async pyquickshare.receive(*, endpoint_id: bytes | None = None) AsyncIterator[ShareRequest]

Receive something over Quick Share. Runs forever.

This function registers an mDNS service and opens a socket server to receive data. If firewalld is available, it temporarily reconfigures firewalld to allow incoming connections on the port.

Yields:

ShareRequest – A request to share something

Parameters:

endpoint_id (bytes | None)

Return type:

AsyncIterator[ShareRequest]

Example

async for request in receive():
    results = await request.accept()
    print(results)
async pyquickshare.send_to(service: AsyncServiceInfo, *, file: str) None

Send a file to a service.

Parameters:
  • service (AsyncServiceInfo) – The service to send the file to

  • file (str) – The file to send

Return type:

None

pyquickshare.results

Objects that represent the results of Quick Share operations.

class pyquickshare.results.FileResult(name, path, size)

Bases: NamedTuple

Parameters:
name: str

Alias for field number 0

path: str

Alias for field number 1

size: int

Alias for field number 2

class pyquickshare.results.TextResult(title, text)

Bases: NamedTuple

Parameters:
text: str

Alias for field number 1

title: str

Alias for field number 0

class pyquickshare.results.WifiResult(ssid, password, security_type)

Bases: NamedTuple

Parameters:
  • ssid (str)

  • password (str)

  • security_type (WifiCredentialsMetadata.SecurityType)

password: str

Alias for field number 1

security_type: WifiCredentialsMetadata.SecurityType

Alias for field number 2

ssid: str

Alias for field number 0