3 # Copyright (c) 2002-2004 Juri Pakaste <juri@iki.fi>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 2 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public
16 # License along with this program; if not, write to the
17 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 # Boston, MA 02111-1307, USA.
20 # save the location of the script at the start before anything can modify
23 location
= sys
.path
[0]
25 # wrap stdout to print unicode chars in the $TERM
27 sys
.stdout
= codecs
.lookup('utf-8')[-1](sys
.stdout
)
40 sdir
= os
.path
.join(location
, "lib")
42 sdir
= os
.environ
["STRAW_LIB"]
45 sd
= os
.path
.join(d
, 'straw')
50 h
, t
= os
.path
.split(os
.path
.split(os
.path
.abspath(sys
.argv
[0]))[0])
52 libdir
= os
.path
.join(h
, 'lib')
53 fp
= os
.path
.join(libdir
, 'straw')
57 raise "FileNotFoundError", "couldn't find straw library dir"
62 Run straw in the source tree
64 currentdir
= os
.path
.dirname(os
.path
.abspath(sys
.argv
[0]))
65 prefix
= os
.path
.abspath(os
.path
.join(currentdir
, '..'))
66 print 'Generating constants.py...'
67 f
= open (os
.path
.join(sdir
,'constants.py'),'w')
68 f
.write('APPNAME = "Straw"\n')
69 f
.write('VERSION = "0.28"\n')
70 f
.write('STRAW_URL = "http://www.gnome.org/projects/straw"\n')
71 f
.write('STRAW_REF_URL = "http://www.gnome.org/projects/straw-ref.html"\n')
72 f
.write('libdir = "%s"\n' % sdir
)
73 f
.write('localedir = "%s"\n' % os
.path
.join(prefix
, 'po'))
74 f
.write('datadir = "%s"\n' % os
.path
.join(prefix
, 'data'))
75 f
.write('imagedir = "%s"\n' % os
.path
.join(prefix
, 'images'))
76 f
.write('gladedir = "%s"\n' % os
.path
.join(prefix
, 'glade'))
81 # remove created compiled files
83 httplibdir
= os
.path
.join(sdir
, 'httplib2')
84 for d
in [sdir
, httplibdir
]:
85 for fn
in dircache
.listdir(d
):
86 filepath
= os
.path
.join(d
, fn
)
87 if filepath
.endswith(".pyc"):
89 os
.remove(os
.path
.join(sdir
, 'constants.py'))
94 from optparse
import OptionParser
95 usage
= """%prog [--offline]\nDesktop feed aggregator"""
96 parser
= OptionParser(usage
=usage
)
97 parser
.set_defaults(offline
=False)
98 parser
.add_option("--offline", action
="store_true", dest
="offline", default
=False,
99 help="run Straw in offline mode")
100 (options
,args
) = parser
.parse_args()
105 from lib
import Application
, Config
107 from straw
import Application
, Config
109 # set offline to false if offline. Previous releases just rely on the
110 # previous state of the 'offline' config. So if the user specifies
111 # offline, the next run will still be set to offline regardless if the
112 # user did not specifiy offline since it will still get the state of the
113 # offline config from the previous run.
114 config
= Config
.get_instance()
116 config
.offline
= True
118 config
.offline
= False
119 app
= Application
.Application()
120 # load tray if it's a standard install
121 if not ENV_IN_SOURCE
:
126 signal
.signal(signal
.SIGINT
, signal
.SIG_DFL
)
127 options
= parse_args()
136 # setup path and environment
137 ENV_IN_SOURCE
= os
.environ
.has_key("STRAW_IN_SOURCE_DIR")
138 ENV_LIB_DIR
= os
.environ
.has_key("STRAW_LIB")
139 sdir
= find_straw_lib()
140 if sdir
not in sys
.path
:
141 sys
.path
.insert(0,sdir
)
143 if __name__
== '__main__':