forked from conda/conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
help.py
43 lines (36 loc) · 1.17 KB
/
help.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sys
from os.path import join
import conda.config as config
from conda.cli.common import name_prefix
def read_message(fn):
res = []
for envs_dir in config.envs_dirs:
path = join(envs_dir, '.conda-help', fn)
try:
with open(path) as fi:
s = fi.read().decode('utf-8')
s = s.replace('${envs_dir}', envs_dir)
res.append(s)
except IOError:
pass
return ''.join(res)
def root_read_only(command, prefix):
assert command in {'install', 'update', 'remove'}
msg = read_message('ro.txt')
if not msg:
msg = """\
Error: Missing write permissions in: ${root_dir}
#
# You don't appear to have the necessary permissions to ${command} packages
# into the install area '${root_dir}'.
# However you can clone this environment into your home directory and
# then make changes to it.
# This may be done using the command:
#
# $ conda create -n my_${name} --clone=${prefix}
"""
msg = msg.replace('${root_dir}', config.root_dir)
msg = msg.replace('${prefix}', prefix)
msg = msg.replace('${name}', name_prefix(prefix))
msg = msg.replace('${command}', command)
sys.exit(msg)