Skip to content

Instantly share code, notes, and snippets.

@blue-bird1
Last active October 9, 2018 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blue-bird1/60264ea1d9057db8fe68c2adb594de24 to your computer and use it in GitHub Desktop.
Save blue-bird1/60264ea1d9057db8fe68c2adb594de24 to your computer and use it in GitHub Desktop.
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