Giter Site home page Giter Site logo

more than 255 arguments about pysmi HOT 8 CLOSED

etingof avatar etingof commented on August 28, 2024
more than 255 arguments

from pysmi.

Comments (8)

etingof avatar etingof commented on August 28, 2024

Thank you for raising this issue!

The fix is here, I'd appreciate your testing and reporting back how it worked for you. So I could merge that branch and make a release.

from pysmi.

cqhan777 avatar cqhan777 commented on August 28, 2024

from pysmi.

cqhan777 avatar cqhan777 commented on August 28, 2024

Hi Ilya,

The fix works in my case, but I don't why it would work. From the fix, it seems that cascading setObject() would result in only the last setObject() call being effective.

The source code for ObjectGroup class in SNMPv2_CONF.py looks like:

class ObjectGroup(MibNode):
objects = ()
description = ''

def getObjects(self):
    return getattr(self, 'objects', ())

def setObjects(self, *args):
    self.objects = args
    return self

def getDescription(self):
    return getattr(self, 'description', '')

def setDescription(self, v):
    self.description = v
    return self

So calling the setObjects() twice would void the first call. Did I miss something here?

Regards,
Kevin

from pysmi.

etingof avatar etingof commented on August 28, 2024

Hey Kevin,

The fix works in my case, but I don't why it would work. From the fix, it seems that cascading setObject() would result in only the last setObject() call being effective.

You are right, that's my bad!

I've reworked the pysmi implementation (564f845) and added the incremental objects adding mode to pysnmp (commit 1739070fb0702451a34608cf0c39c44bf1e09514).

I wonder if you could re-test those? ;-)

from pysmi.

cqhan777 avatar cqhan777 commented on August 28, 2024

Hi Ilya,

I see one potential problem: Line 412 (and others)

append=False)
wonder it should be
append=True

Also I wonder if you are changing the pysnmp code, why not just add a new funciton, something like
setObjectList( object_tuple), where the tuple object is the argument instead of expand it.

    def setObjectsList(self, list_args):
        self.objects = list_args
        return self   

Then in codegen/pysnmp.py

        objStr = ', '.join(objects)
        outStr = name + ' = NotificationGroup(' + oidStr + ')' + label + '\n'
        if getattr(mibBuilder, 'version', 0) < (4, 4, 2):
            outStr += name + '.objects = (' + objStr + ')\n'
        else:
            outStr += name + 'setObjectList((' + objStr + '))\n'

from pysmi.

etingof avatar etingof commented on August 28, 2024

I see one potential problem: Line 412 (and others)

Indeed! Fixed in 1d7ca20.

Also I wonder if you are changing the pysnmp code, why not just add a new funciton, something like
setObjectList( object_tuple), where the tuple object is the argument instead of expand it.

Yes, this is definitely another legitimate way.

I'm leaning towards kwargs because I expect that some other need for customizing those .set*() setters behavior may come up. Creating combinations of functions like setObjectList/setObjectSomethingElse might become tedious by some point.

Does it make sense?

Thanks!

from pysmi.

cqhan777 avatar cqhan777 commented on August 28, 2024

I'm OK with it. Thanks for fixing the problem!.

from pysmi.

etingof avatar etingof commented on August 28, 2024

Merged, thank you!

from pysmi.

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.