~debian-lptools/debian/sid/lptools/sid

« back to all changes in this revision

Viewing changes to bin/lp-shell

  • Committer: Jelmer Vernooij
  • Date: 2023-09-28 12:07:22 UTC
  • mfrom: (2.18.8)
  • Revision ID: jelmer@jelmer.uk-20230928120722-704pws90v7e943dk
* New upstream snapshot.
 + Drop patches for conversion to python 3 and breezy; now merged upstream.
+ debian/upstream/metadata: Drop unknown Homepage field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
 
1
#!/usr/bin/python3
2
2
 
3
3
# Open an interactive launchpadlib Python shell.
4
4
# It supports all known LP service instances and API versions. The login
52
52
    if len(args) >= 1:
53
53
        try:
54
54
            instance = lookup_service_root(args[0])
55
 
        except ValueError, err:
56
 
            print 'E: %s' % (err)
57
 
            print 'I: Falling back to "production".'
 
55
        except ValueError as err:
 
56
            print('E: %s' % (err))
 
57
            print('I: Falling back to "production".')
58
58
 
59
59
    if len(args) >= 2:
60
60
        if args[1] in valid_api_versions:
61
61
            api_version = args[1]
62
62
        else:
63
 
            print 'E: "%s" is not a valid LP API version.' % (args[1])
64
 
            print 'I: Falling back to "1.0".'
 
63
            print('E: "%s" is not a valid LP API version.' % (args[1]))
 
64
            print('I: Falling back to "1.0".')
65
65
 
66
66
    if options.anonymous:
67
67
        launchpad = Launchpad.login_anonymously('lp-shell', instance,
84
84
    if options.shell == "ipython":
85
85
        try:
86
86
            try: # ipython >= 0.11
87
 
                from IPython.frontend.terminal.embed import InteractiveShellEmbed
 
87
                from IPython.terminal.embed import InteractiveShellEmbed
88
88
                sh = InteractiveShellEmbed(banner2=banner, user_ns={'lp': launchpad})
89
89
            except ImportError: # ipython < 0.11
90
90
                # pylint does not handle nested try-except, disable import error
94
94
                sh.set_banner(sh.IP.BANNER + '\n' + banner)
95
95
            sh.excepthook = sys.__excepthook__
96
96
        except ImportError:
97
 
            print "E: ipython not available. Using normal python shell."
 
97
            print("E: ipython not available. Using normal python shell.")
98
98
 
99
99
    if sh:
100
100
        sh()
106
106
                try:
107
107
                    import readline
108
108
                except ImportError:
109
 
                    print 'I: readline module not available.'
 
109
                    print('I: readline module not available.')
110
110
                else:
111
111
                    import rlcompleter
112
112
                    readline.parse_and_bind("tab: complete")