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


Python Plugin.create_from_zip方法代码示例

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


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

示例1: post

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import create_from_zip [as 别名]
 def post(self):
     data = StringIO(request.data)
     try:
         plugin = Plugin.create_from_zip(data)
     except ValidationError as e:
         return {'result': 'error', 'message': "%s" % e}
     return {'result': 'success', 'plugin': plugin.metadata}
开发者ID:boundlessgeo,项目名称:qgis-plugin-repos,代码行数:9,代码来源:main.py

示例2: plugin_upload

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import create_from_zip [as 别名]
def plugin_upload():
    message = None
    if request.method == 'POST':
        # check if the post request has the file part
        if 'file' not in request.files:
            message = 'No file part'
        else:
            file = request.files['file']
            # if user does not select file, browser also
            # submit a empty part without filename
            if file.filename == '':
                message = 'No selected file'
            elif file and '.' in file.filename and \
                    file.filename.rsplit('.', 1)[1] == 'zip':
                file.filename = secure_filename(file.filename)
                # Create plugin
                try:
                    plugin = Plugin.create_from_zip(file, file.filename)
                    message = 'Plugin {} version {} created'.format(plugin.name, plugin.version)
                except ValidationError as e:
                    render_error('<b>{}</b> is not valid {}'.format(key, e))
            else:
                message = 'File does not have a zip extension'
    log("Plugin upload message: %s" % message)
    return render_template('upload.html', message=message)
开发者ID:boundlessgeo,项目名称:qgis-plugin-repos,代码行数:27,代码来源:main.py

示例3: app_bootstrap

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import create_from_zip [as 别名]
def app_bootstrap():
    """Load all zipfile plugins from the zipfiles folder"""
    zipfolder = os.path.join(os.path.dirname(__file__), 'zipfiles')
    if os.path.isdir(zipfolder):
        for path in [f for f in os.listdir(zipfolder)
                     if (os.path.isfile(os.path.join(zipfolder, f))
                     and f.endswith('.zip'))]:
            try:
                plugin = Plugin.create_from_zip(open(os.path.join(zipfolder, path)))
                log("Plugin: %s has been succesfully loaded" % plugin.key)
            except ValidationError as e:
                log("Plugin file: %s could not be loaded: %s" % (path, e))
开发者ID:boundlessgeo,项目名称:qgis-plugin-repos,代码行数:14,代码来源:main.py


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