Coder Social home page Coder Social logo

sdk-samples's People

Contributors

amickel avatar clintberger avatar ctrlaltelite2012 avatar dapplegatecp avatar gregular avatar hbreauxv avatar lreese avatar mrtonyg avatar nathanwiens avatar phate999 avatar shawndfisher avatar sshresthacp avatar tsnuggs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-samples's Issues

cs.put strips spaces in values

value = json.dumps(value).replace(' ', '')

I'm curious about why this is here? this prevents cs.put any values with spaces. One such legitimate case is in certificate management where the certificates will always begin -----BEGIN CERTIFICATE----- etc

My particular case I'm putting certificates to certmgmt, but the certs were corrupt. I commented this line out and cs.put worked correctly.

Bugs in singleton and signal handling for csclient

csclient registers a signal handler for SIGTERM, which cleans up EventingCSClient and then exits with 0.

def clean_up_reg(signal, frame):
"""
When 'cppython remote_port_forward.py' gets a SIGTERM, config_store_receiver.py doesn't
clean up registrations. Even if it did, the comm module can't rely on an external service
to clean up.
"""
EventingCSClient('CSClient').stop()
sys.exit(0)
signal.signal(signal.SIGTERM, clean_up_reg)

In reality, it creates a NEW EventingCSClient (with a new registry) and calls stop on it. If there is already a singleton with the exact class EventingCSClient, it will use that one instead. If there is a subclass of EventingCSClient, it will not use that one, because of how the singleton lookup works.

There is also a misunderstanding of how __init__ works. The __init__ function is called on the result of __new__ even if the object was already initialized. That means the signal handler will replace the registry before it cleans it up.

Sample code demonstrating the double init:

class A:
    _instances = {}
    def __new__(cls, *na, **kwna):
        """ Singleton factory (with subclassing support) """
        try: instance = cls._instances[cls]
        except KeyError: instance = cls._instances[cls] = super().__new__(cls)
        return instance

class B(A):
    def __init__(self, value):
        self.value = value
        print('init', value)

b0 = B('first')          # init first
b1 = B('second')         # init second
print(f"{b0 is b1 = }")  # b0 is b1 = True
print(f"{b0.value = }")  # b0.value = 'second'

If there is no object with exact class EventingCSClient, the stop() call will crash when it tries to access self.event_sock, because that is only created by the start call, not for a fresh new object.

What is the intent of this signal handler? It refers to "remote_port_forward.py" and "config_store_receiver.py", neither of which are in this repo.

Turning a SIGTERM into a SystemExit(0) changes the behavior of applications. For example, non-daemon threads can ignore SystemExit but not SIGTERM. Is that intentional?

make.py install fails on MacOS

The result of attempting to install an SDK script on a device is the following:

Warning: Permanently added '192.168.0.1' (RSA) to the list of known hosts.
subsystem request failed on channel 0
scp: Connection closed```

I can check the status and do other things but not install the SDK script on the device I use for testing. It doesn't matter which device; I've tried several devices and models.

MacOS version: Ventura 13.5

upload cs.py to pypi as a pip installable package

Please package the library as a pip install-able package and upload to pypi. Alternatively you can change the licensce to make it open source and I can take care of it. I'll be uploading it to my internal artifactory pypi instance for now.

Carriage return (CR) handling is burdensome

I checkout'd and tried to run make package, and it broke because it detected CR in the sample code that I cloned. This puts unnecessary burden on the user just to test the code, because I'd have to know in the first place to clone it with non-default Git settings.

Instead, it should make copies without the carriage returns, and then build off of those.

I think the Python interpreter doesn't even care about CRs in source code.

Also, this code inefficiently reads every file, whether or not it cares about that file:

def scan_for_cr(path):
    scanfiles = ('.py', '.sh')
    for root, _, files in os.walk(path):
        for fl in files:
            with open(os.path.join(root, fl), 'rb') as f:
                if b'\r' in f.read() and [x for x in scanfiles if fl.endswith(x)]:
                    raise Exception('Carriage return (\\r) found in file %s' % (os.path.join(root, fl)))

It should at least do the scanfiles check first.

def scan_for_cr(path):
    scanfiles = ('.py', '.sh')
    for root, _, files in os.walk(path):
        for fl in files:
            if any(fl.endswith(x) for x in scanfiles):
                with open(os.path.join(root, fl), 'rb') as f:
                    if b'\r' in f.read():
                        raise Exception('Carriage return (\\r) found in file %s' % (os.path.join(root, fl)))

Missed variable in delete function in REST API calles

Hello,

This is my first issue report in github, please consider my humble report,
In sdk\app_template_csclient\csclient script code, delete function needs a variable called value in parameters:

                                           def delete(self, base, query=''):

It should be like:

                                   def delete(self, base, value='', query=''):

I think this issue can be found in other csclient files in other directories.

Regards,

Omar

Ookla speed test server selection

Hi, the Cradlepoint speed test use the Ookla servers randomly, that mean the speed test aren't consistent, can't be used for tests. For a true speed test you need to use the same server for each time. Is it possible to choose Ookla server as in web or mobile interface with this app?
Kind regards

ValueError on version increment

cp_lib/split_version.py split_version_string returns major,minor,patch, but tools/make_load_settings.py only expects it to return major,minor, resulting in "ValueError: too many values to unpack (expected 2)" when attempting to have the version auto-incremented on build
Also, version major/minor/patch is not included in the generated version in increment_app_version::_do_my_tweak

Review: CSClient.get doc inconsistent with behavior

The docstring says it returns the {success, data} dict.

Returns:
A dictionary containing the response (i.e. {"success": True, "data:": {}}

However, the code unwraps the dict and only returns the data value.

return self._dispatch(cmd).get('data')
return json.loads(response.text).get('data')

Other potential improvements:

  • Check success.
  • Use response.json() instead of json.loads(response.text).

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.