Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.

Commit 38857cf

Browse files
committed
Merge branch 'python' for release 0.1
2 parents 315e7a8 + 10682b9 commit 38857cf

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

swc-windows-installer.py

+22-10
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@
4141
import zipfile
4242

4343

44+
__version__ = '0.1'
45+
4446
LOG = logging.getLogger('swc-windows-installer')
4547
LOG.addHandler(logging.StreamHandler())
46-
LOG.setLevel(logging.ERROR)
48+
LOG.setLevel(logging.INFO)
4749

4850

4951
if sys.version_info >= (3, 0): # Python 3
@@ -197,15 +199,19 @@ def create_nosetests_entry_point(python_scripts_directory):
197199
def get_r_bin_directory():
198200
"""Locate the R bin directory (if R is installed
199201
"""
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')
202202
version_re = re.compile('^R-(\d+)[.](\d+)[.](\d+)$')
203203
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
209215
if not paths:
210216
LOG.info('no R installation found under {}'.format(pf))
211217
return
@@ -274,8 +280,13 @@ def main():
274280
description=__doc__,
275281
formatter_class=argparse.RawDescriptionHelpFormatter)
276282
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__))
279290

280291
args = parser.parse_args()
281292

@@ -284,5 +295,6 @@ def main():
284295
LOG.setLevel(level)
285296

286297
LOG.info('Preparing your Software Carpentry awesomeness!')
298+
LOG.info('installer version {}'.format(__version__))
287299
main()
288300
LOG.info('Installation complete.')

0 commit comments

Comments
 (0)