cradlepoint / sdk-samples Goto Github PK
View Code? Open in Web Editor NEWCradlepoint team sample code and tools
License: Other
Cradlepoint team sample code and tools
License: Other
sdk-samples/app_template/cs.py
Line 117 in 82d855d
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.
csclient registers a signal handler for SIGTERM, which cleans up EventingCSClient and then exits with 0.
sdk-samples/app_template_csclient/csclient.py
Lines 598 to 608 in 5f4ce85
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?
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
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.
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)))
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
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
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
The docstring says it returns the {success, data}
dict.
sdk-samples/app_template_csclient/csclient.py
Lines 90 to 91 in 293de9b
However, the code unwraps the dict and only returns the data value.
sdk-samples/app_template_csclient/csclient.py
Line 111 in 293de9b
Other potential improvements:
success
.response.json()
instead of json.loads(response.text)
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.