Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(14)  |  Call(10)  |  Derive(0)  |  Import(4)

        def grids_command(args=None):
    parser = optparse.OptionParser("%prog grids [options] mapproxy_conf")
    parser.add_option("-f", "--mapproxy-conf", dest="mapproxy_conf",
        help="MapProxy configuration.")
    parser.add_option("-g", "--grid", dest="grid_name",
        help="Display only information about the specified grid.")
    parser.add_option("--all", dest="show_all", action="store_true", default=False,
        help="Show also grids that are not referenced by any cache.")
    parser.add_option("-l", "--list", dest="list_grids", action="store_true", default=False, help="List names of configured grids, which are used by any cache")
    coverage_group = parser.add_option_group("Approximate the number of tiles within a given coverage")
    coverage_group.add_option("-s", "--seed-conf", dest="seed_config", help="Seed configuration, where the coverage is defined")
    coverage_group.add_option("-c", "--coverage-name", dest="coverage", help="Calculate number of tiles when a coverage is given")

    from mapproxy.script.util import setup_logging
    import logging
    setup_logging(logging.WARN)

    if args:
        args = args[1:] # remove script name

    (options, args) = parser.parse_args(args)
    if not options.mapproxy_conf:
        if len(args) != 1:
            parser.print_help()
            sys.exit(1)
        else:
            options.mapproxy_conf = args[0]
    try:
        proxy_configuration = load_configuration(options.mapproxy_conf)
    except IOError, e:
        print >>sys.stderr, 'ERROR: ', "%s: '%s'" % (e.strerror, e.filename)
        sys.exit(2)
    except ConfigurationError, e:
        print >>sys.stderr, 'ERROR: invalid configuration (see above)'
        sys.exit(2)

    if options.show_all or options.grid_name:
        grids = proxy_configuration.grids
    else:
        caches = proxy_configuration.caches
        grids = {}
        for cache in caches.values():
            grids.update(cache.grid_confs())
        grids = dict(grids)

    if options.grid_name:
        options.grid_name = options.grid_name.lower()
        # ignore case for keys
        grids = dict((key.lower(), value) for (key, value) in grids.iteritems())
        if not grids.get(options.grid_name, False):
            print 'grid not found: %s' % (options.grid_name,)
            sys.exit(1)

    coverage = None
    if options.coverage and options.seed_config:
        with local_base_config(proxy_configuration.base_config):
            try:
                seed_conf = load_seed_tasks_conf(options.seed_config, proxy_configuration)
            except SeedConfigurationError, e:
                print >>sys.stderr, 'ERROR: invalid configuration (see above)'
                sys.exit(2)

            if not isinstance(seed_conf, SeedingConfiguration):
                print 'Old seed configuration format not supported'
                sys.exit(1)

            coverage = seed_conf.coverage(options.coverage)
            coverage.name = options.coverage

    elif (options.coverage and not options.seed_config) or (not options.coverage and options.seed_config):
        print '--coverage and --seed-conf can only be used together'
        sys.exit(1)

    if options.list_grids:
        display_grids_list(grids)
    elif options.grid_name:
        display_grids({options.grid_name: grids[options.grid_name]}, coverage=coverage)
    else:
        display_grids(grids, coverage=coverage)
        


src/m/a/MapProxy-1.6.0/mapproxy/script/util.py   MapProxy(Download)
from mapproxy.script.scales import scales_command
from mapproxy.script.wms_capabilities import wms_capabilities_command
from mapproxy.script.grids import grids_command
from mapproxy.script.export import export_command
 

src/m/a/mapproxy-HEAD/mapproxy/script/util.py   mapproxy(Download)
from mapproxy.script.scales import scales_command
from mapproxy.script.wms_capabilities import wms_capabilities_command
from mapproxy.script.grids import grids_command
from mapproxy.script.export import export_command
from mapproxy.script.conf.app import config_command

src/m/a/MapProxy-1.6.0/mapproxy/test/system/test_util_grids.py   MapProxy(Download)
from cStringIO import StringIO
from nose.tools import assert_raises
from mapproxy.script.grids import grids_command
 
FIXTURE_DIR = os.path.join(os.path.dirname(__file__), 'fixture')
    def test_list_configured(self):
        self.args.append('-l')
        grids_command(self.args)
        captured_output = sys.stdout.getvalue()
        for grid in GRID_NAMES:
    def test_list_configured_all(self):
        self.args.append('-l')
        self.args.append('--all')
        grids_command(self.args)
        captured_output = sys.stdout.getvalue()
    def test_display_single_grid(self):
        self.args.append('-g')
        self.args.append('GLOBAL_MERCATOR')
        grids_command(self.args)
        captured_output = sys.stdout.getvalue()
    def test_ignore_case(self):
        self.args.append('-g')
        self.args.append('global_geodetic')
        grids_command(self.args)
        captured_output = sys.stdout.getvalue()

src/m/a/mapproxy-HEAD/mapproxy/test/system/test_util_grids.py   mapproxy(Download)
from cStringIO import StringIO
from nose.tools import assert_raises
from mapproxy.script.grids import grids_command
 
FIXTURE_DIR = os.path.join(os.path.dirname(__file__), 'fixture')
    def test_list_configured(self):
        self.args.append('-l')
        grids_command(self.args)
        captured_output = sys.stdout.getvalue()
        for grid in GRID_NAMES:
    def test_list_configured_all(self):
        self.args.append('-l')
        self.args.append('--all')
        grids_command(self.args)
        captured_output = sys.stdout.getvalue()
    def test_display_single_grid(self):
        self.args.append('-g')
        self.args.append('GLOBAL_MERCATOR')
        grids_command(self.args)
        captured_output = sys.stdout.getvalue()
    def test_ignore_case(self):
        self.args.append('-g')
        self.args.append('global_geodetic')
        grids_command(self.args)
        captured_output = sys.stdout.getvalue()