Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

some Python script errors

‎03-25-2019 08:00 PM

Hi all

The following Python script (dev.facts) works fine. But when running the script, it gives some messages or errors in red color below.... Any ideas about how to get rid of this messages/errors?

 

from jnpr.junos import Device
from getpass import getpass
import sys

hostname = input("Device hostname: ")
username = input("Device username: ")
password = getpass("Device password: ")

# NETCONF session over SSH
dev = Device(host=hostname, user=username, passwd=password)

try:
  dev.open()
except Exception as err:
   print (err)
   sys.exit(1)
print (dev.facts)

dev.close()

exit()

--------------------------------------------------------------------------------------------------------

C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.
m.add_string(self.Q_C.public_numbers().encode_point())
C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\kex_ecdh_nist.py:96: CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point
self.curve, Q_S_bytes
C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\kex_ecdh_nist.py:111: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.
hm.add_string(self.Q_C.public_numbers().encode_point())
C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\ecdsakey.py:164: CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point
self.ecdsa_curve.curve_class(), pointinfof

 

Thanks,

Rimix

 

2 REPLIES 2
Highlighted
Junos Automation (Scripting)

Re: some Python script errors

‎03-25-2019 09:06 PM

This errror is specific to Paramiko on Windows.

 

There are a number of ways to work around it - but the simplest is probably to filter the error with the following code:

 

import warnings

warnings.simplefilter("ignore", cryptography.utils.CryptographyDeprecationWarning)

Hope this helps!

Ben Dale
JNCIP-ENT, JNCIP-SP, JNCIP-DC, JNCIE-SEC #63
Juniper Ambassador
Follow me @labelswitcher
Highlighted
Junos Automation (Scripting)

Re: some Python script errors

‎04-03-2019 07:21 AM

Hi Ben.

 

Those Paramiko warning messages were thrashing my script outputs as well.

 

Many thanks for tip how to get rid of them.

 

Regards
Luděk Matoušek
JNCIS-ENT, JNCIS-SP, JNCIP-SEC, JNCIA-DevOps