def plugin_install(app, fobj, request, filename): """Installs a plugin: - Identifies file type by filename - Writes `fobj` contents to the `../deposit/` folder - Calls `w2p_unpack_plugin()` to do the job. Args: app(str): new application name fobj: file object containing the application to be installed request: the global request object filename: original filename of the `fobj`, required to determine extension Returns: name of the file where plugin is temporarily stored or `False` on failure """ upname = apath('../deposit/%s' % filename, request) try: write_file(upname, fobj.read(), 'wb') path = apath(app, request) w2p_unpack_plugin(upname, path) fix_newlines(path) return upname except Exception: os.unlink(upname) return False
def unpack(packed_plugin): w2p_unpack_plugin(packed_plugin, web2py_demo_app) # verify file1 = root/'controllers'/'plugin_instant_admin.py' file2 = web2py_demo_app/'controllers'/'plugin_instant_admin.py' assert filecmp.cmp(file1, file2)
def unpack(packed_plugin): w2p_unpack_plugin(packed_plugin, web2py_demo_app) # verify file1 = root / 'controllers' / 'plugin_instant_admin.py' file2 = web2py_demo_app / 'controllers' / 'plugin_instant_admin.py' assert filecmp.cmp(file1, file2)