Coder Social home page Coder Social logo

Comments (7)

CaeruleusAqua avatar CaeruleusAqua commented on July 25, 2024

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.. ;-)

from plugins.

bmxp avatar bmxp commented on July 25, 2024

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?

from plugins.

CaeruleusAqua avatar CaeruleusAqua commented on July 25, 2024

I think it should be requested when uploading.

from plugins.

bmxp avatar bmxp commented on July 25, 2024

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

Any other ideas?

from plugins.

bmxp avatar bmxp commented on July 25, 2024

@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.

from plugins.

bmxp avatar bmxp commented on July 25, 2024

@CaeruleusAqua did you try the new version?

from plugins.

CaeruleusAqua avatar CaeruleusAqua commented on July 25, 2024

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

Greetings

from plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.