tag_pycxx.py :  » Language-Interface » PyCXX » pycxx-6.2.0 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Language Interface » PyCXX 
PyCXX » pycxx 6.2.0 » tag_pycxx.py
import pysvn
import sys
import os

def make_tag( from_url, tag_base_url, version ):
  client = pysvn.Client()
  client.callback_get_log_message = lambda : (True, 'Tag version '+version)
  client.callback_get_login = callback_getLogin

  try:
    from_files = client.ls( from_url, recurse=False )
    print 'Info: Found', from_url
  except pysvn.ClientError, e:
    print 'Error: From does not exist',from_url
    return

  try:
    tag_files = client.ls( tag_base_url, recurse=False )
    print 'Info: Found', tag_base_url
  except pysvn.ClientError, e:
    print 'Error: Tag base does not exist',tag_base_url
    return

  cur_versions = [os.path.basename(f['name']) for f in tag_files]

  if version in cur_versions:
    print 'Error: Already tagged',version
    return


  try:
    to_url = tag_base_url + '/' + version
    print 'Info: Copy',repr(from_url), repr(to_url)
    client.copy( from_url, to_url )
    print 'Info: Copy complete'
  except pysvn.ClientError, e:
    print 'Error: ', str(e)
    return

def callback_getLogin( realm, username, may_save ):
  print 'May save:',may_save
  print 'Realm:',realm
  if username:
    print 'Username:',username
  else:
    sys.stdout.write( 'Username: ' )
    username = sys.stdin.readline().strip()
    if len(username) == 0:
      return 0, '', '', False

  sys.stdout.write( 'Password: ' )
  password = sys.stdin.readline().strip()

  save_password = 'x'
  while save_password.lower() not in ['y','ye','yes','n', 'no','']:
    sys.stdout.write( 'Save password? [y/n] ' )
    save_password = sys.stdin.readline().strip()
  
  return 1, username, password, save_password in ['y','ye','yes']

def main():
  if len(sys.argv) != 2:
    print 'Usage: %s version' % sys.argv[0]
    return

  version = sys.argv[1]
  from_url = 'https://cxx.svn.sourceforge.net/svnroot/cxx/trunk/CXX'
  tag_base_url = 'https://cxx.svn.sourceforge.net/svnroot/cxx/tags'

  make_tag( from_url, tag_base_url, version )

if __name__ == '__main__':
  main()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.