Last active
October 9, 2018 23:14
-
-
Save blue-bird1/60264ea1d9057db8fe68c2adb594de24 to your computer and use it in GitHub Desktop.
optparse #python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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