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


Python app.config方法代码示例

本文整理汇总了Python中app.app.config方法的典型用法代码示例。如果您正苦于以下问题:Python app.config方法的具体用法?Python app.config怎么用?Python app.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.app的用法示例。


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

示例1: renderFeedsTable

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def renderFeedsTable(page=1):

	feeds = g.session.query(db.RssFeedPost)       \
		.order_by(desc(db.RssFeedPost.published))


	feeds = feeds.options(joinedload('tag_rel'))
	feeds = feeds.options(joinedload('author_rel'))



	if feeds is None:
		flash('No feeds? Something is /probably/ broken!.')
		return redirect(url_for('renderFeedsTable'))

	feed_entries = paginate(feeds, page, app.config['FEED_ITEMS_PER_PAGE'])

	return render_template('rss-pages/feeds.html',
						   subheader = "",
						   sequence_item   = feed_entries,
						   page            = page
						   ) 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:24,代码来源:rss_views.py

示例2: renderFeedsTagTable

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def renderFeedsTagTable(tag, page=1):
	query = g.session.query(db.RssFeedPost)
	# query = query.join(db.Tags)
	query = query.filter(db.RssFeedPost.tags.contains(tag))
	query = query.order_by(desc(db.RssFeedPost.published))

	feeds = query

	if feeds is None:
		flash('No feeds? Something is /probably/ broken!.')
		return redirect(url_for('renderFeedsTable'))

	feed_entries = paginate(feeds, page, app.config['FEED_ITEMS_PER_PAGE'])

	return render_template('rss-pages/feeds.html',
						   subheader = "Tag = '%s'" % tag,
						   sequence_item   = feed_entries,
						   page            = page
						   ) 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:21,代码来源:rss_views.py

示例3: renderFeedsSourceTable

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def renderFeedsSourceTable(source, page=1):
	feeds = g.session.query(db.RssFeedPost) \
		.filter(db.RssFeedPost.srcname == source)  \
		.order_by(desc(db.RssFeedPost.published))

	if feeds is None:
		flash('No feeds? Something is /probably/ broken!.')
		return redirect(url_for('renderFeedsTable'))

	feed_entries = paginate(feeds, page, app.config['FEED_ITEMS_PER_PAGE'])

	return render_template('rss-pages/feeds.html',
						   subheader = "Source = '%s'" % source,
						   sequence_item   = feed_entries,
						   page            = page
						   ) 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:18,代码来源:rss_views.py

示例4: upload_file

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def upload_file():
	# check if the post request has the file part
	if 'file' not in request.files:
		resp = jsonify({'message' : 'No file part in the request'})
		resp.status_code = 400
		return resp
	file = request.files['file']
	if file.filename == '':
		resp = jsonify({'message' : 'No file selected for uploading'})
		resp.status_code = 400
		return resp
	if file and allowed_file(file.filename):
		filename = secure_filename(file.filename)
		file.save(os.path.join(os.path.dirname(os.path.abspath(__file__)), app.config['UPLOAD_FOLDER'], filename))
		resp = jsonify({'message' : 'File {} successfully uploaded to {}'.format(filename, os.path.dirname(os.path.abspath(__file__)))})
		resp.status_code = 201
		return resp
	else:
		resp = jsonify({'message' : 'Allowed file types are txt, csv, xlsx, xls'})
		resp.status_code = 400
		return resp 
开发者ID:paulozip,项目名称:arauto,代码行数:23,代码来源:main.py

示例5: __init__

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def __init__(self, local=True):
        
        if local:
        # Class instance connection to Mongo
            self.connection = MongoClient()
    
            if config.AUTH:
                try:
                    self.connection.admin.authenticate(config.USERNAME, config.PASSWORD)
                except:
                    print('Error: Authentication failed. Please check:\n1. MongoDB credentials in config.py\n2. MongoDB uses the correct authentication schema (MONGODB-CR)\nFor more info. see https://github.com/bitslabsyr/stack/wiki/Installation')
                    sys.exit(1)
                
            # App-wide config file for project info access
            self.config_db = self.connection.config
            self.stack_config = self.config_db.config
        else:
            self.connection = MongoClient(config.CT_SERVER)
    
            if config.CT_AUTH:
                try:
                    self.connection.admin.authenticate(config.CT_USERNAME, config.CT_PASSWORD)
                except:
                    print('Error: Authentication failed at the central server. Please check:\n1. MongoDB credentials in config.py\n2. MongoDB uses the correct authentication schema (MONGODB-CR)\nFor more info. see https://github.com/bitslabsyr/stack/wiki/Installation')
                    sys.exit(1) 
开发者ID:bitslabsyr,项目名称:stack,代码行数:27,代码来源:models.py

示例6: get_collector_detail

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def get_collector_detail(self, project_id, collector_id):
        """
        When passed a collector_id, returns that collectors details
        """
        project = self.get_project_detail(project_id)

        if project['status']:
            configdb = project['project_config_db']

            project_config_db = self.connection[configdb]
            coll = project_config_db.config

            collector = coll.find_one({'_id': ObjectId(collector_id)})
            if collector:
                collector['_id'] = str(collector['_id'])
                resp = {'status': 1, 'message': 'Success', 'collector': collector}
            else:
                resp = {'status': 0, 'message': 'Failed'}
        else:
            resp = {'status': 0, 'message': 'Failed'}

        return resp 
开发者ID:bitslabsyr,项目名称:stack,代码行数:24,代码来源:models.py

示例7: get_network_detail

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def get_network_detail(self, project_id, network):
        """
        Returns details for a network module. To be used by the Controller.
        """
        project = self.get_project_detail(project_id)

        if project['status']:
            configdb = project['project_config_db']

            project_config_db = self.connection[configdb]
            coll = project_config_db.config

            network = coll.find_one({'module': network})
            if network:
                network['_id'] = str(network['_id'])
                resp = {'status': 1, 'message': 'Success', 'network': network}
            else:
                resp = {'status': 0, 'message': 'Failed'}
        else:
            resp = {'status': 0, 'message': 'Failed'}

        return resp 
开发者ID:bitslabsyr,项目名称:stack,代码行数:24,代码来源:models.py

示例8: _load_project_config_db

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def _load_project_config_db(self, project_id):
        """
        Utility method to load a project account's config DB

        :param project_id:

        :return: project_config_db connection
        """
        # Finds project db
        project_info = self.get_project_detail(project_id)
        configdb = project_info['project_config_db']

        # Makes a connection to the config db
        project_config_db = self.connection[configdb]

        return project_config_db 
开发者ID:bitslabsyr,项目名称:stack,代码行数:18,代码来源:models.py

示例9: webfile

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def webfile():
    if PCAPS == None:
        flash("请先上传要分析的数据包!")
        return redirect(url_for('upload'))
    else:
        host_ip = get_host_ip(PCAPS)
        filepath = app.config['FILE_FOLDER'] + 'Web/'
        web_list = web_file(PCAPS, host_ip, filepath)
        file_dict = dict()
        for web in web_list:
            file_dict[os.path.split(web['filename'])[-1]] = web['filename']
        file = request.args.get('file')
        if file in file_dict:
            filename = hashlib.md5(file.encode(
                'UTF-8')).hexdigest() + '.' + file.split('.')[-1]
            os.rename(filepath+file, filepath+filename)
            return send_from_directory(filepath, filename, as_attachment=True)
        else:
            return render_template('./fileextract/webfile.html', web_list=web_list)

# Mail文件提取 
开发者ID:HatBoy,项目名称:Pcap-Analyzer,代码行数:23,代码来源:views.py

示例10: ftpfile

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def ftpfile():
    if PCAPS == None:
        flash("请先上传要分析的数据包!")
        return redirect(url_for('upload'))
    else:
        host_ip = get_host_ip(PCAPS)
        filepath = app.config['FILE_FOLDER'] + 'FTP/'
        ftp_list = ftp_file(PCAPS, host_ip, filepath)
        file_dict = dict()
        for ftp in ftp_list:
            file_dict[os.path.split(ftp['filename'])[-1]] = ftp['filename']
        file = request.args.get('file')
        if file in file_dict:
            filename = hashlib.md5(file.encode(
                'UTF-8')).hexdigest() + '.' + file.split('.')[-1]
            os.rename(filepath+file, filepath+filename)
            return send_from_directory(filepath, filename, as_attachment=True)
        else:
            return render_template('./fileextract/ftpfile.html', ftp_list=ftp_list)

# 所有二进制文件提取 
开发者ID:HatBoy,项目名称:Pcap-Analyzer,代码行数:23,代码来源:views.py

示例11: allfile

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def allfile():
    if PCAPS == None:
        flash("请先上传要分析的数据包!")
        return redirect(url_for('upload'))
    else:
        filepath = app.config['FILE_FOLDER'] + 'All/'
        allfiles_dict = all_files(PCAPS, filepath)
        file = request.args.get('file')
        if file in allfiles_dict:
            filename = hashlib.md5(file.encode(
                'UTF-8')).hexdigest() + '.' + file.split('.')[-1]
            os.rename(filepath+file, filepath+filename)
            return send_from_directory(filepath, filename, as_attachment=True)
        else:
            return render_template('./fileextract/allfile.html', allfiles_dict=allfiles_dict)


# ----------------------------------------------错误处理页面--------------------------------------------- 
开发者ID:HatBoy,项目名称:Pcap-Analyzer,代码行数:20,代码来源:views.py

示例12: run_migrations_offline

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def run_migrations_offline():
    """
    Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.

    Calls to context.execute() here emit the given string to the
    script output.
    """
    url = unquote(DB_URI)
    context.configure(url=url, target_metadata=target_metadata, transactional_ddl=True)
    context.config.attributes["progress_reporter"] = progress_reporter
    op = ProgressWrapper(alembic_op, NullReporter())

    with context.begin_transaction():
        context.run_migrations(op=op, tables=tables, tester=get_tester()) 
开发者ID:quay,项目名称:quay,代码行数:21,代码来源:env.py

示例13: test_perform_indexing

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def test_perform_indexing(next_token, expected_next_token, initialized_db):
    app.config["SECURITY_SCANNER_V4_NAMESPACE_WHITELIST"] = ["devtable"]
    app.config["SECURITY_SCANNER_V4_ENDPOINT"] = "http://clairv4:6060"

    def secscan_api(*args, **kwargs):
        api = Mock()
        api.state.return_value = {"state": "abc"}
        api.index.return_value = ({"err": None, "state": IndexReportState.Index_Finished}, "abc")

        return api

    def layer_analyzer(*args, **kwargs):
        return Mock()

    with patch("data.secscan_model.secscan_v4_model.ClairSecurityScannerAPI", secscan_api):
        with patch("util.secscan.analyzer.LayerAnalyzer", layer_analyzer):
            secscan_model.configure(app, instance_keys, storage)

            assert secscan_model.perform_indexing(next_token) == expected_next_token 
开发者ID:quay,项目名称:quay,代码行数:21,代码来源:test_secscan_interface.py

示例14: test_perform_indexing_whitelist

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def test_perform_indexing_whitelist(initialized_db, set_secscan_config):
    app.config["SECURITY_SCANNER_V4_NAMESPACE_WHITELIST"] = ["devtable"]
    expected_manifests = (
        Manifest.select().join(Repository).join(User).where(User.username == "devtable")
    )

    secscan = V4SecurityScanner(app, instance_keys, storage)
    secscan._secscan_api = mock.Mock()
    secscan._secscan_api.state.return_value = {"state": "abc"}
    secscan._secscan_api.index.return_value = (
        {"err": None, "state": IndexReportState.Index_Finished},
        "abc",
    )

    next_token = secscan.perform_indexing()

    assert secscan._secscan_api.index.call_count == expected_manifests.count()
    for mss in ManifestSecurityStatus.select():
        assert mss.repository.namespace_user.username == "devtable"
    assert ManifestSecurityStatus.select().count() == expected_manifests.count()
    assert (
        Manifest.get_by_id(next_token.min_id - 1).repository.namespace_user.username == "devtable"
    ) 
开发者ID:quay,项目名称:quay,代码行数:25,代码来源:test_secscan_v4_model.py

示例15: _sign_derived_image

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import config [as 别名]
def _sign_derived_image(verb, derived_image, queue_file):
    """
    Read from the queue file and sign the contents which are generated.

    This method runs in a separate process.
    """
    signature = None
    try:
        signature = signer.detached_sign(queue_file)
    except Exception as e:
        logger.exception(
            "Exception when signing %s deriving image %s: $s", verb, derived_image, str(e)
        )
        return

    # Setup the database (since this is a new process) and then disconnect immediately
    # once the operation completes.
    if not queue_file.raised_exception:
        with database.UseThenDisconnect(app.config):
            registry_model.set_derived_image_signature(derived_image, signer.name, signature) 
开发者ID:quay,项目名称:quay,代码行数:22,代码来源:__init__.py


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