blob: 983aad125dce91d2b1c438e9afdce921cf61b6bf [file] [log] [blame]
Guido van Rossum464f62b1995-06-23 22:41:34 +00001"""Customize this file to change the default client etc.
2
3(In general, it is probably be better to make local operation the
4default and to require something like an RCSSERVER environment
5variable to enable remote operation.)
6
7"""
Guido van Rossum8bcd3011995-04-28 14:31:36 +00008
9import string
10
Guido van Rossum177df7d1995-04-28 19:23:13 +000011# These defaults don't belong here -- they should be taken from the
12# environment or from a hidden file in the current directory
13
Guido van Rossum8bcd3011995-04-28 14:31:36 +000014HOST = 'voorn.cwi.nl'
15PORT = 4127
Guido van Rossum8bcd3011995-04-28 14:31:36 +000016VERBOSE = 1
Guido van Rossum464f62b1995-06-23 22:41:34 +000017LOCAL = 0
Guido van Rossum72974f31995-06-23 21:59:12 +000018
19import client
20
21
22class RCSProxyClient(client.SecureClient):
23
24 def __init__(self, address, verbose = client.VERBOSE):
25 client.SecureClient.__init__(self, address, verbose)
26
27
Guido van Rossum8bcd3011995-04-28 14:31:36 +000028def openrcsclient(opts = []):
29 "open an RCSProxy client based on a list of options returned by getopt"
30 import RCSProxy
31 host = HOST
32 port = PORT
Guido van Rossum8bcd3011995-04-28 14:31:36 +000033 verbose = VERBOSE
Guido van Rossum464f62b1995-06-23 22:41:34 +000034 local = LOCAL
Guido van Rossum177df7d1995-04-28 19:23:13 +000035 directory = None
Guido van Rossum8bcd3011995-04-28 14:31:36 +000036 for o, a in opts:
37 if o == '-h':
38 host = a
39 if ':' in host:
40 i = string.find(host, ':')
41 host, p = host[:i], host[i+1:]
42 if p:
43 port = string.atoi(p)
44 if o == '-p':
45 port = string.atoi(a)
46 if o == '-d':
47 directory = a
48 if o == '-v':
49 verbose = verbose + 1
50 if o == '-q':
51 verbose = 0
Guido van Rossum464f62b1995-06-23 22:41:34 +000052 if o == '-L':
53 local = 1
54 if local:
55 import RCSProxy
56 x = RCSProxy.RCSProxyLocal()
57 else:
58 address = (host, port)
59 x = RCSProxyClient(address, verbose)
Guido van Rossum177df7d1995-04-28 19:23:13 +000060 if not directory:
61 try:
62 directory = open("CVS/Repository").readline()
63 except IOError:
64 pass
65 else:
66 if directory[-1] == '\n':
67 directory = directory[:-1]
Guido van Rossum8bcd3011995-04-28 14:31:36 +000068 if directory:
69 x.cd(directory)
70 return x