sourceforge.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import utils.checked_system
  2. import os
  3. import sys
  4. site_dir = '/home/groups/b/bo/boost/htdocs/'
  5. def download( source, destination, user ):
  6. if sys.platform == 'win32':
  7. destination = os.popen( 'cygpath "%s"' % destination ).read().splitlines()[0]
  8. utils.checked_system( [
  9. 'rsync -v -r -z --progress %(user)s@shell.sourceforge.net:%(site_dir)s%(source)s %(dest)s'
  10. % { 'user': user, 'site_dir': site_dir, 'source': source, 'dest': destination }
  11. ] )
  12. def upload( source, destination, user ):
  13. if sys.platform == 'win32':
  14. source = os.popen( 'cygpath "%s"' % source ).read().splitlines()[0]
  15. utils.checked_system( [
  16. 'rsync -v -r -z --progress %(source)s %(user)s@shell.sourceforge.net:%(site_dir)s%(dest)s'
  17. % { 'user': user, 'site_dir': site_dir, 'source': source, 'dest': destination }
  18. ] )
  19. def checked_system( commands, user, background = False ):
  20. if not background:
  21. cmd = 'ssh -l %s shell.sourceforge.net "%s"'
  22. else:
  23. cmd = 'ssh -f -l %s shell.sourceforge.net "%s"'
  24. utils.checked_system(
  25. [ cmd % ( user, '&&'.join( commands ) ) ]
  26. )
  27. def untar( archive, user, background ):
  28. checked_system(
  29. [
  30. 'cd %s' % os.path.join( site_dir, os.path.dirname( archive ) )
  31. , 'tar -x -z --overwrite --mode=+w -f %s' % os.path.basename( archive )
  32. , 'rm -f %s' % archive
  33. ]
  34. , user = user
  35. , background = background
  36. )
粤ICP备19079148号