In step 1, we pull the necessary Python standard library and PyEZ framework definitions into the global namespace so that we can make use of them. And then in step 2, we establish a general-purpose handler routine that should be called if any exceptions are thrown.
In step 3, we pick apart the command-line arguments with arpgarse help. We’re configured to recognise switches to define the user name and the destination TCP port for the NETCONF over SSH session. Then the extra parameters after the switches are the target hostname, and the actual command line – in quotation marks – respectively:
unix$ ./pyez-command-line.py -husage: pyez-command-line.py [-h] [-p port] [-u username] target commandPython JUNOS PyEZ Command Line Tool ...