You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Netbox does not have a single root netbox package so anything inside netbox/ will be considered a separate package in Python. For example the secets package in Netbox conflicts with Python standard library secrets.
Environment
Python version: 3.7.7
NetBox version: 2.8.1
Steps to Reproduce
Create a new custom script 1-test.py
import secrets
class SecretScript(Script):
def run(self, data):
self.log_success(secrets.token_hex())
Browse to the script from web ui http://localhost/extras/scripts/1-test/SecretScript/
Hit Run Script button
Expected Behavior
A success log with the message containing a random hex string, similar to
I discovered this while trying to build a Python package that our custom scripts will use. Having all directories under netbox/ be their own top level packages make imports a bit awkward as Netbox rely on its own secrets package for example.
Would it be possible to have a structure like netbox.secrets instead?
Fun fact: NetBox predates the standard secrets library, which was introduced in Python 3.6. We recently had to work around this conflict to accommodate a recent Django release, which you can see here.
Unfortunately, I'm not sure there's a palatable solution to this problem. We would need to rename the secrets app, which obviously would be quite disruptive and probably not worth the negligible gain.
I'm going to close this issue as I don't think there's anything actionable in the immediate future. Might be worth revisiting down the road but unless the conflict escalates to a serious problem, renaming the app is unlikely to be worth the disruption to users.
Netbox does not have a single root
netbox
package so anything insidenetbox/
will be considered a separate package in Python. For example thesecets
package in Netbox conflicts with Python standard librarysecrets
.Environment
Steps to Reproduce
1-test.py
http://localhost/extras/scripts/1-test/SecretScript/
Run Script
buttonExpected Behavior
A
success
log with the message containing a random hex string, similar toObserved Behavior
Exception:
An exception occurred: AttributeError: module 'secrets' has no attribute 'token_hex'
The text was updated successfully, but these errors were encountered: