def main(vers=None):
    try:
        if vers:pause=False
        else:pause=True

        svn=which('svn')

        if not svn:
            print 'Install an SVN command line client (e.g. http://www.sliksvn.com) or ensure that it is on your PATH'
            if pause:raw_input('Press enter to exit.')
            sys.exit(1)

        if not vers:
            try:vers = raw_input('Enter the version to build, options are: \n1.N (eg. 1.1 release) \ncurr (latest release) \nbranches/<branch> \ntrunk (unstable development) \nVersion:  ')
            except:sys.exit(0)#vers = 'trunk'

        repo=''
        if vers in ['curr','']:
            cmd='svn ls http://metageta.googlecode.com/svn/tags'
            exit_code,stdout,stderr=runcmd(cmd)
            if exit_code != 0:
                if stderr:    print stderr
                elif stdout:  print stdout
                else :        print 'SVN command failed'
                if pause:raw_input('Press enter to exit.')
                sys.exit(exit_code)
            else:
def main(vers=None):
    try:
        if vers: pause = False
        else: pause = True

        svn = which('svn')

        if not svn:
            print 'Install an SVN command line client (e.g. http://www.sliksvn.com) or ensure that it is on your PATH'
            if pause: raw_input('Press enter to exit.')
            sys.exit(1)

        if not vers:
            try:
                vers = raw_input(
                    'Enter the version to build, options are: \n1.N (eg. 1.1 release) \ncurr (latest release) \nbranches/<branch> \ntrunk (unstable development) \nVersion:  '
                )
            except:
                sys.exit(0)  #vers = 'trunk'

        repo = ''
        if vers in ['curr', '']:
            cmd = 'svn ls http://metageta.googlecode.com/svn/tags'
            exit_code, stdout, stderr = runcmd(cmd)
            if exit_code != 0:
                if stderr: print stderr
                elif stdout: print stdout
                else: print 'SVN command failed'
                if pause: raw_input('Press enter to exit.')
                sys.exit(exit_code)
            else:
            cmd='svn ls http://metageta.googlecode.com/svn/tags'
            exit_code,stdout,stderr=runcmd(cmd)
            if exit_code != 0:
                if stderr:    print stderr
                elif stdout:  print stdout
                else :        print 'SVN command failed'
                if pause:raw_input('Press enter to exit.')
                sys.exit(exit_code)
            else:
                vers=stdout.strip().split()[-1][:-1]
                'tags/%s'%vers
                print 'Latest release is %s'%vers

        elif vers[-4:]=='curr':  #i.e. branches/dsewpac/curr
            cmd='svn ls http://metageta.googlecode.com/svn/%s/tags'%vers[:-5]
            exit_code,stdout,stderr=runcmd(cmd)
            if exit_code != 0:
                if stderr:    print stderr
                elif stdout:  print stdout
                else :        print 'SVN command failed'
                if pause:raw_input('Press enter to exit.')
                sys.exit(exit_code)
            else:
                repo='%s/tags/'%vers[:-5]
                vers=stdout.strip().split()[-1][:-1]
                repo+=vers
                print 'Latest release is %s'%vers

        cd = os.path.abspath(os.path.dirname(sys.argv[0]))

        os.chdir(cd)
            exit_code, stdout, stderr = runcmd(cmd)
            if exit_code != 0:
                if stderr: print stderr
                elif stdout: print stdout
                else: print 'SVN command failed'
                if pause: raw_input('Press enter to exit.')
                sys.exit(exit_code)
            else:
                vers = stdout.strip().split()[-1][:-1]
                'tags/%s' % vers
                print 'Latest release is %s' % vers

        elif vers[-4:] == 'curr':  #i.e. branches/dsewpac/curr
            cmd = 'svn ls http://metageta.googlecode.com/svn/%s/tags' % vers[:
                                                                             -5]
            exit_code, stdout, stderr = runcmd(cmd)
            if exit_code != 0:
                if stderr: print stderr
                elif stdout: print stdout
                else: print 'SVN command failed'
                if pause: raw_input('Press enter to exit.')
                sys.exit(exit_code)
            else:
                repo = '%s/tags/' % vers[:-5]
                vers = stdout.strip().split()[-1][:-1]
                repo += vers
                print 'Latest release is %s' % vers

        cd = os.path.abspath(os.path.dirname(sys.argv[0]))

        os.chdir(cd)
Esempio n. 5
0
def ParseGDALinfo(filepath):
    ''' Very basic gdalinfo parser, does not include colo(u)r tables, raster attribute tables.

        @type    filepath: C{str}
        @param   filepath: path to dataset
        @rtype:  C{(dict,list)}
        @return: GDAL info,extent coordinates
    '''
    
    metadata={}
    extent=[]

    cmd='gdalinfo -noct '+filepath
    exit_code,stdout,stderr=utilities.runcmd(cmd)
    if exit_code != 0: raise Exception, stderr
    
    decimal=r'([-+]?\d+\.?\d+e?[-+]?\d+?)'

    rex=r'Size is (\d+),\s*(\d+)'
    rex=re.compile(rex, re.I)
    rex=rex.findall(stdout)
    if rex:metadata['cols'],metadata['rows']=[int(r) for r in rex[0]]

    rex=r'Coordinate System is:\s*(.*\])'
    rex=re.compile(rex, re.I)
    rex=rex.findall(' '.join([s.strip() for s in stdout.split('\n')]))
    if rex:metadata['srs']=rex[0]


    rex=r'Pixel Size\s*=\s*\(%s,%s\)' % (decimal,decimal)
    rex=re.compile(rex, re.I)
    rex=rex.findall(stdout)
    if rex:metadata['cellx'],metadata['celly']=[float(r) for r in rex[0]]

    rex=r'Upper Left\s*\(\s*%s\s*,\s*%s\)' % (decimal,decimal)
    rex=re.compile(rex, re.I)
    rex=rex.findall(stdout)
    if rex:extent.append([float(r) for r in rex[0]])

    rex=r'Upper Right\s*\(\s*%s\s*,\s*%s\)' % (decimal,decimal)
    rex=re.compile(rex, re.I)
    rex=rex.findall(stdout)
    if rex:extent.append([float(r) for r in rex[0]])

    rex=r'Lower Left\s*\(\s*%s\s*,\s*%s\)' % (decimal,decimal)
    rex=re.compile(rex, re.I)
    rex=rex.findall(stdout)
    if rex:extent.append([float(r) for r in rex[0]])

    rex=r'Lower Right\s*\(\s*%s\s*,\s*%s\)' % (decimal,decimal)
    rex=re.compile(rex, re.I)
    rex=rex.findall(stdout)
    if rex:extent.append([float(r) for r in rex[0]])

    rex=r'Band \d'
    rex=re.compile(rex, re.I)
    rex=rex.findall(stdout)
    if rex:metadata['nbands']=len(rex)

    rex=r'Type=(%s)' % '|'.join([gdal.GetDataTypeName(dt) for dt in range(0,gdal.GDT_TypeCount)])
    rex=re.compile(rex, re.I)
    rex=rex.findall(stdout)
    if rex:metadata['datatype']=rex[0]
    
    rex=r'NoData Value='+decimal
    rex=re.compile(rex, re.I)
    rex=rex.findall(stdout)
    if rex:metadata['nodata']=rex[0]

    return metadata,extent