3 # Copyright (c) 2002-2004 Juri Pakaste <juri@iki.fi>
4 # Copyright (c) 2005-2007 Straw Contributors
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public
17 # License along with this program; if not, write to the
18 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
22 # wrap stdout to print unicode chars in the $TERM
24 sys
.stdout
= codecs
.lookup('utf-8')[-1](sys
.stdout
)
26 import signal
, os
, os
.path
, time
32 def initialize_gettext():
33 import gettext
, locale
34 from straw
import defs
36 appname
= defs
.PACKAGE
37 localedir
= "%s/%s" % (defs
.DATA_DIR
,'locale')
39 gettext
.bindtextdomain(appname
, localedir
)
40 gettext
.bind_textdomain_codeset(appname
, 'UTF-8')
41 gettext
.textdomain(appname
)
42 gettext
.install(appname
, localedir
, unicode=1)
44 locale
.bindtextdomain(appname
, localedir
)
45 locale
.bind_textdomain_codeset(appname
, localedir
)
46 locale
.textdomain(appname
)
48 gtk
.glade
.bindtextdomain(appname
, localedir
)
52 dir = os
.path
.dirname (os
.path
.abspath
53 (sys
._getframe
().f_code
.co_filename
))
54 rootdir
= os
.path
.abspath(os
.path
.join(dir, ".."))
57 def get_library_location():
58 return os
.path
.join(get_root(), 'straw')
62 Run straw in the source tree
64 # insert straw module into python path
65 sys
.path
.insert(0, get_root())
70 m
= straw
.defs
= sys
.modules
["straw.defs"] = imp
.new_module("straw.defs")
75 m
.VERSION
= "uninstalled"
78 m
.STRAW_HOME
= "http://www.gnome.org/projects/straw"
79 m
.STRAW_DATA_DIR
= os
.path
.join(get_root(), "data")
82 # remove created compiled files
84 libloc
= get_library_location()
85 httplibdir
= os
.path
.join(libloc
, "httplib2")
86 for d
in [libloc
, httplibdir
]:
87 for fn
in dircache
.listdir(d
):
88 filepath
= os
.path
.join(d
, fn
)
89 if filepath
.endswith(".pyc"):
95 from optparse
import OptionParser
96 usage
= """%prog [--offline]\nDesktop feed aggregator"""
97 parser
= OptionParser(usage
=usage
)
98 parser
.set_defaults(offline
=False)
99 parser
.add_option("--offline", action
="store_true", dest
="offline", default
=False,
100 help="run Straw in offline mode")
101 (options
,args
) = parser
.parse_args()
105 from straw
import Application
, Config
, Constants
107 # set offline to false if offline. Previous releases just rely on the
108 # previous state of the 'offline' config. So if the user specifies
109 # offline, the next run will still be set to offline regardless if the
110 # user did not specifiy offline since it will still get the state of the
111 # offline config from the previous run.
112 offline
= Config
.set(Constants
.OPTION_OFFLINE
, options
.offline
)
114 app
= Application
.Application()
119 signal
.signal(signal
.SIGINT
, signal
.SIG_DFL
)
120 options
= parse_args()
121 prof
= os
.environ
.has_key('STRAW_PROFILE')
126 from tools
import statprof
138 if __name__
== '__main__':