41
41
import zipfile
42
42
43
43
44
+ __version__ = '0.1'
45
+
44
46
LOG = logging .getLogger ('swc-windows-installer' )
45
47
LOG .addHandler (logging .StreamHandler ())
46
- LOG .setLevel (logging .ERROR )
48
+ LOG .setLevel (logging .INFO )
47
49
48
50
49
51
if sys .version_info >= (3 , 0 ): # Python 3
@@ -197,15 +199,19 @@ def create_nosetests_entry_point(python_scripts_directory):
197
199
def get_r_bin_directory ():
198
200
"""Locate the R bin directory (if R is installed
199
201
"""
200
- pf = os .environ .get ('ProgramFiles' , r'c:\ProgramFiles' )
201
- bin_glob = os .path .join (pf , 'R' , 'R-[0-9]*.[0-9]*.[0-9]*' , 'bin' )
202
202
version_re = re .compile ('^R-(\d+)[.](\d+)[.](\d+)$' )
203
203
paths = {}
204
- for path in glob .glob (bin_glob ):
205
- version_dir = os .path .basename (os .path .dirname (path ))
206
- version_match = version_re .match (version_dir )
207
- if version_match :
208
- paths [version_match .groups ()] = path
204
+ for pf in [
205
+ os .environ .get ('ProgramW6432' , r'c:\Program Files' ),
206
+ os .environ .get ('ProgramFiles' , r'c:\Program Files' ),
207
+ os .environ .get ('ProgramFiles(x86)' , r'c:\Program Files(x86)' ),
208
+ ]:
209
+ bin_glob = os .path .join (pf , 'R' , 'R-[0-9]*.[0-9]*.[0-9]*' , 'bin' )
210
+ for path in glob .glob (bin_glob ):
211
+ version_dir = os .path .basename (os .path .dirname (path ))
212
+ version_match = version_re .match (version_dir )
213
+ if version_match and version_match .groups () not in paths :
214
+ paths [version_match .groups ()] = path
209
215
if not paths :
210
216
LOG .info ('no R installation found under {}' .format (pf ))
211
217
return
@@ -274,8 +280,13 @@ def main():
274
280
description = __doc__ ,
275
281
formatter_class = argparse .RawDescriptionHelpFormatter )
276
282
parser .add_argument (
277
- '-v' , '--verbose' , choices = ['info' , 'debug' ],
278
- help = 'Verbosity' )
283
+ '-v' , '--verbose' ,
284
+ choices = ['critical' , 'error' , 'warning' , 'info' , 'debug' ],
285
+ help = 'Verbosity (defaults to {!r})' .format (
286
+ logging .getLevelName (LOG .level ).lower ()))
287
+ parser .add_argument (
288
+ '--version' , action = 'version' ,
289
+ version = '%(prog)s {}' .format (__version__ ))
279
290
280
291
args = parser .parse_args ()
281
292
@@ -284,5 +295,6 @@ def main():
284
295
LOG .setLevel (level )
285
296
286
297
LOG .info ('Preparing your Software Carpentry awesomeness!' )
298
+ LOG .info ('installer version {}' .format (__version__ ))
287
299
main ()
288
300
LOG .info ('Installation complete.' )
0 commit comments