当前位置: 首页>>代码示例>>Python>>正文


Python script.CommandLineEnvironment类代码示例

本文整理汇总了Python中webassets.script.CommandLineEnvironment的典型用法代码示例。如果您正苦于以下问题:Python CommandLineEnvironment类的具体用法?Python CommandLineEnvironment怎么用?Python CommandLineEnvironment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommandLineEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build

    def build(self):
        logger = getLogger('webassets')
        logger.addHandler(StreamHandler())
        logger.setLevel(DEBUG)

        cli_environment = CommandLineEnvironment(self.env, logger)
        cli_environment.invoke("build", args={})
开发者ID:rembish,项目名称:rembish-org,代码行数:7,代码来源:assets_ext.py

示例2: _build_webassets

 def _build_webassets(self):
     # Set up a logger
     log = logging.getLogger('webassets')
     log.addHandler(logging.StreamHandler())
     log.setLevel(logging.DEBUG)
     cmdenv = CommandLineEnvironment(self.webassets_env, log)
     cmdenv.build()
开发者ID:gharp,项目名称:Ubiqu-Ity,代码行数:7,代码来源:__init__.py

示例3: handle

    def handle(self, *args, **options):
        valid_commands = CommandLineEnvironment.Commands
        if len(args) > 1:
            raise CommandError('Invalid number of subcommands passed: %s' %
                ", ".join(args))
        elif len(args) == 0:
            raise CommandError('You need to specify a subcommand: %s' %
                               ', '.join(valid_commands))

        # Create log
        log = logging.getLogger('django-assets')
        log.setLevel({0: logging.WARNING, 1: logging.INFO, 2: logging.DEBUG}[int(options.get('verbosity', 1))])
        log.addHandler(logging.StreamHandler())

        # If the user requested it, search for bundles defined in templates
        if options.get('parse_templates'):
            log.info('Searching templates...')
            # Note that we exclude container bundles. By their very nature,
            # they are guaranteed to have been created by solely referencing
            # other bundles which are already registered.
            get_env().add(*[b for b in self.load_from_templates()
                            if not b.is_container])

        if len(get_env()) == 0:
            raise CommandError('No asset bundles were found. '
                'If you are defining assets directly within your '
                'templates, you want to use the --parse-templates '
                'option.')

        # Execute the requested subcommand
        cmd = CommandLineEnvironment(get_env(), log)
        try:
            cmd.invoke(args[0])
        except AssetCommandError, e:
            raise CommandError(e)
开发者ID:lyschoening,项目名称:webassets,代码行数:35,代码来源:assets.py

示例4: js

def js():
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.WARNING)

    cmdenv = CommandLineEnvironment(assets_env, log)
    cmdenv.build()
开发者ID:nukomeet,项目名称:kulfon,代码行数:7,代码来源:kulfon.py

示例5: _init_webassets

def _init_webassets(debug=False):
    assets_env = Environment(directory=SITE_ASSET_DIR,
                             url=SITE_ASSET_URL_PREFIX,
                             cache=WEBASSETS_CACHE_DIR,
                             load_path=[SITE_ASSET_SRC_DIR])
    assets_env.debug = debug

    js = Bundle('js/*.js', filters='uglifyjs', output='js/app.js')
    css = Bundle('sass/*.scss', filters='scss,cssmin', output='css/app.css')

    assets_env.register('app_js', js)
    assets_env.register('app_css', css)

    cmd = CommandLineEnvironment(assets_env, log)

    p = Process(target=lambda: cmd.watch())

    def signal_handler(sig, frame):
        try:
            p.terminate()
        except Exception:
            pass
        sys.exit(0)

    signal.signal(signal.SIGINT, signal_handler)
    p.start()

    return assets_env
开发者ID:jackzhangpython,项目名称:PyConChina2016,代码行数:28,代码来源:gen.py

示例6: static

def static(path, input):
    '''Compile and collect static files'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    if exists(path):
        print('"{0}" directory already exists and will be erased'.format(path))
        if input and not prompt_bool('Are you sure'):
            exit(-1)

    cmdenv = CommandLineEnvironment(assets, log)
    # cmdenv.clean()
    cmdenv.build(production=True)

    print('Deleting static directory {0}'.format(path))
    shutil.rmtree(path)

    print('Copying assets into "{0}"'.format(path))
    shutil.copytree(assets.directory, path)

    for prefix, source in manager.app.config['STATIC_DIRS']:
        print('Copying %s to %s', source, prefix)
        destination_path = join(path, prefix)
        if not exists(destination_path):
            makedirs(destination_path)
        for filename in iglob(join(source, '*')):
            print(filename)
            if isdir(filename):
                continue
            shutil.copy(filename, destination_path)
        # shutil.copy(static_dir, path)

    print('Done')
开发者ID:rossjones,项目名称:udata,代码行数:34,代码来源:static.py

示例7: main

def main():
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    call(["coffee", "-c", "src/tambur.coffee"])
    call(["coffee", "-c", "src/tambur_publisher.coffee"])

    env = Environment('.', '/static')
    tamburjs = Bundle(
            'deps/sockjs-0.3.js',
            'src/tambur.js', output='out/tambur.js')
    tamburminjs = Bundle(
            'deps/sockjs-0.3.js',
            'src/tambur.js', filters='yui_js', output='out/tambur.min.js')
    publishjs = Bundle(
            'deps/sha1.js',
            'deps/oauth.js',
            'src/tambur_publisher.js', output='out/tambur_pub.js')
    publishminjs = Bundle(
            'deps/sha1.js',
            'deps/oauth.js',
            'src/tambur_publisher.js', filters='yui_js', output='out/tambur_pub.min.js')
    env.register('tambur.js', tamburjs)
    env.register('tambur.min.js', tamburminjs)
    env.register('tambur_pub.js', publishjs)
    env.register('tambur_pub.min.js', publishminjs)
    cmdenv = CommandLineEnvironment(env, log)
    cmdenv.build()
开发者ID:tamburio,项目名称:tambur.js,代码行数:29,代码来源:assets.py

示例8: handle

 def handle(self, app, **kwargs):
     assets = Environment(app)
     assets.url = app.static_url_path# = os.path.join(_appdir, 'static')
     assets.register('all_css', app.bundles['all_css_min'])
     assets.register('all_js', app.bundles['all_js_min'])
     log = logging.getLogger('webassets')
     log.addHandler(logging.StreamHandler())
     log.setLevel(logging.DEBUG)
     cmdenv = CommandLineEnvironment(assets, log)
     cmdenv.invoke('build', kwargs)
开发者ID:gloaec,项目名称:bamboo,代码行数:10,代码来源:assets.py

示例9: clear_css_cache

def clear_css_cache():
    import logging
    from webassets.script import CommandLineEnvironment

    # Setup a logger
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets, log)
    cmdenv.clean()
开发者ID:joehand,项目名称:pdx_ulti,代码行数:11,代码来源:manage.py

示例10: rebuild_assets

def rebuild_assets(config):
    config = config.copy()
    config['assets.debug'] = True
    assets = make_assets(config)
    assets_dir = assets.env.directory
    # Remove existing assets
    for name, bundle in assets.env._named_bundles.items():
        path = os.path.join(assets_dir, bundle.output) % {'version': '*'}
        for p in glob.iglob(path):
            os.unlink(p)
    cmdenv = CommandLineEnvironment(assets.env, logging.getLogger('assets'))
    cmdenv.invoke('build', {})
开发者ID:Outernet-Project,项目名称:broadcast-portal,代码行数:12,代码来源:static.py

示例11: build_assets

def build_assets(mod):
    from webassets.script import CommandLineEnvironment

    module = import_module(mod, True)
    assets_env = module.app.jinja_env.assets_environment

    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets_env, log)
    cmdenv.build()
开发者ID:mardix,项目名称:flask-magic,代码行数:12,代码来源:cli.py

示例12: _buildassets

def _buildassets(app):

    from webassets.script import CommandLineEnvironment

    module = get_app_serve_module(app)
    assets_env = module.app.jinja_env.assets_environment

    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets_env, log)
    cmdenv.build()
开发者ID:mardix,项目名称:webportfolio,代码行数:13,代码来源:cli.py

示例13: static

def static(path, input):
    '''Compile and collect static files'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets, log)
    cmdenv.build()

    if exists(path):
        print('"{0}" directory already exists and will be erased'.format(path))
        if input and not prompt_bool('Are you sure'):
            exit(-1)
        shutil.rmtree(path)

    print('Copying assets into "{0}"'.format(path))
    shutil.copytree(assets.directory, path)

    print('Done')
开发者ID:pborreli,项目名称:cada,代码行数:19,代码来源:commands.py

示例14: static

def static(path, no_input):
    '''Compile and collect static files into path'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets, log)
    cmdenv.build()

    if exists(path):
        warning('{0} directory already exists and will be {1}', white(path), white('erased'))
        if not no_input and not click.confirm('Are you sure'):
            exit_with_error()
        shutil.rmtree(path)

    echo('Copying assets into {0}', white(path))
    shutil.copytree(assets.directory, path)

    success('Done')
开发者ID:etalab,项目名称:cada,代码行数:19,代码来源:commands.py

示例15: TestCLI

class TestCLI(object):
    def setup(self):
        self.assets_env = Environment("", "")
        self.cmd_env = CommandLineEnvironment(self.assets_env, logging)

    def test_rebuild_container_bundles(self):
        """Test the rebuild command can deal with container bundles.
        """
        a = MockBundle(output="a")
        b1 = MockBundle(output="b1")
        b2 = MockBundle(output="b2")
        b = MockBundle(b1, b2)
        self.assets_env.add(a, b)

        self.cmd_env.rebuild()

        assert a.build_called
        assert not b.build_called
        assert b1.build_called
        assert b2.build_called
开发者ID:jamorton,项目名称:webassets,代码行数:20,代码来源:test_script.py


注:本文中的webassets.script.CommandLineEnvironment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。