/Demo/pdist/rcsclient.py

http://unladen-swallow.googlecode.com/ · Python · 71 lines · 53 code · 9 blank · 9 comment · 17 complexity · d986af610f0f71debd4b4e01122d5bfd MD5 · raw file

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