Skip to content

Instantly share code, notes, and snippets.

@blue-bird1
Last active Oct 9, 2018
Embed
What would you like to do?
optparse #python
from optparse import OptionParser, OptionGroup, OptionError
try:
from setting import IS_WIN
except ImportError as e:
errmsg = e.message.split('named')[0]
print errmsg
exit()
def cmdLineParser(argv=None):
"""
This function parses the command line parameters and arguments
"""
if not argv:
argv = sys.argv
parser = OptionParser()
try:
return parser
except (OptionError, TypeError) as e:
parser.error(e)
except SystemExit:
# Protection against Windows dummy double clicking
if IS_WIN:
print("\nPress Enter to continue...")
raw_input()
raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment