python - Changing KWArgs format with import module method -


hello pythoner's (yeah doesn't sound clean let's go it),

i have issue need assistance with. trying automate network using couple of cool modules, have run 2 issue's don't know how address.

import netmiko import json getpass2 import getpass      def username():         netmiko.baseconnection.__init__         (         ip=raw_input("enter ip:"),         username=raw_input("enter username:"),         password=raw_input("enter password:"),         secret=raw_input("enter secret:"),         port=raw_input('enter ssh port #:')         try:            return int(netmiko.baseconnection.__init__(port))         except            str(port):         ) 

my apologies formatting if isn't best practice. trying reference port kwarg in __init__ namespace validate user input integer value instead of string. however, keeps stating "unresolved reference 'port'" in pycharm ide. how should best address this?

i keep code structured way if possible, reason being security reasons not have clear text passwords stored in code. way have structured allows me have variable directly handle value user input, makes application self-maintaining in sense, in other words, don't have keep updating when credentials change.

the second concept explained me if possible, how can leverage getpass module's methods used in password prompt password=raw_input("enter password:"),. allow user not susceptible shoulder surfing attack, can see users password in plain text. i'm not sure how leverage different module's methods separate module's kwarg in function? if make's sense, believe need known declaration merging, i'm not sure if indeed needed or appropriate.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -