author | Paul Crowley <paul@lshift.net> |
Fri, 13 Nov 2009 14:58:55 +0000 | |
changeset 216 | 0122df83ebd0 |
parent 215 | 584df0f2e5c7 |
child 217 | 32b431977bf9 |
permissions | -rw-r--r-- |
70 | 1 |
# Copyright 2008-2009 LShift Ltd |
2 |
||
79 | 3 |
import sys |
4 |
import os.path |
|
215
584df0f2e5c7
Use ConfigParser istead of mercurial.config
Paul Crowley <paul@lshift.net>
parents:
213
diff
changeset
|
5 |
import ConfigParser |
79 | 6 |
|
165
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
7 |
globalconfig = None |
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
8 |
|
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
9 |
def _getConf(): |
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
10 |
global globalconfig |
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
11 |
if globalconfig is None: |
215
584df0f2e5c7
Use ConfigParser istead of mercurial.config
Paul Crowley <paul@lshift.net>
parents:
213
diff
changeset
|
12 |
globalconfig = ConfigParser.RawConfigParser() |
165
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
13 |
globalconfig.read(os.path.expanduser("~/.mercurial-server")) |
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
14 |
return globalconfig |
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
15 |
|
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
16 |
def _getPath(name): |
215
584df0f2e5c7
Use ConfigParser istead of mercurial.config
Paul Crowley <paul@lshift.net>
parents:
213
diff
changeset
|
17 |
return os.path.expanduser(_getConf().get("paths", name)) |
165
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
18 |
|
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
19 |
def _getPaths(name): |
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
20 |
return [os.path.expanduser(p) |
215
584df0f2e5c7
Use ConfigParser istead of mercurial.config
Paul Crowley <paul@lshift.net>
parents:
213
diff
changeset
|
21 |
for p in _getConf().get("paths", name).split(":")] |
165
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
22 |
|
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
23 |
def getReposPath(): return _getPath("repos") |
213
72e7ba8b41a6
Don't hardwire location of authorized_keys file
Paul Crowley <paul@lshift.net>
parents:
212
diff
changeset
|
24 |
def getAuthorizedKeysPath(): return _getPath("authorized_keys") |
165
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
25 |
|
216 | 26 |
def configExists(): |
27 |
try: |
|
28 |
_getAuthorizedKeysPath() |
|
29 |
return True |
|
30 |
except: |
|
31 |
return False |
|
32 |
||
165
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
33 |
def getKeysPaths(): return _getPaths("keys") |
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
34 |
def getAccessPaths(): return _getPaths("access") |
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
35 |
|
215
584df0f2e5c7
Use ConfigParser istead of mercurial.config
Paul Crowley <paul@lshift.net>
parents:
213
diff
changeset
|
36 |
def getEnv(): return _getConf().items("env") |
165
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
37 |
|
3606d60b07e5
Use .mercurial-sever file instead of hardcoding
Paul Crowley <paul@lshift.net>
parents:
79
diff
changeset
|
38 |
# Work out where we are, don't use config. |
79 | 39 |
def setExePath(): |
40 |
global _exePath |
|
41 |
_exePath = os.path.dirname(os.path.abspath(sys.argv[0])) |
|
42 |
||
43 |
def getExePath(): |
|
44 |
return _exePath |
|
45 |