Guido van Rossum | 464f62b | 1995-06-23 22:41:34 +0000 | [diff] [blame] | 1 | """Customize this file to change the default client etc. |
| 2 | |
| 3 | (In general, it is probably be better to make local operation the |
| 4 | default and to require something like an RCSSERVER environment |
| 5 | variable to enable remote operation.) |
| 6 | |
| 7 | """ |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 8 | |
| 9 | import string |
Guido van Rossum | 11bb174 | 1995-10-07 19:26:06 +0000 | [diff] [blame] | 10 | import os |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 11 | |
Guido van Rossum | 177df7d | 1995-04-28 19:23:13 +0000 | [diff] [blame] | 12 | # These defaults don't belong here -- they should be taken from the |
| 13 | # environment or from a hidden file in the current directory |
| 14 | |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 15 | HOST = 'voorn.cwi.nl' |
| 16 | PORT = 4127 |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 17 | VERBOSE = 1 |
Guido van Rossum | 464f62b | 1995-06-23 22:41:34 +0000 | [diff] [blame] | 18 | LOCAL = 0 |
Guido van Rossum | 72974f3 | 1995-06-23 21:59:12 +0000 | [diff] [blame] | 19 | |
| 20 | import client |
| 21 | |
| 22 | |
| 23 | class RCSProxyClient(client.SecureClient): |
Tim Peters | e6ddc8b | 2004-07-18 05:56:09 +0000 | [diff] [blame] | 24 | |
| 25 | def __init__(self, address, verbose = client.VERBOSE): |
| 26 | client.SecureClient.__init__(self, address, verbose) |
Guido van Rossum | 72974f3 | 1995-06-23 21:59:12 +0000 | [diff] [blame] | 27 | |
| 28 | |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 29 | def openrcsclient(opts = []): |
Tim Peters | e6ddc8b | 2004-07-18 05:56:09 +0000 | [diff] [blame] | 30 | "open an RCSProxy client based on a list of options returned by getopt" |
| 31 | import RCSProxy |
| 32 | host = HOST |
| 33 | port = PORT |
| 34 | verbose = VERBOSE |
| 35 | local = LOCAL |
| 36 | directory = None |
| 37 | for o, a in opts: |
| 38 | if o == '-h': |
| 39 | host = a |
| 40 | if ':' in host: |
| 41 | i = string.find(host, ':') |
| 42 | host, p = host[:i], host[i+1:] |
| 43 | if p: |
| 44 | port = string.atoi(p) |
| 45 | if o == '-p': |
| 46 | port = string.atoi(a) |
| 47 | if o == '-d': |
| 48 | directory = a |
| 49 | if o == '-v': |
| 50 | verbose = verbose + 1 |
| 51 | if o == '-q': |
| 52 | verbose = 0 |
| 53 | if o == '-L': |
| 54 | local = 1 |
| 55 | if local: |
| 56 | import RCSProxy |
| 57 | x = RCSProxy.RCSProxyLocal() |
| 58 | else: |
| 59 | address = (host, port) |
| 60 | x = RCSProxyClient(address, verbose) |
| 61 | if not directory: |
| 62 | try: |
| 63 | directory = open(os.path.join("CVS", "Repository")).readline() |
| 64 | except IOError: |
| 65 | pass |
| 66 | else: |
| 67 | if directory[-1] == '\n': |
| 68 | directory = directory[:-1] |
| 69 | if directory: |
| 70 | x.cd(directory) |
| 71 | return x |