Skip to content

Changing xcp.accessor API to explicitly specify text or binary mode #19

@ydirson

Description

@ydirson

Context: commit "WIP xcp.repository: switch from ConfigParser to configparser" in #17 (current shortcut: ydirson@6667fef). When adding python3 compatibility, we see some Accessor implementations (e.g. FileAccessor) provide a text stream, while others (e.g. HTTPAccessor) provide a binary
stream. This is a problem for code written to be compatible with arbitrary Accessor implementations, as demonstrated in additional unit tests in commits WIP test_accessor: check for I/O on binary files and WIP test_accessor: write into copy file as binary.

To be in line with file-opening conventions, Accessor.openAddress() should be made to accept a mode argument so client code can get what it expects without a need for hacks such as illustrated above. To make sure not-yet-reviewed/converted client code is caught red-handed, I would rather add this parameter as mandatory.

Identified client code to be reviewed/adjusted in lockstep include:

  • XAPI plugin prepare_host_upgrade (not in any public repo yet ?)
  • xcp.repository (internal dependency, not a problem)

Additionally, https://github.com/xenserver/host-installer contains a forked version of this code in repository.py (itself an advanced fork of xcp.repository).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions