Switch to unified view

a/migrate-3rdparty/allura_import.py b/migrate-3rdparty/allura_import.py
...
...
15
Import project data dump in JSON format into Allura project.''')
15
Import project data dump in JSON format into Allura project.''')
16
    optparser.add_option('-a', '--api-key', dest='api_key', help='API key')
16
    optparser.add_option('-a', '--api-key', dest='api_key', help='API key')
17
    optparser.add_option('-s', '--secret-key', dest='secret_key', help='Secret key')
17
    optparser.add_option('-s', '--secret-key', dest='secret_key', help='Secret key')
18
    optparser.add_option('-u', '--base-url', dest='base_url', default='https://sourceforge.net', help='Base Allura URL (%default)')
18
    optparser.add_option('-u', '--base-url', dest='base_url', default='https://sourceforge.net', help='Base Allura URL (%default)')
19
    optparser.add_option('--validate', dest='validate', action='store_true', help='Validate import data')
19
    optparser.add_option('--validate', dest='validate', action='store_true', help='Validate import data')
20
    optparser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='Verbose operation')
20
    options, args = optparser.parse_args()
21
    options, args = optparser.parse_args()
21
    if len(args) != 1:
22
    if len(args) != 1:
22
        optparser.error("Wrong number of arguments.")
23
        optparser.error("Wrong number of arguments.")
23
    if not options.api_key or not options.secret_key:
24
    if not options.api_key or not options.secret_key:
24
        optparser.error("Keys are required.")
25
        optparser.error("Keys are required.")
...
...
46
47
47
        try:
48
        try:
48
            result = urllib2.urlopen(url, urllib.urlencode(params))
49
            result = urllib2.urlopen(url, urllib.urlencode(params))
49
            return result.read()
50
            return result.read()
50
        except urllib2.HTTPError, e:
51
        except urllib2.HTTPError, e:
52
            if options.verbose:
51
            error_content = e.read()
53
                error_content = e.read()
52
            e.msg += '. Error response:\n' + error_content
54
                e.msg += '. Error response:\n' + error_content
53
            raise e
55
            raise e
54
56
55
    
57
    
56
if __name__ == '__main__':
58
if __name__ == '__main__':
57
    options, args = parse_options()
59
    options, args = parse_options()