Skip to content

Commit

Permalink
cmd: ipdata ok
Browse files Browse the repository at this point in the history
  • Loading branch information
p-l- committed Nov 15, 2015
1 parent 812909c commit 9bf9c4f
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions ivre/tools/ipdata.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,34 @@
"""

import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import os
try:
import argparse
USING_ARGPARSE = True
except ImportError:
import optparse
USING_ARGPARSE = False

import ivre.db
import ivre.geoiputils
import ivre.config

if __name__ == '__main__':
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import os
try:
import argparse
parser = argparse.ArgumentParser(
description=__doc__)
USING_ARGPARSE = True
except ImportError:
import optparse
def main():
if USING_ARGPARSE:
parser = argparse.ArgumentParser(description=__doc__)
else:
parser = optparse.OptionParser(
description=__doc__)
parser.parse_args_orig = parser.parse_args

def my_parse_args():
res = parser.parse_args_orig()
res[0].ensure_value('ip', res[1])
return res[0]
parser.parse_args = my_parse_args
parser.add_argument = parser.add_option
USING_ARGPARSE = False
TORUN = []
parser.add_argument('--init', '--purgedb', action='store_true',
help='Purge or create and initialize the database.')
Expand Down

0 comments on commit 9bf9c4f

Please sign in to comment.