Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

knx: Plugin not working with password protected ETS5 projects #523

Closed
CaeruleusAqua opened this issue Sep 3, 2021 · 7 comments
Closed
Assignees

Comments

@CaeruleusAqua
Copy link
Contributor

CaeruleusAqua commented Sep 3, 2021

The project cant't be loaded because the P-<ABCD> Folder is a password protected ZIP file, instead of a folder.
So "_parse_knxproject" failes with "No project file found to examine"

@CaeruleusAqua
Copy link
Contributor Author

This works for me:

    knxproj = zipfile.ZipFile(filename, 'r')

    # see which project files can be found
    subprojects = []
    for file in knxproj.filelist:
        print(file)
        if file.filename[0] != 'P':
            continue

        # According to Project Schema Description, page 41 future files can be named [0...16].xml
        if file.filename.split("/")[-1] != '0.xml':
            continue
        subprojects.append(file)
        logger.debug("Subfile '{}' found".format(file))

    zipped_subprojects = []
    for file in knxproj.filelist:
        print(file)
        if file.filename[0] != 'P':
            continue

        # According to Project Schema Description, page 41 future files can be named [0...16].xml
        if not file.filename.endswith('.zip'):
            continue
        zipped_subprojects.append(file)
        logger.debug("Zipped Subfile '{}' found".format(file))

    if len(subprojects) == 0 and len(zipped_subprojects) == 0:
        logger.error("No project file found to examine")
        return None

    if len(subprojects) > 1 or len(zipped_subprojects) > 1:
        logger.error("More than one project file found to examine, giving up!")
        return None

    xmlfile = None
    
    if (len(subprojects) == 0):
        zipped_subproject = knxproj.open(zipped_subprojects[0].filename)
        subproject = zipfile.ZipFile(zipped_subproject, 'r')
        print("subproject")
        print(subproject)
        for file in subproject.filelist:
            # According to Project Schema Description, page 41 future files can be named [0...16].xml
            if file.filename.split("/")[-1] != '0.xml':
                continue
            xmlfile = subproject.open(file.filename, pwd=b"YourPassword")
            break

    else:
        xmlfile = knxproj.open(subprojects[0].filename)

    xmldict = xmltodict.parse(xmlfile.read())

Someone may add the infrastructure for the password.. ;-)

@bmxp bmxp self-assigned this Sep 4, 2021
@bmxp
Copy link
Member

bmxp commented Sep 21, 2021

Some questions:
Should the password provided when uploading the knxproj file?
Or should it be kept within plugins config?
Or aside from upload put into an item for storage with cache keyword?

@CaeruleusAqua
Copy link
Contributor Author

I think it should be requested when uploading.

@bmxp
Copy link
Member

bmxp commented Oct 8, 2021

That means you have to send the password first to the plugin before the knxproj file can be read...?

Any other ideas?

@msinn msinn changed the title KNX-Plugin not working with password protected ETS5 projects knx: Plugin not working with password protected ETS5 projects Dec 23, 2021
@bmxp
Copy link
Member

bmxp commented Dec 26, 2021

@CaeruleusAqua
There is an updated knx plugin in develop which has the possibility to provide a password when uploading a knxproj file.
The password is the saved within the knx plugin until SHNG stops. It will be lost after a restart of SHNG and it needs to provide it again with another upload.
If the password provided with using the upload is empty then an existing password within the plugin will not be overwritten.

@bmxp
Copy link
Member

bmxp commented Jan 28, 2022

@CaeruleusAqua did you try the new version?

@bmxp bmxp closed this as completed Jan 28, 2022
@CaeruleusAqua
Copy link
Contributor Author

Sorry for the long wait. Just have to do well with house construction and my daughter ;-).
The new version is running fine.

Greetings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants