~ubuntu-branches/ubuntu/raring/software-center/raring-proposed

« back to all changes in this revision

Viewing changes to software-center

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2012-10-11 15:33:05 UTC
  • mfrom: (195.1.18 quantal)
  • Revision ID: package-import@ubuntu.com-20121011153305-fm5ln7if3rpzts4n
Tags: 5.4.1.1
* lp:~mvo/software-center/reinstall-previous-purchase-token-fix:
  - fix reinstall previous purchases that have a system-wide
    license key LP: #1065481
* lp:~mvo/software-center/lp1060106:
  - Add missing gettext init for utils/update-software-center-agent
    (LP: #1060106)

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
 
50
50
if __name__ == "__main__":
51
51
 
52
 
    parser = OptionParser("usage: %prog [options] [package-name | apturl | deb-file]", 
53
 
                          version="%prog "+VERSION)
 
52
    parser = OptionParser("usage: %prog [options] [package-name | apturl | "
 
53
                          "deb-file]", version="%prog " + VERSION)
54
54
    parser.add_option("--debug", action="store_true",
55
55
                      help="enable debug mode", default=False)
56
 
    parser.add_option("--debug-filter", 
 
56
    parser.add_option("--debug-filter",
57
57
                      help="show only specific messages. supported currently: "
58
58
                           "'softwarecenter.performance'")
59
59
    parser.add_option("--force-rtl", action="store_true",
60
 
                      help="force rtl mode (useful for debugging)", 
 
60
                      help="force rtl mode (useful for debugging)",
61
61
                      default=False)
62
62
    parser.add_option("--display-navlog", action="store_true",
63
 
                      help="display a navigation history log (useful for debugging)", 
64
 
                      default=False)
65
 
    # FIXME:  REMOVE THIS option once launchpad integration is enabled
66
 
    #         by default
67
 
    parser.add_option("--enable-lp", action="store_true",
68
 
                      help="enable launchpad integration (for development use)", 
69
 
                      default=False)
 
63
                      help="display a navigation history log (useful for "
 
64
                      "debugging)", default=False)
70
65
    parser.add_option("--disable-buy", action="store_true",
71
66
                      help="disable support to buy software",
72
67
                      default=False)
73
68
    parser.add_option("--disable-apt-xapian-index", action="store_true",
74
 
                      help="disable support for apt-xapian-index (technical items)",
75
 
                      default=False)
 
69
                      help="disable support for apt-xapian-index (technical "
 
70
                      "items)", default=False)
76
71
    parser.add_option("--measure-startup-time", action="store_true",
77
 
                      help="open and wait until the window is visible, then close, only useful for profiling",
78
 
                      default=False)
 
72
                      help="open and wait until the window is visible, "
 
73
                      "then close, only useful for profiling", default=False)
79
74
    parser.add_option("--dummy-backend", action="store_true",
80
 
                      help="run with a dummy backend, this will not actually install or remove anything and is useful for testing",
 
75
                      help="run with a dummy backend, this will not actually "
 
76
                      "install or remove anything and is useful for testing",
81
77
                      default=False)
82
78
    parser.add_option("--packagekit-backend", action="store_true",
83
 
                      help="use PackageKit backend (experimental)", 
 
79
                      help="use PackageKit backend (experimental)",
84
80
                      default=False)
85
81
    parser.add_option("--profile", action="store_true",
86
82
                      help="use cProfile to gather a profile dump for e.g. "
87
 
                           "kcachegrind, runsnake, gprof2dot", 
 
83
                           "kcachegrind, runsnake, gprof2dot",
88
84
                      default=False)
89
85
 
90
86
    (options, args) = parser.parse_args()
92
88
    # statup time measure implies "performance" in debug filters
93
89
    if options.measure_startup_time:
94
90
        options.debug_filter = "performance,traceback"
95
 
    
 
91
 
96
92
    if options.debug_filter:
97
93
        softwarecenter.log.add_filters_from_string(options.debug_filter)
98
94
        # implies general debug
99
95
        options.debug = True
100
 
        
 
96
 
101
97
    if options.debug:
102
98
        softwarecenter.log.root.setLevel(level=logging.DEBUG)
103
99
    else:
104
100
        softwarecenter.log.root.setLevel(level=logging.INFO)
105
 
    
 
101
 
106
102
    # packagekit
107
103
    if options.packagekit_backend:
108
104
        softwarecenter.enums.USE_PACKAGEKIT_BACKEND = True
111
107
    # dummy backend
112
108
    if options.dummy_backend:
113
109
        import atexit
114
 
        from softwarecenter.testutils import start_dummy_backend, stop_dummy_backend
 
110
        from softwarecenter.tests.utils import (
 
111
            start_dummy_backend,
 
112
            stop_dummy_backend)
115
113
        start_dummy_backend()
116
114
        atexit.register(stop_dummy_backend)
117
115
 
120
118
        Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL)
121
119
 
122
120
    # check if running locally
123
 
    (datadir, xapian_base_path) = mangle_paths_if_running_in_local_checkout()
 
121
    mangle_paths_if_running_in_local_checkout()
124
122
 
125
123
    # ensure we can actually run
126
124
    Gtk.init_check(sys.argv)
127
125
 
128
 
    # set default ssl-ca-file here because it needs only be set once, but
129
 
    # it can not be set in the global context as this will cause segfaults
130
 
    # on exit. However its IMPORTANT to set it as libsoup is *not* secure
131
 
    # by default (see bugzilla #666280 and #666276)
132
 
    from gi.repository import WebKit as webkit
133
 
    # enable certificates validation in webkit views unless specified otherwise
134
 
    if not "SOFTWARE_CENTER_FORCE_DISABLE_CERTS_CHECK" in os.environ:
135
 
        session = webkit.get_default_session()
136
 
        session.set_property("ssl-ca-file", "/etc/ssl/certs/ca-certificates.crt")
137
 
    else:
138
 
        # WARN the user!! Do not remove this
139
 
        LOG.warning("SOFTWARE_CENTER_FORCE_DISABLE_CERTS_CHECK " +
140
 
                    "has been specified, all purchase transactions " + 
141
 
                    "are now INSECURE and UNENCRYPTED!!")
142
 
 
143
126
    # create the app
144
 
    from softwarecenter.ui.gtk3.app import SoftwareCenterAppGtk3
 
127
    with ExecutionTime("import SoftwareCenterApp"):
 
128
        from softwarecenter.ui.gtk3.app import SoftwareCenterAppGtk3
145
129
    with ExecutionTime("create SoftwareCenterApp"):
146
 
        app = SoftwareCenterAppGtk3(datadir, xapian_base_path, options, args)
 
130
        app = SoftwareCenterAppGtk3(options, args)
147
131
 
148
 
    # DEBUG/PROFILE mode 
 
132
    # DEBUG/PROFILE mode
149
133
    if options.measure_startup_time:
150
134
        logger = logging.getLogger("softwarecenter.performance")
151
135
        with ExecutionTime("show() & gtk events until visible"):
173
157
 
174
158
        time_to_ready = time.time() - time_entering_main
175
159
        print(time_to_ready)
176
 
        logger.debug("** main window fully ready after: %s seconds" % time_to_ready)
 
160
        logger.debug("** main window fully ready after: %s seconds" %
 
161
                     time_to_ready)
177
162
        sys.exit(0)
178
163
 
179
164
    # run with cProfile
181
166
        # use something like "pyprof2calltree" from pypi and kcachegrind:
182
167
        #  $ python ./pyprof2calltree.py -i software-center_*.pyprof -k
183
168
        # OR
184
 
        #  $ runsnakerun software_center_*.pyprof 
 
169
        #  $ runsnakerun software_center_*.pyprof
185
170
        # OR
186
171
        #  gprof2dot (http://code.google.com/p/jrfonseca/wiki/Gprof2Dot):
187
172
        #  $ gprof2dot.py -f pstats software-center_20120620_114618.pyprof |\
196
181
    # run it normally
197
182
    app.run(args)
198
183
    Gtk.main()
199