summaryrefslogtreecommitdiff
path: root/tools/regression/xsl_reports/utils/sourceforge.py
blob: 0c6b0852863c2aa40c35d8968cf0261616685fcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

import utils.checked_system
import os
import sys

site_dir = '/home/groups/b/bo/boost/htdocs/'

def download( source, destination, user ):
    if sys.platform == 'win32':
        destination = os.popen( 'cygpath "%s"' % destination ).read().splitlines()[0]

    utils.checked_system( [ 
          'rsync -v -r -z --progress %(user)s@shell.sourceforge.net:%(site_dir)s%(source)s %(dest)s'
                % { 'user': user, 'site_dir': site_dir, 'source': source, 'dest': destination }
        ] )


def upload( source, destination, user ):
    if sys.platform == 'win32':
        source = os.popen( 'cygpath "%s"' % source ).read().splitlines()[0]
        
    utils.checked_system( [ 
          'rsync -v -r -z --progress %(source)s %(user)s@shell.sourceforge.net:%(site_dir)s%(dest)s'
                % { 'user': user, 'site_dir': site_dir, 'source': source, 'dest': destination }
        ] )


def checked_system( commands, user, background = False ):
    if not background:
        cmd = 'ssh -l %s shell.sourceforge.net "%s"'
    else:
        cmd = 'ssh -f -l %s shell.sourceforge.net "%s"'

    utils.checked_system( 
          [ cmd % ( user, '&&'.join( commands ) ) ]
        )


def untar( archive, user, background ):
    checked_system( 
          [
              'cd %s' % os.path.join( site_dir, os.path.dirname( archive ) )
            , 'tar -x -z --overwrite --mode=+w -f %s' % os.path.basename( archive )
            , 'rm -f %s' % archive
            ]
        , user = user
        , background = background
        )