17
by Michael Vogt
initial UI |
1 |
#!/usr/bin/python
|
68
by Michael Vogt
add copyrights information |
2 |
# Copyright (C) 2009 Canonical
|
3 |
#
|
|
4 |
# Authors:
|
|
5 |
# Michael Vogt
|
|
6 |
#
|
|
7 |
# This program is free software; you can redistribute it and/or modify it under
|
|
8 |
# the terms of the GNU General Public License as published by the Free Software
|
|
325
by Michael Vogt
update license to GPLv3 |
9 |
# Foundation; version 3.
|
68
by Michael Vogt
add copyrights information |
10 |
#
|
11 |
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
# details.
|
|
15 |
#
|
|
16 |
# You should have received a copy of the GNU General Public License along with
|
|
17 |
# this program; if not, write to the Free Software Foundation, Inc.,
|
|
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
by Michael Vogt
initial UI |
19 |
|
1277
by Michael Vogt
* test/test_startup.py: |
20 |
# take time stamp as early as python allows this
|
21 |
import time |
|
22 |
time_entering_main = time.time() |
|
23 |
||
24 |
||
915.1.118
by Kiwinote
* software-center: |
25 |
# NOTE: although Decimal is not used in this file, we need to import it here to
|
26 |
# work around bug LP: #607705
|
|
27 |
from decimal import Decimal |
|
28 |
||
305
by Michael Vogt
* software-store: |
29 |
# thread init is also required otherwise both gst and webkit are unhappy
|
303
by Michael Vogt
software-store: add import pygtk;pygtk.require header |
30 |
import pygtk |
31 |
pygtk.require ("2.0") |
|
2112.1.1
by Martin Pitt
software-center: Import the static gobject, not the GI module, as this |
32 |
import gobject |
33 |
gobject.threads_init() |
|
372
by Michael Vogt
* Merged from Matthew McGowan: |
34 |
import gtk |
303
by Michael Vogt
software-store: add import pygtk;pygtk.require header |
35 |
|
280
by Michael Vogt
add more missing gettext glue |
36 |
import gettext |
1799
by Michael Vogt
merged from lp:~alexeftimie/software-center/fix-runlocal-appinstall |
37 |
import glob |
18
by Michael Vogt
make the installed/availabe view work |
38 |
import logging |
47
by Michael Vogt
* AppCenter/view/catview.py: |
39 |
import os |
1277
by Michael Vogt
* test/test_startup.py: |
40 |
import time |
41 |
import sys |
|
259
by Michael Vogt
merged lp:~sil/software-store/run-uninstalled, many |
42 |
|
330
by Michael Vogt
renamed to "Ubuntu Software Center" and software-center (LP: #436648) |
43 |
from softwarecenter.enums import * |
1487
by Michael Vogt
software-center: add missing import |
44 |
from softwarecenter.paths import XAPIAN_BASE_PATH |
1303.1.4
by Michael Vogt
add more with ExecutionTime() for better profiling data |
45 |
from softwarecenter.utils import ExecutionTime |
330
by Michael Vogt
renamed to "Ubuntu Software Center" and software-center (LP: #436648) |
46 |
from softwarecenter.version import * |
910.1.2
by Geliy Sokolov
Add log.py replacement for logging |
47 |
|
1694.1.1
by Michael Vogt
rewrite get_reviews to use a external helper instead of multiprocessing, this should *finally* fix #743020 for good, but its really anoying to have to workaround this issue with the accessibility layer |
48 |
import softwarecenter.log |
49 |
import softwarecenter.paths |
|
259
by Michael Vogt
merged lp:~sil/software-store/run-uninstalled, many |
50 |
|
143
by Michael Vogt
merge optparse support from rugby471 (thanks!) |
51 |
from optparse import OptionParser |
128.1.7
by Andrew
added commandline argument handling infrastructure, added error message constrcutor and half the code to handle going to a package from the commandline (hopefully mvo and supply the other half :-] ) |
52 |
|
17
by Michael Vogt
initial UI |
53 |
if __name__ == "__main__": |
143
by Michael Vogt
merge optparse support from rugby471 (thanks!) |
54 |
|
867.2.56
by Kiwinote
Update man file to reflect apturl and gdebi capabilities |
55 |
parser = OptionParser("usage: %prog [options] [package-name | apturl | deb-file]", |
284
by Michael Vogt
* setup.py: |
56 |
version="%prog "+VERSION) |
750
by Michael Vogt
make ExecutionTime() use the softwarecenter.performance logger |
57 |
parser.add_option("--debug", action="store_true", |
143
by Michael Vogt
merge optparse support from rugby471 (thanks!) |
58 |
help="enable debug mode", default=False) |
750
by Michael Vogt
make ExecutionTime() use the softwarecenter.performance logger |
59 |
parser.add_option("--debug-filter", |
60 |
help="show only specific messages. supported currently: " |
|
61 |
"'softwarecenter.performance'") |
|
372
by Michael Vogt
* Merged from Matthew McGowan: |
62 |
parser.add_option("--force-rtl", action="store_true", |
63 |
help="force rtl mode (useful for debugging)", |
|
64 |
default=False) |
|
841.1.1
by Gary Lasker
only enable LP integration when --enable-lp at startup |
65 |
# FIXME: REMOVE THIS option once launchpad integration is enabled
|
66 |
# by default
|
|
67 |
parser.add_option("--enable-lp", action="store_true", |
|
841.1.3
by Gary Lasker
tweak help message to indicate this is a developer option |
68 |
help="enable launchpad integration (for development use)", |
841.1.1
by Gary Lasker
only enable LP integration when --enable-lp at startup |
69 |
default=False) |
1066
by Michael Vogt
really enable buy-something by default |
70 |
parser.add_option("--disable-buy", action="store_true", |
915.1.62
by Kiwinote
softwareware typo |
71 |
help="disable support to buy software", |
1066
by Michael Vogt
really enable buy-something by default |
72 |
default=False) |
1809
by Michael Vogt
add new optional --disable-apt-xapian-index switch |
73 |
parser.add_option("--disable-apt-xapian-index", action="store_true", |
74 |
help="disable support for apt-xapian-index (technical items)", |
|
75 |
default=False) |
|
1277
by Michael Vogt
* test/test_startup.py: |
76 |
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) |
|
2095.1.1
by Michael Vogt
add --dummy-backend option, add install progress test, not quite working yet because of some dbus oddness |
79 |
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", |
|
81 |
default=False) |
|
1277
by Michael Vogt
* test/test_startup.py: |
82 |
|
143
by Michael Vogt
merge optparse support from rugby471 (thanks!) |
83 |
(options, args) = parser.parse_args() |
1277
by Michael Vogt
* test/test_startup.py: |
84 |
|
85 |
# statup time measure implies "performance" in debug filters
|
|
86 |
if options.measure_startup_time: |
|
87 |
options.debug_filter = "performance" |
|
910.1.1
by Geliy Sokolov
Fix --debug-filter and --debug options |
88 |
|
750
by Michael Vogt
make ExecutionTime() use the softwarecenter.performance logger |
89 |
if options.debug_filter: |
935
by Michael Vogt
merged lp:~hellium/software-center/logging, thanks to |
90 |
softwarecenter.log.add_filters_from_string(options.debug_filter) |
750
by Michael Vogt
make ExecutionTime() use the softwarecenter.performance logger |
91 |
# implies general debug
|
92 |
options.debug = True |
|
93 |
||
143
by Michael Vogt
merge optparse support from rugby471 (thanks!) |
94 |
if options.debug: |
935
by Michael Vogt
merged lp:~hellium/software-center/logging, thanks to |
95 |
softwarecenter.log.root.setLevel(level=logging.DEBUG) |
143
by Michael Vogt
merge optparse support from rugby471 (thanks!) |
96 |
else: |
935
by Michael Vogt
merged lp:~hellium/software-center/logging, thanks to |
97 |
softwarecenter.log.root.setLevel(level=logging.INFO) |
1538.2.8
by Michael Vogt
add --enable-weblive switch |
98 |
|
2095.1.1
by Michael Vogt
add --dummy-backend option, add install progress test, not quite working yet because of some dbus oddness |
99 |
# dummy backend
|
100 |
if options.dummy_backend: |
|
101 |
import atexit |
|
102 |
from softwarecenter.testutils import start_dummy_backend, stop_dummy_backend |
|
103 |
start_dummy_backend() |
|
104 |
atexit.register(stop_dummy_backend) |
|
105 |
||
372
by Michael Vogt
* Merged from Matthew McGowan: |
106 |
# override text direction for testing purposes
|
107 |
if options.force_rtl: |
|
108 |
gtk.widget_set_default_direction(gtk.TEXT_DIR_RTL) |
|
143
by Michael Vogt
merge optparse support from rugby471 (thanks!) |
109 |
|
1952
by Michael Vogt
software-center: automatically set PYTOHNPATH if running in the local checkout so that the helpers will work properly |
110 |
# we are running in a local checkout, make life as easy as possible
|
111 |
# for this
|
|
1912
by Michael Vogt
* data/ui/*.ui: |
112 |
if os.path.exists("./data/ui/gtk/SoftwareCenter.ui"): |
910.1.1
by Geliy Sokolov
Fix --debug-filter and --debug options |
113 |
logging.getLogger("softwarecenter").info("Using data (UI, xapian) from current dir") |
1952
by Michael Vogt
software-center: automatically set PYTOHNPATH if running in the local checkout so that the helpers will work properly |
114 |
# set pythonpath for the various helpers
|
2099
by Michael Vogt
* software-center: |
115 |
if os.environ.get("PYTHONPATH", ""): |
2095
by Michael Vogt
* software-center-gtk3, software-center: |
116 |
os.environ["PYTHONPATH"]=os.path.abspath(".") + ":" + os.environ.get("PYTHONPATH","") |
117 |
else: |
|
118 |
os.environ["PYTHONPATH"]=os.path.abspath(".") |
|
68
by Michael Vogt
add copyrights information |
119 |
datadir = "./data" |
242.1.1
by stuart.langridge at canonical
Allow running software-store uninstalled, direct from a bzr checkout |
120 |
xapian_base_path = datadir |
1694.1.1
by Michael Vogt
rewrite get_reviews to use a external helper instead of multiprocessing, this should *finally* fix #743020 for good, but its really anoying to have to workaround this issue with the accessibility layer |
121 |
# set new global datadir
|
122 |
softwarecenter.paths.datadir = datadir |
|
1798.1.1
by Alex Eftimie
temporary fix for run_local, where u-s-c is not installed |
123 |
# also alter the app-install path
|
1803
by Michael Vogt
merged from lp:~alexeftimie/software-center/fix-runlocal-appinstall |
124 |
path = "%s/desktop/software-center.menu" % softwarecenter.paths.APP_INSTALL_PATH |
125 |
if not os.path.exists(path): |
|
1799
by Michael Vogt
merged from lp:~alexeftimie/software-center/fix-runlocal-appinstall |
126 |
softwarecenter.paths.APP_INSTALL_PATH = './build/share/app-install' |
1801
by Michael Vogt
software-center: really fix using the local app-install path data now |
127 |
logging.warn("using local APP_INSTALL_PATH: %s" % softwarecenter.paths.APP_INSTALL_PATH) |
68
by Michael Vogt
add copyrights information |
128 |
else: |
1694.1.1
by Michael Vogt
rewrite get_reviews to use a external helper instead of multiprocessing, this should *finally* fix #743020 for good, but its really anoying to have to workaround this issue with the accessibility layer |
129 |
datadir = softwarecenter.paths.datadir |
259
by Michael Vogt
merged lp:~sil/software-store/run-uninstalled, many |
130 |
xapian_base_path = XAPIAN_BASE_PATH |
1327
by Michael Vogt
software-center: add gtk.init_check() & test visible elements on the main window |
131 |
|
132 |
# ensure we can actually run
|
|
133 |
gtk.init_check() |
|
134 |
||
1277
by Michael Vogt
* test/test_startup.py: |
135 |
# create the app
|
1899
by Michael Vogt
move softwarecenter.app softwarecenter.ui.gtk.app as its not really generic but full of gtk2 code |
136 |
from softwarecenter.ui.gtk.app import SoftwareCenterApp |
1303.1.4
by Michael Vogt
add more with ExecutionTime() for better profiling data |
137 |
with ExecutionTime("create SoftwareCenterApp"): |
138 |
app = SoftwareCenterApp(datadir, xapian_base_path, options, args) |
|
1277
by Michael Vogt
* test/test_startup.py: |
139 |
|
140 |
# DEBUG/PROFILE mode
|
|
141 |
if options.measure_startup_time: |
|
1327
by Michael Vogt
software-center: add gtk.init_check() & test visible elements on the main window |
142 |
with ExecutionTime("show() & gtk events until visible"): |
1406.1.7
by Gary Lasker
tweak the startup time measurement code |
143 |
# app.window_main.show_all()
|
1327
by Michael Vogt
software-center: add gtk.init_check() & test visible elements on the main window |
144 |
while gtk.events_pending(): |
145 |
# test visible area
|
|
146 |
if (app.window_main.flags() & gtk.VISIBLE and |
|
1406.1.7
by Gary Lasker
tweak the startup time measurement code |
147 |
app.available_pane.searchentry.flags() & gtk.VISIBLE and |
148 |
app.available_pane.back_forward.flags() & gtk.VISIBLE): |
|
1327
by Michael Vogt
software-center: add gtk.init_check() & test visible elements on the main window |
149 |
break
|
150 |
gtk.main_iteration() |
|
1277
by Michael Vogt
* test/test_startup.py: |
151 |
time_to_visible = time.time() - time_entering_main |
152 |
print time_to_visible |
|
153 |
sys.exit(0) |
|
154 |
||
155 |
# run it normally
|
|
442
by Michael Vogt
merge lp:~rugby471/software-center/software-store-andrew, |
156 |
app.run(args) |
17
by Michael Vogt
initial UI |
157 |