How to use plugin method in stryker-parent

Best JavaScript code snippet using stryker-parent

pandora-plugin

Source:pandora-plugin Github

copy

Full Screen

...134""" % plugin)135 plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am')136 if os.path.exists(plugin_am_file):137 plugin_file.write('include %s\n' % plugin_am_file)138def write_external_plugin():139 """Return True if the plugin had changed."""140 plugin = read_plugin_ini('.')141 expand_plugin_ini(plugin)142 plugin_file = ChangeProtectedFile('configure.ac')143 write_external_configure(plugin, plugin_file)144 result = plugin_file.close()145 plugin_file = ChangeProtectedFile('Makefile.am')146 write_external_makefile(plugin, plugin_file)147 # Write some stub configure.ac and Makefile.am files that include the above148 result = plugin_file.close() or result149 return result150def write_plugin(plugin, plugin_ini_list):151 # Since this function is recursive, make sure we're not already in it.152 if plugin.has_key('writing_status'):153 if plugin['writing_status'] == 'done':154 return155 else:156 print "Dependency loop detected with %s" % plugin['name']157 exit(1)158 plugin['writing_status'] = 'dependencies'159 # Write all dependencies first to get around annoying automake bug160 for dependency in plugin['dependency_list']:161 found = False162 for find_plugin in plugin_ini_list:163 if find_plugin['module_name'] == dependency:164 found = True165 write_plugin(find_plugin, plugin_ini_list)166 break167 if found is False:168 print "Could not find dependency %s: %s" % (plugin['name'], dependency)169 exit(1)170 write_plugin_ac(plugin, plugin_ac_file)171 write_plugin_am(plugin, plugin_am_file)172 write_plugin_docs(plugin, plugin_doc_index, plugin_am_file)173 plugin['writing_status'] = 'done'174def write_plugin_docs(plugin, doc_index, plugin_am):175 if plugin['docs'] is not None and os.path.isdir("docs/plugins"):176 if not os.path.exists(os.path.join("docs/plugins",plugin["name"])):177 os.symlink(os.path.abspath(plugin["docs"]), os.path.join("docs/plugins",plugin["name"]))178 doc_index.write("""179 %(name)s/index""" % plugin)180 plugin_am.write("""181EXTRA_DIST+=${top_srcdir}/docs/plugins/%(name)s/*.rst182""" % plugin)183def write_plugin_ac(plugin, plugin_ac):184 #185 # Write plugin config instructions into plugin.ac file.186 #187 plugin_ac_file=os.path.join(plugin['rel_path'],'plugin.ac')188 plugin_m4_dir=os.path.join(plugin['rel_path'],'m4')189 plugin_m4_files=[]190 if os.path.exists(plugin_m4_dir) and os.path.isdir(plugin_m4_dir):191 for m4_file in os.listdir(plugin_m4_dir):192 if os.path.splitext(m4_file)[-1] == '.m4':193 plugin_m4_files.append(os.path.join(plugin['rel_path'], m4_file))194 plugin_ac.write("""195dnl Config for %(title)s196""" % plugin)197 for m4_file in plugin_m4_files:198 plugin_ac.write('m4_sinclude([%s])\n' % m4_file)199 plugin['plugin_dep_libs']=" ".join(["\${top_builddir}/%s" % f for f in plugin['libs'].split()])200 plugin_ac.write("""201AC_ARG_WITH([%(name_with_dashes)s-plugin],[202dnl indented wierd to make the help output correct203AS_HELP_STRING([--with-%(name_with_dashes)s-plugin],[Build %(title)s. @<:@default=%(enabled)s@:>@])204AS_HELP_STRING([--without-%(name_with_dashes)s-plugin],[Disable building %(title)s])205 ],[206 with_%(name)s_plugin="$withval"207 AS_IF([test "x$with_%(name)s_plugin" = "xyes"],[208 requested_%(name)s_plugin="yes"209 ],[210 requested_%(name)s_plugin="no"211 ])212 ],[213 with_%(name)s_plugin="%(enabled)s"214 requested_%(name)s_plugin="no"215 ])216AC_ARG_WITH([static-%(name_with_dashes)s-plugin],[217AS_HELP_STRING([--with-static-%(name_with_dashes)s-plugin],[Build Archive Storage Engine. @<:@default=%(static_yesno)s@:>@])218AS_HELP_STRING([--without-static-%(name_with_dashes)s-plugin],[Disable building Archive Storage Engine])219 ],[220 with_static_%(name)s_plugin=${withval}221 ],[222 with_static_%(name)s_plugin=%(static_yesno)s223])224AS_IF([test "x${with_static_%(name)s_plugin}" = "xyes" -o "x${with_all_static}" = "xyes"],[225 shared_%(name)s_plugin=no226 ],[227 shared_%(name)s_plugin=yes228])229AC_ARG_ENABLE([%(name_with_dashes)s-plugin],[230dnl indented wierd to make the help output correct231AS_HELP_STRING([--enable-%(name_with_dashes)s-plugin],[Enable loading %(title)s by default. @<:@default=%(default_yesno)s@:>@])232AS_HELP_STRING([--disable-%(name_with_dashes)s-plugin],[Disable loading %(title)s by default.])233 ],234 [enable_%(name)s_plugin="$enableval"],235 [enable_%(name)s_plugin=%(default_yesno)s])236""" % plugin)237 if os.path.exists(plugin_ac_file):238 plugin_ac.write('m4_sinclude([%s])\n' % plugin_ac_file)239 # The plugin author has specified some check to make to determine240 # if the plugin can be built. If the plugin is turned on and this241 # check fails, then configure should error out. If the plugin is not242 # turned on, then the normal conditional build stuff should just let243 # it silently not build244 if plugin['has_build_conditional']:245 plugin_ac.write("""246AS_IF([test %(build_conditional)s],247 [], dnl build_conditional can only negate248 [249 AS_IF([test "x${requested_%(name)s_plugin}" = "xyes"],250 [AC_MSG_ERROR([Plugin %(name)s was explicitly requested, yet failed build dependency checks. Aborting!])])251 with_%(name)s_plugin=no252 ])253""" % plugin)254 if not plugin['unconditional']:255 plugin_ac.write("""256AM_CONDITIONAL([%(static_build_conditional_tag)s],257 [test %(build_conditional)s -a ! %(shared_build)s])258AM_CONDITIONAL([%(shared_build_conditional_tag)s],259 [test %(build_conditional)s -a %(shared_build)s])260AM_CONDITIONAL([%(build_conditional_tag)s],261 [test %(build_conditional)s])262 """ % plugin)263 plugin_ac.write("""264AS_IF([test "x$with_%(name)s_plugin" = "xyes"],[265""" % plugin)266 if plugin['testsuite']:267 plugin_ac.write("""268 pandora_plugin_test_list="%(name)s,${pandora_plugin_test_list}"269 """ % plugin)270 plugin_ac.write("""271 AS_IF([test "x${with_static_%(name)s_plugin}" = "xyes" -o "x${with_all_static}" = "xyes"],[272 AS_IF([test "x$enable_%(name)s_plugin" = "xyes"],[273 pandora_builtin_load_list="%(module_name)s,${pandora_builtin_load_list}"274 pandora_builtin_load_symbols_list="_drizzled_%(module_name)s_plugin_,${pandora_builtin_load_symbols_list}"275 PANDORA_PLUGIN_DEP_LIBS="${PANDORA_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"276 ])277 pandora_builtin_list="%(module_name)s,${pandora_builtin_list}"278 pandora_builtin_symbols_list="_drizzled_%(module_name)s_plugin_,${pandora_builtin_symbols_list}"279 pandora_plugin_libs="${pandora_plugin_libs} \${top_builddir}/%(root_plugin_dir)s/%(libname)s.la"280 ],[281 AS_IF([test "x$enable_%(name)s_plugin" = "xyes"],[282 pandora_default_plugin_list="%(name)s,${pandora_default_plugin_list}"283 ])284 ])285 """ % plugin)286 plugin_ac.write("])\n")287def fix_file_paths(plugin, files):288 # TODO: determine path to plugin dir relative to top_srcdir... append it to289 # source files if they don't already have it290 new_files=""291 if plugin['plugin_dir'] != ".":292 for file in files.split():293 if not file.startswith(plugin['rel_path']):294 file= os.path.join(plugin['rel_path'], file)295 new_files= "%s %s" % (new_files, file)296 else:297 new_files= " ".join(plugin['sources'].split())298 if new_files != "":299 return new_files300 return files301def expand_plugin_ini(plugin):302 if plugin['name'] == "**OUT-OF-TREE**":303 print "Out of tree plugins require the name field to be specified in plugin.ini"304 sys.exit(1)305 if plugin['plugin_dir'] == ".":306 plugin['rel_path']= plugin['plugin_dir']307 plugin['unconditional']=True308 else:309 plugin['rel_path']= plugin['plugin_dir'][len(config['top_srcdir'])+len(os.path.sep):]310 plugin['unconditional']=False311 plugin['sources']= fix_file_paths(plugin, plugin['sources'])312 plugin['main_source']= plugin['sources'].split()[0]313 plugin['headers']= fix_file_paths(plugin, plugin['headers'])314 plugin['install_headers']= fix_file_paths(plugin, plugin['install_headers'])315 plugin['tests']= fix_file_paths(plugin, plugin['tests'])316 # Make a yes/no version for autoconf help messages317 if plugin['load_by_default']:318 plugin['default_yesno']="yes"319 else:320 plugin['default_yesno']="no"321 if plugin.has_key('extra_dist'):322 plugin['extra_dist']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['extra_dist'].split()])323 if plugin['static']:324 plugin['static_yesno']="yes"325 else:326 plugin['static_yesno']="no"327 plugin['build_conditional_tag']= "BUILD_%s_PLUGIN" % plugin['name'].upper()328 plugin['shared_build_conditional_tag']= "BUILD_%s_PLUGIN_SHARED" % plugin['name'].upper()329 plugin['static_build_conditional_tag']= "BUILD_%s_PLUGIN_STATIC" % plugin['name'].upper()330 plugin['name_with_dashes']= plugin['name'].replace('_','-')331 if plugin.has_key('build_conditional'):332 plugin['has_build_conditional']=True333 plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes" -a %(build_conditional)s' % plugin334 else:335 plugin['has_build_conditional']=False336 plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes"' %plugin337 plugin['shared_build']='"x${shared_%(name)s_plugin}" = "xyes"' %plugin338 if plugin['install']:339 plugin['library_type']= 'pkgplugin'340 else:341 plugin['library_type']= 'noinst'342def find_testsuite(plugin_dir):343 for testdir in ['drizzle-tests','tests']:344 if os.path.isdir(os.path.join(plugin_dir,testdir)):345 return testdir346 if os.path.isdir(os.path.join('tests','suite',os.path.basename(plugin_dir))):347 return ""348 return None349def find_docs(plugin_dir):350 if os.path.isfile(os.path.join(plugin_dir, "docs", "index.rst")):351 return os.path.join(plugin_dir, "docs")352def read_plugin_ini(plugin_dir):353 sources_default=""354 if plugin_dir == ".":355 plugin_name="**OUT-OF-TREE**"356 module_name="**OUT-OF-TREE**"357 else:358 sources_default="%s.cc" % os.path.basename(plugin_dir)359 plugin_name = plugin_dir[plugin_dir.index(config['root_plugin_dir']) + len(config['root_plugin_dir']) + 1:]360 module_name = plugin_name.replace("/", config['module_name_separator']).replace("\\", config['module_name_separator'])361 plugin_name = plugin_name.replace("/", config['plugin_name_separator']).replace("\\", config['plugin_name_separator'])362 plugin_file= os.path.join(plugin_dir,config['plugin_ini_fname'])363 plugin_defaults= dict(sources=sources_default,364 headers="",365 install_headers="",366 cflags="",367 cppflags="",368 cxxflags="",369 libs="",370 ldflags="",371 author="",372 title="",373 description="",374 license="PLUGIN_LICENSE_GPL",375 name=plugin_name,376 module_name=module_name,377 load_by_default=config['default_load_by_default'],378 disabled="False",379 static="False",380 dependencies="",381 dependency_aliases="",382 tests="",383 install=config['default_install'])384 parser=ConfigParser.ConfigParser(defaults= plugin_defaults)385 parser.read(plugin_file)386 plugin=dict(parser.items('plugin'))387 plugin['plugin_dir'] = plugin_dir388 if plugin_dir == '.':389 if not plugin.has_key('url'):390 print "External Plugins are required to specifiy a url"391 plugin['url']= 'http://launchpad.net/%(name)s' % plugin392 sys.exit(1)393 if plugin_dir == '.' and not plugin.has_key('version'):394 print "External Plugins are required to specifiy a version"395 sys.exit(1)396 if not plugin.has_key('version'):397 plugin['version'] = config['default_plugin_version']398 if plugin.has_key('load_by_default'):399 plugin['load_by_default']=parser.getboolean('plugin','load_by_default')400 if plugin.has_key('disabled'):401 plugin['disabled']=parser.getboolean('plugin','disabled')402 if plugin['disabled']:403 plugin['enabled']="no"404 else:405 plugin['enabled']="yes"406 if plugin.has_key('static'):407 try:408 plugin['static']= parser.getboolean('plugin','static')409 except:410 if plugin['static'][:5] == os.sys.platform[:5]:411 plugin['static']= True412 else:413 plugin['static']= False414 if plugin.has_key('install'):415 plugin['install']= parser.getboolean('plugin','install')416 if plugin.has_key('testsuite'):417 if plugin['testsuite'] == 'disable':418 plugin['testsuite']= False419 plugin['dist_testsuite']= find_testsuite(plugin_dir)420 else:421 plugin_testsuite= find_testsuite(plugin_dir)422 plugin['testsuitedir']=plugin_testsuite423 if plugin_testsuite is not None:424 plugin['testsuite']=True425 else:426 plugin['testsuite']=False427 plugin['docs']= find_docs(plugin_dir)428 plugin['cflags']+= ' ' + config['extra_cflags']429 plugin['cppflags']+= ' ' + config['extra_cppflags']430 plugin['cxxflags']+= ' ' + config['extra_cxxflags']431 plugin['libname']= "lib%s%s%s" % (config['plugin_prefix'],432 plugin['name'],433 config['plugin_suffix'])434 if config['force_lowercase_libname']:435 plugin['libname']= plugin['libname'].lower()436 plugin['root_plugin_dir']= config['root_plugin_dir']437 plugin['plugin_prefix']= config['plugin_prefix']438 plugin['plugin_suffix']= config['plugin_suffix']439 plugin['pkgplugindir']= config['pkgplugindir']440 # Dependencies must have a module but dependency aliases are simply added441 # to the variable passed during compile.442 plugin['dependency_list'] = plugin['dependencies'].split()443 dependency_aliases = plugin['dependency_aliases'].split()444 plugin['dependencies'] = ','.join(plugin['dependency_list'] +445 plugin['dependency_aliases'].split())446 dependency_libs = ["%s/lib%s%s.la" % (config['root_plugin_dir'],447 dependency.lower().replace('::', '_'),448 config['plugin_suffix'])449 for dependency in plugin['dependency_list']]450 plugin['libs'] = " ".join(plugin['libs'].split() + dependency_libs);451# Libtool is going to expand:452# -DPANDORA_MODULE_AUTHOR='"Padraig O'"'"'Sullivan"'453# to:454# "-DPANDORA_MODULE_AUTHOR=\"Padraig O'Sullivan\""455# So we have to replace internal ''s to '"'"'456 for key in ('author','title','description','version'):457 plugin[key]=plugin[key].replace('"','\\"')458 plugin[key]=plugin[key].replace("'","'\"'\"'")459 return plugin460def write_plugin_am(plugin, plugin_am):461 """Write an automake fragment for this plugin.462 :param plugin: The plugin dict.463 :param plugin_am: The file to write to.464 """465 # The .plugin.ini.stamp avoids changing the datestamp on plugin.ini which can466 # confuse VCS systems.467 plugin_am.write("""468EXTRA_DIST += %(rel_path)s/plugin.ini469# Prevent errors when a plugin dir is removed470%(rel_path)s/plugin.ini:471""" % plugin)472 if plugin.has_key('extra_dist') and plugin['extra_dist'] != "":473 plugin_am.write("EXTRA_DIST += %(extra_dist)s\n" % plugin)474 if plugin['headers'] != "":475 plugin_am.write("noinst_HEADERS += %(headers)s\n" % plugin)476 if plugin['install_headers'] != "":477 plugin_am.write("nobase_pkginclude_HEADERS += %(install_headers)s\n" % plugin)478 if plugin['testsuite']:479 if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "":480 plugin_am.write("EXTRA_DIST += %(rel_path)s/%(testsuitedir)s\n" % plugin)481 if plugin.has_key('dist_testsuite') and plugin['dist_testsuite'] != "":482 plugin_am.write("EXTRA_DIST += %(rel_path)s/%(dist_testsuite)s\n" % plugin)483 if plugin['docs'] is not None:484 plugin_am.write("EXTRA_DIST += ${top_srcdir}/%(rel_path)s/docs/*.rst\n" % plugin)485 plugin_am.write("""486%(root_plugin_dir)s_%(plugin_prefix)s%(name)s_dir=${top_srcdir}/%(rel_path)s487# Include sources in EXTRA_DIST because we might not build this, but we488# still want the sources to wind up in a tarball489EXTRA_DIST += %(rel_path)s/plugin.ini %(sources)s490if %(static_build_conditional_tag)s491 noinst_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la492 %(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s493 %(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s494 %(root_plugin_dir)s_%(libname)s_la_LDFLAGS=$(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)495 %(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='%(author)s' -DPANDORA_MODULE_TITLE='%(title)s' -DPANDORA_MODULE_VERSION='%(version)s' -DPANDORA_MODULE_LICENSE=%(license)s -DPANDORA_MODULE_DEPENDENCIES='%(dependencies)s' %(cppflags)s496 %(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s497 %(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s498 %(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s499 check_PROGRAMS += %(tests)s500 PANDORA_DYNAMIC_LDADDS+=${top_builddir}/%(root_plugin_dir)s/%(libname)s.la501endif502EXTRA_DIST += %(rel_path)s/plugin.ini503if %(shared_build_conditional_tag)s504 %(library_type)s_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la505 %(root_plugin_dir)s_%(libname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)506 %(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s507 %(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s508 %(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='%(author)s' -DPANDORA_MODULE_TITLE='%(title)s' -DPANDORA_MODULE_VERSION='%(version)s' -DPANDORA_MODULE_LICENSE=%(license)s -DPANDORA_MODULE_DEPENDENCIES='%(dependencies)s' %(cppflags)s509 %(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s510 %(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s511 %(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s512 check_PROGRAMS += %(tests)s513endif514""" % plugin)515 plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am')516 if os.path.exists(plugin_am_file):517 plugin_am.write('include %s\n' % plugin_am_file)518#519# MAIN STARTS HERE:520#521# Parse the pandora-plugin config file522config_defaults= dict(523 top_srcdir='.',524 top_builddir='.',525 plugin_ini_fname='plugin.ini',526 plugin_prefix='',527 plugin_suffix='',528 extra_cflags='',529 extra_cppflags='',530 extra_cxxflags='',531 root_plugin_dir='',532 pkgplugindir='',533 default_install='True',534 default_plugin_version='',535 default_load_by_default='False',536 force_lowercase_libname='True',537 plugin_name_separator='_',538 module_name_separator='::'539)540config_parser = ConfigParser.ConfigParser(defaults=config_defaults)541config_parser.read(pandora_plugin_file)542config = dict(config_parser.items('pandora-plugin'))543config['force_lowercase_libname']=config_parser.getboolean('pandora-plugin','force_lowercase_libname')544# I'm 3 seconds away from writing a comprehensive build solution545if not os.path.exists('config/pandora_vc_revinfo'):546 if os.path.exists('.bzr'):547 bzr_revno= subprocess.Popen(["bzr", "revno"], stdout=subprocess.PIPE).communicate()[0].strip()548 rev_date= datetime.date.fromtimestamp(time.time())549 config['default_plugin_version'] = "%d.%02d.%s" % (rev_date.year, rev_date.month, bzr_revno)550 else:551 config['default_plugin_version']=datetime.date.fromtimestamp(time.time()).isoformat()552else:553 # need to read config/pandora_vc_revno554 pandora_vc_revno=open('config/pandora_vc_revinfo','r').read().split()555 rev_date=""556 bzr_revno=""557 for revno_line in pandora_vc_revno:558 (revno_key,revno_val)= revno_line.split("=")559 if revno_key == 'PANDORA_VC_REVNO':560 bzr_revno=revno_val.strip()561 elif revno_key == 'PANDORA_RELEASE_DATE':562 rev_date=revno_val.strip()563 config['default_plugin_version'] = "%s.%s" % (rev_date, bzr_revno)564actions=[]565for arg in sys.argv:566 if arg.startswith('--top_srcdir='):567 config['top_srcdir']=arg[12:]568 elif arg.startswith('--top_builddir='):569 config['top_builddir']=arg[14:]570 elif arg == "--force-all":571 actions=['plugin-list','pandora-plugin.am','write']572 break573 else:574 actions.append(arg)575if len(actions) == 0:576 actions.append('write')577plugin_list=[]578def accumulate_plugins(arg, dirname, fnames):579 # plugin_ini_fname is a name in dirname indicating dirname is a plugin.580 if config['plugin_ini_fname'] in fnames:581 arg.append(dirname)582os.path.walk(os.path.join(config['top_srcdir'],583 config['root_plugin_dir']),584 accumulate_plugins,585 plugin_list)586if not os.path.exists("config/pandora-plugin.am") or "write" in actions:587 plugin_am_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.am'))588 plugin_am_file.write("""589# always the current list, generated every build so keep this lean.590# pandora-plugin.list: datestamp preserved list591${srcdir}/config/pandora-plugin.list: .plugin.scan592.plugin.scan:593 @cd ${top_srcdir} && python config/pandora-plugin plugin-list594# Plugins affect configure; so to prevent configure running twice in a tarball595# build (once up front, once with the right list of plugins, we ship the596# generated list of plugins and the housekeeping material for that list so it597# is likewise not updated.598EXTRA_DIST += \599 config/pandora-plugin.am \600 config/pandora-plugin.ac \601 config/pandora-plugin \602 config/pandora-plugin.ini603# Seed the list of plugin LDADDS which plugins may extend.604PANDORA_DYNAMIC_LDADDS=605# plugin.stamp: graph dominator for creating all per pandora-plugin.ac/am606# files. This is invoked when the code to generate such files has altered.""")607if not os.path.exists("config/pandora-plugin.ac") or "write" in actions:608 plugin_ac_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.ac'))609 plugin_ac_file.write("dnl Generated file, run make to rebuild\n")610 plugin_ac_file.write("""611AC_ARG_WITH([all-static],[612AS_HELP_STRING([--with-all-static],[Link all plugins staticly into the server @<:@default=no@:>@])613],[614 with_all_static="$withval"615 ],[616 with_all_static=no617])618 """)619if os.path.exists("docs/plugins"):620 if not os.path.exists("docs/plugins/list.rst") or "write" in actions:621 plugin_doc_index = ChangeProtectedFile("docs/plugins/list.rst")622 plugin_doc_index.write("""623Plugin Documentation624====================625.. toctree::626 :maxdepth: 2627""")628if os.path.exists('plugin.ini'):629 # Are we in a plugin dir which wants to have a self-sufficient build system?630 plugin_list=['.']631 write_external_plugin()632else:633 plugin_list_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.list'))634 for p in plugin_list:635 plugin_list_file.write(p)636 plugin_list_file.write("\n")637 plugin_list.sort()638 plugin_list_file.close()639if not os.path.exists("config/pandora-plugin.am") or 'write' in actions:640 plugin_am_file.write("\n${top_srcdir}/config/pandora-plugin.am: ${top_srcdir}/config/pandora-plugin.list ${top_srcdir}/config/pandora-plugin ")641 for plugin_dir in plugin_list:642 plugin_am_file.write("\\\n\t%s/plugin.ini " % plugin_dir)643 plugin_am_file.write("\n\tcd ${top_srcdir} && python config/pandora-plugin write\n")644 plugin_ini_list=[]645 # Load all plugin.ini files first so we can do dependency tracking.646 for plugin_dir in plugin_list:647 plugin = read_plugin_ini(plugin_dir)648 expand_plugin_ini(plugin)649 plugin_ini_list.append(plugin)650 # Check for duplicates651 plugin_name_list = [plugin['libname'] for plugin in plugin_ini_list]652 for plugin in plugin_ini_list:653 if plugin_name_list.count(plugin['libname']) != 1:654 print "Duplicate module name %s" % plugin['libname']655 exit(1)656 for plugin in plugin_ini_list:657 write_plugin(plugin, plugin_ini_list)658if plugin_am_file is not None:659 plugin_am_file.close()660if plugin_ac_file is not None:661 plugin_ac_file.close()662if plugin_doc_index is not None:...

Full Screen

Full Screen

plugins.py

Source:plugins.py Github

copy

Full Screen

...62 request = super(PluginsTestBaseCase, self).get_request(*args, **kwargs)63 request.placeholder_media = Media()64 return request65class PluginsTestCase(PluginsTestBaseCase):66 def test_add_edit_plugin(self):67 """68 Test that you can add a text plugin69 """70 # add a new text plugin71 page_data = self.get_new_page_data()72 response = self.client.post(URL_CMS_PAGE_ADD, page_data)73 page = Page.objects.all()[0]74 plugin_data = {75 'plugin_type':"TextPlugin",76 'language':settings.LANGUAGES[0][0],77 'placeholder':page.placeholders.get(slot="body").pk,78 }79 response = self.client.post(URL_CMS_PLUGIN_ADD, plugin_data)80 self.assertEquals(response.status_code, 200)81 self.assertEquals(int(response.content), CMSPlugin.objects.all()[0].pk)82 # now edit the plugin83 edit_url = URL_CMS_PLUGIN_EDIT + response.content + "/"84 response = self.client.get(edit_url)85 self.assertEquals(response.status_code, 200)86 data = {87 "body":"Hello World"88 }89 response = self.client.post(edit_url, data)90 self.assertEquals(response.status_code, 200)91 txt = Text.objects.all()[0]92 self.assertEquals("Hello World", txt.body)93 def test_copy_plugins(self):94 """95 Test that copying plugins works as expected.96 """97 # create some objects98 page_en = create_page("CopyPluginTestPage (EN)", "nav_playground.html", "en")99 page_de = create_page("CopyPluginTestPage (DE)", "nav_playground.html", "de")100 ph_en = page_en.placeholders.get(slot="body")101 ph_de = page_de.placeholders.get(slot="body")102 103 # add the text plugin104 text_plugin_en = add_plugin(ph_en, "TextPlugin", "en", body="Hello World")105 self.assertEquals(text_plugin_en.pk, CMSPlugin.objects.all()[0].pk)106 107 # add a *nested* link plugin108 link_plugin_en = add_plugin(ph_en, "LinkPlugin", "en", target=text_plugin_en,109 name="A Link", url="https://www.django-cms.org")110 111 # the call above to add a child makes a plugin reload required here.112 text_plugin_en = self.reload(text_plugin_en)113 114 # check the relations115 self.assertEquals(text_plugin_en.get_children().count(), 1)116 self.assertEqual(link_plugin_en.parent.pk, text_plugin_en.pk)117 118 # just sanity check that so far everything went well119 self.assertEqual(CMSPlugin.objects.count(), 2)120 121 # copy the plugins to the german placeholder122 copy_plugins_to(ph_en.cmsplugin_set.all(), ph_de, 'de')123 124 self.assertEqual(ph_de.cmsplugin_set.filter(parent=None).count(), 1)125 text_plugin_de = ph_de.cmsplugin_set.get(parent=None).get_plugin_instance()[0]126 self.assertEqual(text_plugin_de.get_children().count(), 1)127 link_plugin_de = text_plugin_de.get_children().get().get_plugin_instance()[0]128 129 130 # check we have twice as many plugins as before131 self.assertEqual(CMSPlugin.objects.count(), 4)132 133 # check language plugins134 self.assertEqual(CMSPlugin.objects.filter(language='de').count(), 2)135 self.assertEqual(CMSPlugin.objects.filter(language='en').count(), 2)136 137 138 text_plugin_en = self.reload(text_plugin_en)139 link_plugin_en = self.reload(link_plugin_en)140 141 # check the relations in english didn't change142 self.assertEquals(text_plugin_en.get_children().count(), 1)143 self.assertEqual(link_plugin_en.parent.pk, text_plugin_en.pk)144 145 self.assertEqual(link_plugin_de.name, link_plugin_en.name)146 self.assertEqual(link_plugin_de.url, link_plugin_en.url)147 148 self.assertEqual(text_plugin_de.body, text_plugin_en.body)149 150 def test_remove_plugin_before_published(self):151 """152 When removing a draft plugin we would expect the public copy of the plugin to also be removed153 """154 # add a page155 page_data = self.get_new_page_data()156 response = self.client.post(URL_CMS_PAGE_ADD, page_data)157 page = Page.objects.all()[0]158 # add a plugin159 plugin_data = {160 'plugin_type':"TextPlugin",161 'language':settings.LANGUAGES[0][0],162 'placeholder':page.placeholders.get(slot="body").pk,163 }164 response = self.client.post(URL_CMS_PLUGIN_ADD, plugin_data)165 self.assertEquals(response.status_code, 200)166 self.assertEquals(int(response.content), CMSPlugin.objects.all()[0].pk)167 # there should be only 1 plugin168 self.assertEquals(CMSPlugin.objects.all().count(), 1)169 # delete the plugin170 plugin_data = {171 'plugin_id': int(response.content)172 }173 remove_url = URL_CMS_PLUGIN_REMOVE174 response = self.client.post(remove_url, plugin_data)175 self.assertEquals(response.status_code, 200)176 # there should be no plugins177 self.assertEquals(0, CMSPlugin.objects.all().count())178 def test_remove_plugin_after_published(self):179 # add a page180 page_data = self.get_new_page_data()181 response = self.client.post(URL_CMS_PAGE_ADD, page_data)182 page = Page.objects.all()[0]183 # add a plugin184 plugin_data = {185 'plugin_type':"TextPlugin",186 'language':settings.LANGUAGES[0][0],187 'placeholder':page.placeholders.get(slot="body").pk,188 }189 response = self.client.post(URL_CMS_PLUGIN_ADD, plugin_data)190 plugin_id = int(response.content)191 self.assertEquals(response.status_code, 200)192 self.assertEquals(int(response.content), CMSPlugin.objects.all()[0].pk)193 # there should be only 1 plugin194 self.assertEquals(CMSPlugin.objects.all().count(), 1)195 # publish page196 response = self.client.post(URL_CMS_PAGE + "%d/change-status/" % page.pk, {1 :1})197 self.assertEqual(response.status_code, 200)198 # there should now be two plugins - 1 draft, 1 public199 self.assertEquals(CMSPlugin.objects.all().count(), 2)200 # delete the plugin201 plugin_data = {202 'plugin_id': plugin_id203 }204 remove_url = URL_CMS_PLUGIN_REMOVE205 response = self.client.post(remove_url, plugin_data)206 self.assertEquals(response.status_code, 200)207 # there should be no plugins208 self.assertEquals(CMSPlugin.objects.all().count(), 0)209 def test_remove_plugin_not_associated_to_page(self):210 """211 Test case for PlaceholderField212 """213 page_data = self.get_new_page_data()214 response = self.client.post(URL_CMS_PAGE_ADD, page_data)215 page = Page.objects.all()[0]216 # add a plugin217 plugin_data = {218 'plugin_type':"TextPlugin",219 'language':settings.LANGUAGES[0][0],220 'placeholder':page.placeholders.get(slot="body").pk,221 }222 response = self.client.post(URL_CMS_PLUGIN_ADD, plugin_data)223 self.assertEquals(response.status_code, 200)224 self.assertEquals(int(response.content), CMSPlugin.objects.all()[0].pk)225 # there should be only 1 plugin226 self.assertEquals(CMSPlugin.objects.all().count(), 1)227 ph = Placeholder(slot="subplugin")228 ph.save()229 plugin_data = {230 'plugin_type':"TextPlugin",231 'language':settings.LANGUAGES[0][0],232 'placeholder': ph.pk,233 'parent': int(response.content)234 }235 response = self.client.post(URL_CMS_PLUGIN_ADD, plugin_data)236 # no longer allowed for security reasons237 self.assertEqual(response.status_code, 404)238 def test_register_plugin_twice_should_raise(self):239 number_of_plugins_before = len(plugin_pool.get_all_plugins())240 # The first time we register the plugin is should work241 plugin_pool.register_plugin(DumbFixturePlugin)242 # Let's add it a second time. We should catch and exception243 raised = False244 try:245 plugin_pool.register_plugin(DumbFixturePlugin)246 except PluginAlreadyRegistered:247 raised = True248 self.assertTrue(raised)249 # Let's also unregister the plugin now, and assert it's not in the250 # pool anymore251 plugin_pool.unregister_plugin(DumbFixturePlugin)252 # Let's make sure we have the same number of plugins as before:253 number_of_plugins_after = len(plugin_pool.get_all_plugins())254 self.assertEqual(number_of_plugins_before, number_of_plugins_after)255 def test_unregister_non_existing_plugin_should_raise(self):256 number_of_plugins_before = len(plugin_pool.get_all_plugins())257 raised = False258 try:259 # There should not be such a plugin registered if the others tests260 # don't leak plugins261 plugin_pool.unregister_plugin(DumbFixturePlugin)262 except PluginNotRegistered:263 raised = True264 self.assertTrue(raised)265 # Let's count, to make sure we didn't remove a plugin accidentally.266 number_of_plugins_after = len(plugin_pool.get_all_plugins())267 self.assertEqual(number_of_plugins_before, number_of_plugins_after)268 269 def test_inheritplugin_media(self):270 """271 Test case for InheritPagePlaceholder272 """273 with SettingsOverride(CMS_MODERATOR=False):274 inheritfrompage = create_page('page to inherit from',275 'nav_playground.html',276 'en')277 278 body = inheritfrompage.placeholders.get(slot="body")279 280 plugin = TwitterRecentEntries(281 plugin_type='TwitterRecentEntriesPlugin',282 placeholder=body, 283 position=1, 284 language=settings.LANGUAGE_CODE,285 twitter_user='djangocms',286 )287 plugin.insert_at(None, position='last-child', save=True)288 289 page = create_page('inherit from page',290 'nav_playground.html',291 'en',292 published=True)293 294 inherited_body = page.placeholders.get(slot="body")295 296 inherit_plugin = InheritPagePlaceholder(297 plugin_type='InheritPagePlaceholderPlugin',298 placeholder=inherited_body, 299 position=1, 300 language=settings.LANGUAGE_CODE,301 from_page=inheritfrompage,302 from_language=settings.LANGUAGE_CODE)303 inherit_plugin.insert_at(None, position='last-child', save=True)304 305 self.client.logout()306 response = self.client.get(page.get_absolute_url())307 self.assertTrue('%scms/js/libs/jquery.tweet.js' % settings.STATIC_URL in response.content, response.content)308 def test_copy_textplugin(self):309 """310 Test that copying of textplugins replaces references to copied plugins311 """312 page = create_page("page", "nav_playground.html", "en")313 314 placeholder = page.placeholders.get(slot='body')315 plugin_base = CMSPlugin(316 plugin_type='TextPlugin',317 placeholder=placeholder,318 position=1,319 language=self.FIRST_LANG)320 plugin_base.insert_at(None, position='last-child', save=False)321 plugin = Text(body='')322 plugin_base.set_base_attr(plugin)...

Full Screen

Full Screen

cordova_plugins.js

Source:cordova_plugins.js Github

copy

Full Screen

1cordova.define('cordova/plugin_list', function(require, exports, module) {2module.exports = [3 {4 "file": "plugins/cordova-plugin-battery-status/www/battery.js",5 "id": "cordova-plugin-battery-status.battery",6 "pluginId": "cordova-plugin-battery-status",7 "clobbers": [8 "navigator.battery"9 ]10 },11 {12 "file": "plugins/cordova-plugin-battery-status/src/browser/BatteryProxy.js",13 "id": "cordova-plugin-battery-status.Battery",14 "pluginId": "cordova-plugin-battery-status",15 "runs": true16 },17 {18 "file": "plugins/cordova-plugin-camera/www/CameraConstants.js",19 "id": "cordova-plugin-camera.Camera",20 "pluginId": "cordova-plugin-camera",21 "clobbers": [22 "Camera"23 ]24 },25 {26 "file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js",27 "id": "cordova-plugin-camera.CameraPopoverOptions",28 "pluginId": "cordova-plugin-camera",29 "clobbers": [30 "CameraPopoverOptions"31 ]32 },33 {34 "file": "plugins/cordova-plugin-camera/www/Camera.js",35 "id": "cordova-plugin-camera.camera",36 "pluginId": "cordova-plugin-camera",37 "clobbers": [38 "navigator.camera"39 ]40 },41 {42 "file": "plugins/cordova-plugin-camera/src/browser/CameraProxy.js",43 "id": "cordova-plugin-camera.CameraProxy",44 "pluginId": "cordova-plugin-camera",45 "runs": true46 },47 {48 "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js",49 "id": "cordova-plugin-file.DirectoryEntry",50 "pluginId": "cordova-plugin-file",51 "clobbers": [52 "window.DirectoryEntry"53 ]54 },55 {56 "file": "plugins/cordova-plugin-file/www/DirectoryReader.js",57 "id": "cordova-plugin-file.DirectoryReader",58 "pluginId": "cordova-plugin-file",59 "clobbers": [60 "window.DirectoryReader"61 ]62 },63 {64 "file": "plugins/cordova-plugin-file/www/Entry.js",65 "id": "cordova-plugin-file.Entry",66 "pluginId": "cordova-plugin-file",67 "clobbers": [68 "window.Entry"69 ]70 },71 {72 "file": "plugins/cordova-plugin-file/www/File.js",73 "id": "cordova-plugin-file.File",74 "pluginId": "cordova-plugin-file",75 "clobbers": [76 "window.File"77 ]78 },79 {80 "file": "plugins/cordova-plugin-file/www/FileEntry.js",81 "id": "cordova-plugin-file.FileEntry",82 "pluginId": "cordova-plugin-file",83 "clobbers": [84 "window.FileEntry"85 ]86 },87 {88 "file": "plugins/cordova-plugin-file/www/FileError.js",89 "id": "cordova-plugin-file.FileError",90 "pluginId": "cordova-plugin-file",91 "clobbers": [92 "window.FileError"93 ]94 },95 {96 "file": "plugins/cordova-plugin-file/www/FileReader.js",97 "id": "cordova-plugin-file.FileReader",98 "pluginId": "cordova-plugin-file",99 "clobbers": [100 "window.FileReader"101 ]102 },103 {104 "file": "plugins/cordova-plugin-file/www/FileSystem.js",105 "id": "cordova-plugin-file.FileSystem",106 "pluginId": "cordova-plugin-file",107 "clobbers": [108 "window.FileSystem"109 ]110 },111 {112 "file": "plugins/cordova-plugin-file/www/FileUploadOptions.js",113 "id": "cordova-plugin-file.FileUploadOptions",114 "pluginId": "cordova-plugin-file",115 "clobbers": [116 "window.FileUploadOptions"117 ]118 },119 {120 "file": "plugins/cordova-plugin-file/www/FileUploadResult.js",121 "id": "cordova-plugin-file.FileUploadResult",122 "pluginId": "cordova-plugin-file",123 "clobbers": [124 "window.FileUploadResult"125 ]126 },127 {128 "file": "plugins/cordova-plugin-file/www/FileWriter.js",129 "id": "cordova-plugin-file.FileWriter",130 "pluginId": "cordova-plugin-file",131 "clobbers": [132 "window.FileWriter"133 ]134 },135 {136 "file": "plugins/cordova-plugin-file/www/Flags.js",137 "id": "cordova-plugin-file.Flags",138 "pluginId": "cordova-plugin-file",139 "clobbers": [140 "window.Flags"141 ]142 },143 {144 "file": "plugins/cordova-plugin-file/www/LocalFileSystem.js",145 "id": "cordova-plugin-file.LocalFileSystem",146 "pluginId": "cordova-plugin-file",147 "clobbers": [148 "window.LocalFileSystem"149 ],150 "merges": [151 "window"152 ]153 },154 {155 "file": "plugins/cordova-plugin-file/www/Metadata.js",156 "id": "cordova-plugin-file.Metadata",157 "pluginId": "cordova-plugin-file",158 "clobbers": [159 "window.Metadata"160 ]161 },162 {163 "file": "plugins/cordova-plugin-file/www/ProgressEvent.js",164 "id": "cordova-plugin-file.ProgressEvent",165 "pluginId": "cordova-plugin-file",166 "clobbers": [167 "window.ProgressEvent"168 ]169 },170 {171 "file": "plugins/cordova-plugin-file/www/fileSystems.js",172 "id": "cordova-plugin-file.fileSystems",173 "pluginId": "cordova-plugin-file"174 },175 {176 "file": "plugins/cordova-plugin-file/www/requestFileSystem.js",177 "id": "cordova-plugin-file.requestFileSystem",178 "pluginId": "cordova-plugin-file",179 "clobbers": [180 "window.requestFileSystem"181 ]182 },183 {184 "file": "plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js",185 "id": "cordova-plugin-file.resolveLocalFileSystemURI",186 "pluginId": "cordova-plugin-file",187 "merges": [188 "window"189 ]190 },191 {192 "file": "plugins/cordova-plugin-file/www/browser/isChrome.js",193 "id": "cordova-plugin-file.isChrome",194 "pluginId": "cordova-plugin-file",195 "runs": true196 },197 {198 "file": "plugins/cordova-plugin-file/www/browser/Preparing.js",199 "id": "cordova-plugin-file.Preparing",200 "pluginId": "cordova-plugin-file",201 "runs": true202 },203 {204 "file": "plugins/cordova-plugin-file/src/browser/FileProxy.js",205 "id": "cordova-plugin-file.browserFileProxy",206 "pluginId": "cordova-plugin-file",207 "runs": true208 },209 {210 "file": "plugins/cordova-plugin-file/www/fileSystemPaths.js",211 "id": "cordova-plugin-file.fileSystemPaths",212 "pluginId": "cordova-plugin-file",213 "merges": [214 "cordova"215 ],216 "runs": true217 },218 {219 "file": "plugins/cordova-plugin-file/www/browser/FileSystem.js",220 "id": "cordova-plugin-file.firefoxFileSystem",221 "pluginId": "cordova-plugin-file",222 "merges": [223 "window.FileSystem"224 ]225 },226 {227 "file": "plugins/cordova-plugin-media-capture/www/CaptureAudioOptions.js",228 "id": "cordova-plugin-media-capture.CaptureAudioOptions",229 "pluginId": "cordova-plugin-media-capture",230 "clobbers": [231 "CaptureAudioOptions"232 ]233 },234 {235 "file": "plugins/cordova-plugin-media-capture/www/CaptureImageOptions.js",236 "id": "cordova-plugin-media-capture.CaptureImageOptions",237 "pluginId": "cordova-plugin-media-capture",238 "clobbers": [239 "CaptureImageOptions"240 ]241 },242 {243 "file": "plugins/cordova-plugin-media-capture/www/CaptureVideoOptions.js",244 "id": "cordova-plugin-media-capture.CaptureVideoOptions",245 "pluginId": "cordova-plugin-media-capture",246 "clobbers": [247 "CaptureVideoOptions"248 ]249 },250 {251 "file": "plugins/cordova-plugin-media-capture/www/CaptureError.js",252 "id": "cordova-plugin-media-capture.CaptureError",253 "pluginId": "cordova-plugin-media-capture",254 "clobbers": [255 "CaptureError"256 ]257 },258 {259 "file": "plugins/cordova-plugin-media-capture/www/MediaFileData.js",260 "id": "cordova-plugin-media-capture.MediaFileData",261 "pluginId": "cordova-plugin-media-capture",262 "clobbers": [263 "MediaFileData"264 ]265 },266 {267 "file": "plugins/cordova-plugin-media-capture/www/MediaFile.js",268 "id": "cordova-plugin-media-capture.MediaFile",269 "pluginId": "cordova-plugin-media-capture",270 "clobbers": [271 "MediaFile"272 ]273 },274 {275 "file": "plugins/cordova-plugin-media-capture/www/capture.js",276 "id": "cordova-plugin-media-capture.capture",277 "pluginId": "cordova-plugin-media-capture",278 "clobbers": [279 "navigator.device.capture"280 ]281 },282 {283 "file": "plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js",284 "id": "cordova-plugin-media-capture.CaptureProxy",285 "pluginId": "cordova-plugin-media-capture",286 "runs": true287 },288 {289 "file": "plugins/cordova-plugin-contacts/www/contacts.js",290 "id": "cordova-plugin-contacts.contacts",291 "pluginId": "cordova-plugin-contacts",292 "clobbers": [293 "navigator.contacts"294 ]295 },296 {297 "file": "plugins/cordova-plugin-contacts/www/Contact.js",298 "id": "cordova-plugin-contacts.Contact",299 "pluginId": "cordova-plugin-contacts",300 "clobbers": [301 "Contact"302 ]303 },304 {305 "file": "plugins/cordova-plugin-contacts/www/ContactAddress.js",306 "id": "cordova-plugin-contacts.ContactAddress",307 "pluginId": "cordova-plugin-contacts",308 "clobbers": [309 "ContactAddress"310 ]311 },312 {313 "file": "plugins/cordova-plugin-contacts/www/ContactError.js",314 "id": "cordova-plugin-contacts.ContactError",315 "pluginId": "cordova-plugin-contacts",316 "clobbers": [317 "ContactError"318 ]319 },320 {321 "file": "plugins/cordova-plugin-contacts/www/ContactField.js",322 "id": "cordova-plugin-contacts.ContactField",323 "pluginId": "cordova-plugin-contacts",324 "clobbers": [325 "ContactField"326 ]327 },328 {329 "file": "plugins/cordova-plugin-contacts/www/ContactFindOptions.js",330 "id": "cordova-plugin-contacts.ContactFindOptions",331 "pluginId": "cordova-plugin-contacts",332 "clobbers": [333 "ContactFindOptions"334 ]335 },336 {337 "file": "plugins/cordova-plugin-contacts/www/ContactName.js",338 "id": "cordova-plugin-contacts.ContactName",339 "pluginId": "cordova-plugin-contacts",340 "clobbers": [341 "ContactName"342 ]343 },344 {345 "file": "plugins/cordova-plugin-contacts/www/ContactOrganization.js",346 "id": "cordova-plugin-contacts.ContactOrganization",347 "pluginId": "cordova-plugin-contacts",348 "clobbers": [349 "ContactOrganization"350 ]351 },352 {353 "file": "plugins/cordova-plugin-contacts/www/ContactFieldType.js",354 "id": "cordova-plugin-contacts.ContactFieldType",355 "pluginId": "cordova-plugin-contacts",356 "merges": [357 ""358 ]359 },360 {361 "file": "plugins/cordova-plugin-device/www/device.js",362 "id": "cordova-plugin-device.device",363 "pluginId": "cordova-plugin-device",364 "clobbers": [365 "device"366 ]367 },368 {369 "file": "plugins/cordova-plugin-device/src/browser/DeviceProxy.js",370 "id": "cordova-plugin-device.DeviceProxy",371 "pluginId": "cordova-plugin-device",372 "runs": true373 },374 {375 "file": "plugins/cordova-plugin-device-motion/www/Acceleration.js",376 "id": "cordova-plugin-device-motion.Acceleration",377 "pluginId": "cordova-plugin-device-motion",378 "clobbers": [379 "Acceleration"380 ]381 },382 {383 "file": "plugins/cordova-plugin-device-motion/www/accelerometer.js",384 "id": "cordova-plugin-device-motion.accelerometer",385 "pluginId": "cordova-plugin-device-motion",386 "clobbers": [387 "navigator.accelerometer"388 ]389 },390 {391 "file": "plugins/cordova-plugin-device-motion/src/browser/AccelerometerProxy.js",392 "id": "cordova-plugin-device-motion.AccelerometerProxy",393 "pluginId": "cordova-plugin-device-motion",394 "runs": true395 },396 {397 "file": "plugins/cordova-plugin-device-orientation/www/CompassError.js",398 "id": "cordova-plugin-device-orientation.CompassError",399 "pluginId": "cordova-plugin-device-orientation",400 "clobbers": [401 "CompassError"402 ]403 },404 {405 "file": "plugins/cordova-plugin-device-orientation/www/CompassHeading.js",406 "id": "cordova-plugin-device-orientation.CompassHeading",407 "pluginId": "cordova-plugin-device-orientation",408 "clobbers": [409 "CompassHeading"410 ]411 },412 {413 "file": "plugins/cordova-plugin-device-orientation/www/compass.js",414 "id": "cordova-plugin-device-orientation.compass",415 "pluginId": "cordova-plugin-device-orientation",416 "clobbers": [417 "navigator.compass"418 ]419 },420 {421 "file": "plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js",422 "id": "cordova-plugin-device-orientation.CompassProxy",423 "pluginId": "cordova-plugin-device-orientation",424 "runs": true425 },426 {427 "file": "plugins/cordova-plugin-dialogs/www/notification.js",428 "id": "cordova-plugin-dialogs.notification",429 "pluginId": "cordova-plugin-dialogs",430 "merges": [431 "navigator.notification"432 ]433 },434 {435 "file": "plugins/cordova-plugin-dialogs/www/browser/notification.js",436 "id": "cordova-plugin-dialogs.notification_browser",437 "pluginId": "cordova-plugin-dialogs",438 "merges": [439 "navigator.notification"440 ]441 },442 {443 "file": "plugins/cordova-plugin-file-transfer/www/FileTransferError.js",444 "id": "cordova-plugin-file-transfer.FileTransferError",445 "pluginId": "cordova-plugin-file-transfer",446 "clobbers": [447 "window.FileTransferError"448 ]449 },450 {451 "file": "plugins/cordova-plugin-file-transfer/www/FileTransfer.js",452 "id": "cordova-plugin-file-transfer.FileTransfer",453 "pluginId": "cordova-plugin-file-transfer",454 "clobbers": [455 "window.FileTransfer"456 ]457 },458 {459 "file": "plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js",460 "id": "cordova-plugin-file-transfer.BrowserFileTransfer",461 "pluginId": "cordova-plugin-file-transfer",462 "clobbers": [463 "window.FileTransfer"464 ]465 },466 {467 "file": "plugins/cordova-plugin-globalization/www/GlobalizationError.js",468 "id": "cordova-plugin-globalization.GlobalizationError",469 "pluginId": "cordova-plugin-globalization",470 "clobbers": [471 "window.GlobalizationError"472 ]473 },474 {475 "file": "plugins/cordova-plugin-globalization/www/globalization.js",476 "id": "cordova-plugin-globalization.globalization",477 "pluginId": "cordova-plugin-globalization",478 "clobbers": [479 "navigator.globalization"480 ]481 },482 {483 "file": "plugins/cordova-plugin-globalization/www/browser/moment.js",484 "id": "cordova-plugin-globalization.moment",485 "pluginId": "cordova-plugin-globalization",486 "runs": true487 },488 {489 "file": "plugins/cordova-plugin-globalization/src/browser/GlobalizationProxy.js",490 "id": "cordova-plugin-globalization.GlobalizationProxy",491 "pluginId": "cordova-plugin-globalization",492 "runs": true493 },494 {495 "file": "plugins/cordova-plugin-inappbrowser/www/inappbrowser.js",496 "id": "cordova-plugin-inappbrowser.inappbrowser",497 "pluginId": "cordova-plugin-inappbrowser",498 "clobbers": [499 "cordova.InAppBrowser.open",500 "window.open"501 ]502 },503 {504 "file": "plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js",505 "id": "cordova-plugin-inappbrowser.InAppBrowserProxy",506 "pluginId": "cordova-plugin-inappbrowser",507 "merges": [508 ""509 ]510 },511 {512 "file": "plugins/cordova-plugin-media/www/MediaError.js",513 "id": "cordova-plugin-media.MediaError",514 "pluginId": "cordova-plugin-media",515 "clobbers": [516 "window.MediaError"517 ]518 },519 {520 "file": "plugins/cordova-plugin-media/www/Media.js",521 "id": "cordova-plugin-media.Media",522 "pluginId": "cordova-plugin-media",523 "clobbers": [524 "window.Media"525 ]526 },527 {528 "file": "plugins/cordova-plugin-media/www/browser/Media.js",529 "id": "cordova-plugin-media.BrowserMedia",530 "pluginId": "cordova-plugin-media",531 "clobbers": [532 "window.Media"533 ]534 },535 {536 "file": "plugins/cordova-plugin-network-information/www/network.js",537 "id": "cordova-plugin-network-information.network",538 "pluginId": "cordova-plugin-network-information",539 "clobbers": [540 "navigator.connection",541 "navigator.network.connection"542 ]543 },544 {545 "file": "plugins/cordova-plugin-network-information/www/Connection.js",546 "id": "cordova-plugin-network-information.Connection",547 "pluginId": "cordova-plugin-network-information",548 "clobbers": [549 "Connection"550 ]551 },552 {553 "file": "plugins/cordova-plugin-network-information/src/browser/network.js",554 "id": "cordova-plugin-network-information.NetworkInfoProxy",555 "pluginId": "cordova-plugin-network-information",556 "runs": true557 },558 {559 "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js",560 "id": "cordova-plugin-splashscreen.SplashScreen",561 "pluginId": "cordova-plugin-splashscreen",562 "clobbers": [563 "navigator.splashscreen"564 ]565 },566 {567 "file": "plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js",568 "id": "cordova-plugin-splashscreen.SplashScreenProxy",569 "pluginId": "cordova-plugin-splashscreen",570 "runs": true571 },572 {573 "file": "plugins/cordova-plugin-statusbar/www/statusbar.js",574 "id": "cordova-plugin-statusbar.statusbar",575 "pluginId": "cordova-plugin-statusbar",576 "clobbers": [577 "window.StatusBar"578 ]579 },580 {581 "file": "plugins/cordova-plugin-statusbar/src/browser/statusbar.js",582 "id": "cordova-plugin-statusbar.statusbar.Browser",583 "pluginId": "cordova-plugin-statusbar",584 "merges": [585 "window.StatusBar"586 ]587 },588 {589 "file": "plugins/cordova-plugin-vibration/www/vibration.js",590 "id": "cordova-plugin-vibration.notification",591 "pluginId": "cordova-plugin-vibration",592 "merges": [593 "navigator.notification",594 "navigator"595 ]596 },597 {598 "file": "plugins/cordova-plugin-vibration/src/browser/Vibration.js",599 "id": "cordova-plugin-vibration.Vibration",600 "pluginId": "cordova-plugin-vibration",601 "merges": [602 "navigator.notification",603 "navigator"604 ]605 }606];607module.exports.metadata = 608// TOP OF METADATA609{610 "cordova-plugin-battery-status": "1.1.2",611 "cordova-plugin-camera": "2.1.1",612 "cordova-plugin-file": "6.0.2",613 "cordova-plugin-media-capture": "1.2.0",614 "cordova-plugin-console": "1.0.7",615 "cordova-plugin-contacts": "2.0.1",616 "cordova-plugin-device": "1.1.7",617 "cordova-plugin-device-motion": "1.2.5",618 "cordova-plugin-device-orientation": "1.0.7",619 "cordova-plugin-dialogs": "1.2.1",620 "cordova-plugin-file-transfer": "1.5.1",621 "cordova-plugin-geolocation": "2.1.0",622 "cordova-plugin-globalization": "1.0.9",623 "cordova-plugin-inappbrowser": "1.3.0",624 "cordova-plugin-media": "2.2.0",625 "cordova-plugin-network-information": "1.2.1",626 "cordova-plugin-splashscreen": "3.2.2",627 "cordova-plugin-statusbar": "2.1.3",628 "cordova-plugin-vibration": "2.1.6",629 "cordova-plugin-whitelist": "1.2.2"630}631// BOTTOM OF METADATA...

Full Screen

Full Screen

PluginManager.py

Source:PluginManager.py Github

copy

Full Screen

...35 def add_directory(self, path):36 """Add directory to search path for plugins"""37 self._backend.add_plugin_directories(path)38 self._cache = None39 def add_plugin(self, plugin):40 """Add singe plugin-instance"""41 self._backend.add_plugins(plugin)42 def _load(self):43 """lazy load"""44 if self._cache is not None:45 # cache clean!46 return47 self._cache = plugin.PluginStorage()48 self._backend.collect_plugins()49 (enabled, disabled) = self._validate_plugins(self._backend.get_plugins())50 for plugin_to_add in enabled:51 self._load_plugin(plugin_to_add, self._cache)52 self._cache_disabled = self._filter_duplicated_disabled(53 enabled, disabled)54 self._plugins_loaded = len(enabled)55 def _validate_plugins(self, plugins):56 def partition(plugins):57 plugins_valid = []58 plugins_incompatible = []59 for plugin_to_validate in plugins:60 if not is_plugin(plugin_to_validate):61 continue62 compability_check_result = self._plugin_dependency.check(63 plugin_to_validate)64 if compability_check_result is True:65 plugins_valid.append(plugin_to_validate)66 else:67 item = (68 plugin_to_validate.get_name(),69 compability_check_result)70 plugins_incompatible.append(item)71 return (plugins_valid, plugins_incompatible)72 def is_plugin(plugin_to_validate):73 if not isinstance(plugin_to_validate, pluginmanager.IPlugin):74 return False75 if plugin_to_validate.get_name() == "plugin":76 return False77 return True78 return partition(plugins)79 def _load_plugin(self, plugin_to_add, plugin_storage):80 def handle_aliases(plugin_to_add):81 add_plugin(82 plugin_to_add.get_name().split(' '),83 plugin_to_add,84 plugin_storage)85 for name in plugin_to_add.alias():86 add_plugin(87 name.lower().split(' '),88 plugin_to_add,89 plugin_storage)90 def add_plugin(name, plugin_to_add, parent):91 if len(name) == 1:92 add_plugin_single(name[0], plugin_to_add, parent)93 else:94 add_plugin_compose(name[0], name[1:], plugin_to_add, parent)95 def add_plugin_single(name, plugin_to_add, parent):96 plugin_existing = parent.get_plugins(name)97 if plugin_existing is None:98 parent.add_plugin(name, plugin_to_add)99 else:100 if not plugin_existing.is_callable_plugin():101 plugin_existing.change_with(plugin_to_add)102 parent.add_plugin(name, plugin_to_add)103 else:104 error("Duplicated plugin {}!".format(name))105 def add_plugin_compose(106 name_first,107 name_remaining,108 plugin_to_add,109 parent):110 plugin_existing = parent.get_plugins(name_first)111 if plugin_existing is None:112 plugin_existing = plugin.Plugin()113 plugin_existing._name = name_first114 plugin_existing.__doc__ = ''115 parent.add_plugin(name_first, plugin_existing)116 add_plugin(name_remaining, plugin_to_add, plugin_existing)117 return handle_aliases(plugin_to_add)118 def _filter_duplicated_disabled(self, enabled_list, disabled_list):119 enabled_names = []120 for plugin_enabled in enabled_list:121 enabled_names.append(plugin_enabled.get_name())122 enabled_names.extend(plugin_enabled.alias())123 disabled_unique = {}124 for plugin_name, disable_reason in disabled_list:125 if plugin_name in enabled_names:126 continue127 if plugin_name in disabled_unique:128 disabled_unique[plugin_name].append(disable_reason)129 else:130 disabled_unique[plugin_name] = [disable_reason]...

Full Screen

Full Screen

security.py

Source:security.py Github

copy

Full Screen

...46 Test editing a *PAGE* plugin47 """48 page, placeholder, superuser, staff = self.get_data()49 # create the plugin using a superuser50 plugin = add_plugin(placeholder, 'TextPlugin', 'en', body='body')51 plugin_data = {52 'plugin_id': plugin.pk,53 'body': 'newbody',54 }55 self.assertEqual(plugin.body, 'body') # check the body is as expected.56 # log the user out, try to edit the plugin57 self.client.logout()58 url = URL_CMS_PLUGIN_EDIT + '%s/' % plugin.pk59 response = self.client.post(url, plugin_data)60 # since the user is not logged in, they should be prompted to log in.61 self.assertTemplateUsed(response, 'admin/login.html')62 plugin = self.reload(plugin)63 self.assertEqual(plugin.body, 'body')64 # now log a staff user without permissions in and do the same as above.65 self.client.login(username='staff', password='staff')66 response = self.client.post(url, plugin_data)67 # the user is logged in and the security check fails, so it should 403.68 self.assertEqual(response.status_code, 403)69 plugin = self.reload(plugin)70 self.assertEqual(plugin.body, 'body')71 72 def test_delete(self):73 """74 Test deleting a *PAGE* plugin75 """76 page, placeholder, superuser, staff = self.get_data()77 plugin = add_plugin(placeholder, 'TextPlugin', 'en', body='body')78 plugin_data = {79 'plugin_id': plugin.pk,80 }81 plugin = self.reload(plugin)82 self.assertEqual(plugin.body, 'body')83 # log the user out, try to remove the plugin84 self.client.logout()85 response = self.client.post(URL_CMS_PLUGIN_REMOVE, plugin_data)86 # since the user is not logged in, they should be prompted to log in.87 self.assertTemplateUsed(response, 'admin/login.html')88 self.assertEqual(CMSPlugin.objects.count(), 1)89 plugin = self.reload(plugin)90 self.assertEqual(plugin.body, 'body')91 # now log a staff user without permissions in and do the same as above.92 self.client.login(username='staff', password='staff')93 response = self.client.post(URL_CMS_PLUGIN_REMOVE, plugin_data)94 # the user is logged in and the security check fails, so it should 403.95 self.assertEqual(response.status_code, 403)96 self.assertEqual(CMSPlugin.objects.count(), 1)97 plugin = self.reload(plugin)98 self.assertEqual(plugin.body, 'body')99 100 def test_add_ph(self):101 """102 Test adding a *NON PAGE* plugin103 """104 page, placeholder, superuser, staff = self.get_data()105 plugin_data = {106 'plugin_type':"TextPlugin",107 'language':settings.LANGUAGES[0][0],108 'placeholder':page.placeholders.get(slot="body").pk,109 }110 url = reverse('admin:placeholderapp_example1_add_plugin')111 self.assertEqual(CMSPlugin.objects.count(), 0)112 # log the user out and try to add a plugin using PlaceholderAdmin113 self.client.logout()114 response = self.client.post(url, plugin_data)115 # since the user is not logged in, they should be prompted to log in.116 self.assertTemplateUsed(response, 'admin/login.html')117 self.assertEqual(CMSPlugin.objects.count(), 0)118 # now log a staff user without permissions in and do the same as above.119 self.client.login(username='staff', password='staff')120 response = self.client.post(url, plugin_data)121 # the user is logged in and the security check fails, so it should 403.122 self.assertEqual(response.status_code, 403)123 self.assertEqual(CMSPlugin.objects.count(), 0)124 125 def test_edit_ph(self):126 """127 Test editing a *NON PAGE* plugin128 """129 page, placeholder, superuser, staff = self.get_data()130 plugin = add_plugin(placeholder, 'TextPlugin', 'en', body='body')131 url = reverse('admin:placeholderapp_example1_edit_plugin', args=(plugin.pk,))132 plugin_data = {133 'body': 'newbody',134 'language': 'en',135 'plugin_id': plugin.pk,136 }137 plugin = self.reload(plugin)138 self.assertEqual(plugin.body, 'body')139 # log the user out and try to edit a plugin using PlaceholderAdmin140 self.client.logout()141 response = self.client.post(url, plugin_data)142 # since the user is not logged in, they should be prompted to log in.143 self.assertTemplateUsed(response, 'admin/login.html')144 plugin = self.reload(plugin)145 self.assertEqual(plugin.body, 'body')146 # now log a staff user without permissions in and do the same as above.147 self.client.login(username='staff', password='staff')148 response = self.client.post(url, plugin_data)149 # the user is logged in and the security check fails, so it should 403.150 self.assertEqual(response.status_code, 403)151 plugin = self.reload(plugin)152 self.assertEqual(plugin.body, 'body')153 154 def test_delete_ph(self):155 page, placeholder, superuser, staff = self.get_data()156 plugin = add_plugin(placeholder, 'TextPlugin', 'en', body='body')157 plugin_data = {158 'plugin_id': plugin.pk,159 }160 plugin = self.reload(plugin)161 self.assertEqual(plugin.body, 'body')162 url = reverse('admin:placeholderapp_example1_remove_plugin')163 # log the user out and try to remove a plugin using PlaceholderAdmin164 self.client.logout()165 response = self.client.post(url, plugin_data)166 # since the user is not logged in, they should be prompted to log in.167 self.assertTemplateUsed(response, 'admin/login.html')168 self.assertEqual(CMSPlugin.objects.count(), 1)169 # now log a staff user without permissions in and do the same as above.170 self.client.login(username='staff', password='staff')171 response = self.client.post(url, plugin_data)172 # the user is logged in and the security check fails, so it should 403.173 self.assertEqual(response.status_code, 403)174 self.assertEqual(CMSPlugin.objects.count(), 1)175 176 def test_text_plugin_xss(self):177 page, placeholder, superuser, staff = self.get_data()178 with self.login_user_context(superuser):179 plugin = add_plugin(placeholder, 'TextPlugin', 'en', body='body')180 # ACTUAL TEST STARTS HERE.181 data = {182 "body": "<div onload='do_evil_stuff();'>divcontent</div><a href='javascript:do_evil_stuff()'>acontent</a>"183 }184 edit_url = '%s%s/' % (URL_CMS_PLUGIN_EDIT, plugin.pk)185 response = self.client.post(edit_url, data)186 self.assertEquals(response.status_code, 200)187 txt = Text.objects.all()[0]...

Full Screen

Full Screen

pluginHandler.py

Source:pluginHandler.py Github

copy

Full Screen

1import json2import os3from resources.lib import common, logger4from resources.lib.config import cConfig5class cPluginHandler:6 def __init__(self):7 self.addon = common.addon8 self.rootFolder = common.addonPath9 self.settingsFile = os.path.join(self.rootFolder, 'resources', 'settings.xml')10 self.profilePath = common.profilePath11 self.pluginDBFile = os.path.join(self.profilePath,'pluginDB')12 logger.info('profile folder: %s' % self.profilePath)13 logger.info('root folder: %s' % self.rootFolder)14 self.defaultFolder = os.path.join(self.rootFolder, 'sites')15 logger.info('default sites folder: %s' % self.defaultFolder)16 def getAvailablePlugins(self):17 pluginDB = self.__getPluginDB()18 # default plugins19 update = False20 fileNames = self.__getFileNamesFromFolder(self.defaultFolder)21 for fileName in fileNames:22 plugin = {'name':'', 'icon':'', 'settings':'', 'modified':0}23 if fileName in pluginDB:24 plugin.update(pluginDB[fileName])25 try:26 modTime = os.path.getmtime(os.path.join(self.defaultFolder,fileName+'.py'))27 except OSError:28 modTime = 029 if fileName not in pluginDB or modTime > plugin['modified']:30 logger.info('load plugin: ' + str(fileName))31 # try to import plugin32 pluginData = self.__getPluginData(fileName)33 if pluginData:34 pluginData['modified'] = modTime35 pluginDB[fileName] = pluginData36 update = True37 # check pluginDB for obsolete entries38 deletions = []39 for pluginID in pluginDB:40 if pluginID not in fileNames:41 deletions.append(pluginID)42 for id in deletions:43 del pluginDB[id]44 if update or deletions:45 self.__updateSettings(pluginDB)46 self.__updatePluginDB(pluginDB)47 return self.getAvailablePluginsFromDB()48 def getAvailablePluginsFromDB(self):49 plugins = []50 oConfig = cConfig()51 iconFolder = os.path.join(self.rootFolder, 'resources','art','sites')52 pluginDB = self.__getPluginDB()53 for pluginID in pluginDB:54 plugin = pluginDB[pluginID]55 pluginSettingsName = 'plugin_%s' % pluginID56 plugin['id'] = pluginID57 if 'icon' in plugin:58 plugin['icon'] = os.path.join(iconFolder, plugin['icon'])59 else:60 plugin['icon'] = ''61 # existieren zu diesem plugin die an/aus settings62 if oConfig.getSetting(pluginSettingsName) == 'true':63 plugins.append(plugin)64 return plugins65 def __updatePluginDB(self, data):66 if not os.path.exists(self.profilePath):67 os.makedirs(self.profilePath)68 file = open(self.pluginDBFile, 'w')69 json.dump(data,file)70 file.close()71 def __getPluginDB(self):72 if not os.path.exists(self.pluginDBFile):73 return dict()74 file = open(self.pluginDBFile, 'r')75 try:76 data = json.load(file)77 except ValueError:78 logger.error("pluginDB seems corrupt, creating new one")79 data = dict()80 file.close()81 return data82 def __updateSettings(self, pluginData):83 '''84 data (dict): containing plugininformations85 '''86 xmlString = '<plugin_settings>%s</plugin_settings>'87 import xml.etree.ElementTree as ET88 tree = ET.parse(self.settingsFile)89 #find Element for plugin Settings90 pluginElem = False91 for elem in tree.findall('category'):92 if elem.attrib['label']=='30021':93 pluginElem = elem94 break95 if pluginElem is None:96 logger.info('could not update settings, pluginElement not found')97 return False98 pluginElements = pluginElem.findall('setting')99 for elem in pluginElements:100 pluginElem.remove(elem)101 # add plugins to settings102 for pluginID in sorted(pluginData):103 plugin = pluginData[pluginID]104 subEl = ET.SubElement(pluginElem,'setting', {'type': 'lsep', 'label':plugin['name']})105 subEl.tail = '\n '106 attrib = {'default': 'true', 'type': 'bool'}107 attrib['id'] = 'plugin_%s' % pluginID108 attrib['label'] = '30050'109 subEl = ET.SubElement(pluginElem, 'setting', attrib)110 subEl.tail = '\n '111 attrib = {'default': str(plugin['globalsearch']).lower(), 'type': 'bool'}112 attrib['id'] = 'global_search_%s' % pluginID113 attrib['label'] = '30052'114 attrib['enable'] = "!eq(-1,false)"115 subEl = ET.SubElement(pluginElem, 'setting', attrib)116 subEl.tail = '\n '117 if 'settings' in plugin:118 customSettings = []119 try:120 customSettings = ET.XML(xmlString % plugin['settings']).findall('setting')121 except:122 logger.info('Parsing of custom settings for % failed.' % plugin['name'])123 for setting in customSettings:124 setting.tail = '\n '125 pluginElem.append(setting)126 subEl = ET.SubElement(pluginElem, 'setting', {'type': 'sep'})127 subEl.tail = '\n '128 pluginElements = pluginElem.findall('setting')[-1].tail = '\n'129 try:130 ET.dump(pluginElem)131 except:132 logger.info('Settings update failed')133 return134 tree.write(self.settingsFile)135 def __getFileNamesFromFolder(self, sFolder):136 aNameList = []137 items = os.listdir(sFolder)138 for sItemName in items:139 if sItemName.endswith('.py'):140 sItemName = os.path.basename(sItemName[:-3])141 aNameList.append(sItemName)142 return aNameList143 def __getPluginData(self, fileName):144 pluginData = {}145 try:146 plugin = __import__(fileName, globals(), locals())147 pluginData['name'] = plugin.SITE_NAME148 except Exception, e:149 logger.error("Can't import plugin: %s :%s" % (fileName, e))150 return False151 try:152 pluginData['icon'] = plugin.SITE_ICON153 except:154 pass155 try:156 pluginData['settings'] = plugin.SITE_SETTINGS157 except:158 pass159 try:160 pluginData['globalsearch'] = plugin.SITE_GLOBAL_SEARCH161 except:162 pluginData['globalsearch'] = True163 pass...

Full Screen

Full Screen

plugin_pool.py

Source:plugin_pool.py Github

copy

Full Screen

...15 if self.discovered:16 return17 self.discovered = True18 load('cms_plugins')19 def register_plugin(self, plugin):20 """21 Registers the given plugin(s).22 If a plugin is already registered, this will raise PluginAlreadyRegistered.23 """24 if hasattr(plugin,'__iter__'):25 warnings.warn("Registering more than one plugin at once will be deprecated in 2.3", DeprecationWarning)26 for single_plugin in plugin:27 self.register_plugin(single_plugin)28 return29 if not issubclass(plugin, CMSPluginBase):30 raise ImproperlyConfigured(31 "CMS Plugins must be subclasses of CMSPluginBase, %r is not."32 % plugin33 )34 plugin_name = plugin.__name__35 if plugin_name in self.plugins:36 raise PluginAlreadyRegistered(37 "Cannot register %r, a plugin with this name (%r) is already "38 "registered." % (plugin, plugin_name)39 )40 plugin.value = plugin_name41 self.plugins[plugin_name] = plugin42 if 'reversion' in settings.INSTALLED_APPS:43 try:44 from reversion.registration import RegistrationError45 except ImportError:46 from reversion.revisions import RegistrationError47 try:48 reversion_register(plugin.model)49 except RegistrationError:50 pass51 def unregister_plugin(self, plugin):52 """53 Unregisters the given plugin(s).54 If a plugin isn't already registered, this will raise PluginNotRegistered.55 """56 if hasattr(plugin,'__iter__'):57 warnings.warn("Unregistering more than one plugin at once will be deprecated in 2.3", DeprecationWarning)58 for single_plugin in plugin:59 self.unregister_plugin(single_plugin)60 return 61 plugin_name = plugin.__name__62 if plugin_name not in self.plugins:63 raise PluginNotRegistered(64 'The plugin %r is not registered' % plugin65 )66 del self.plugins[plugin_name]67 def get_all_plugins(self, placeholder=None, page=None, setting_key="plugins", include_page_only=True):68 self.discover_plugins()69 plugins = self.plugins.values()[:]70 plugins.sort(key=lambda obj: unicode(obj.name))71 final_plugins = []72 if page:73 template = page.get_template()74 else:75 template = None76 allowed_plugins = get_placeholder_conf(77 setting_key,78 placeholder,79 template,80 )81 for plugin in plugins:82 include_plugin = False83 if placeholder:84 if allowed_plugins:85 if plugin.__name__ in allowed_plugins:86 include_plugin = True87 elif setting_key == "plugins":88 include_plugin = True89 if plugin.page_only and not include_page_only:90 include_plugin = False91 if include_plugin:92 final_plugins.append(plugin)93 94 if final_plugins:95 plugins = final_plugins96 # plugins sorted by modules97 plugins = sorted(plugins, key=lambda obj: unicode(obj.module))98 return plugins99 def get_text_enabled_plugins(self, placeholder, page):100 plugins = self.get_all_plugins(placeholder, page)101 plugins +=self.get_all_plugins(placeholder, page, 'text_only_plugins')102 final = []103 for plugin in plugins:104 if plugin.text_enabled:105 if plugin not in final:106 final.append(plugin)107 return final108 def get_plugin(self, name):109 """110 Retrieve a plugin from the cache.111 """112 self.discover_plugins()113 return self.plugins[name]...

Full Screen

Full Screen

interface.py

Source:interface.py Github

copy

Full Screen

1import Products.PluggableAuthService.interfaces.plugins as plugins2IAnonymousUserFactoryPlugin = plugins.IAnonymousUserFactoryPlugin3IAuthenticationPlugin = plugins.IAuthenticationPlugin4IChallengePlugin = plugins.IChallengePlugin5IChallengeProtocolChooser = plugins.IChallengeProtocolChooser6ICredentialsResetPlugin = plugins.ICredentialsResetPlugin7ICredentialsUpdatePlugin = plugins.ICredentialsUpdatePlugin8IExtractionPlugin = plugins.IExtractionPlugin9IGroupEnumerationPlugin = plugins.IGroupEnumerationPlugin10IGroupsPlugin = plugins.IGroupsPlugin11ILoginPasswordExtractionPlugin = plugins.ILoginPasswordExtractionPlugin12ILoginPasswordHostExtractionPlugin = plugins.ILoginPasswordHostExtractionPlugin13IPropertiesPlugin = plugins.IPropertiesPlugin14IRequestTypeSniffer = plugins.IRequestTypeSniffer15IRoleAssignerPlugin = plugins.IRoleAssignerPlugin16IRoleEnumerationPlugin = plugins.IRoleEnumerationPlugin17IRolesPlugin = plugins.IRolesPlugin18IUpdatePlugin = plugins.IUpdatePlugin19IUserAdderPlugin = plugins.IUserAdderPlugin20IUserEnumerationPlugin = plugins.IUserEnumerationPlugin21IUserFactoryPlugin = plugins.IUserFactoryPlugin22IValidationPlugin = plugins.IValidationPlugin23class IPackagePlugin(IAnonymousUserFactoryPlugin, IAuthenticationPlugin,24 IChallengePlugin, IChallengeProtocolChooser, ICredentialsResetPlugin,25 ICredentialsUpdatePlugin, IExtractionPlugin, IGroupEnumerationPlugin,26 IGroupsPlugin, ILoginPasswordExtractionPlugin,27 ILoginPasswordHostExtractionPlugin, IPropertiesPlugin,28 IRequestTypeSniffer, IRoleAssignerPlugin,29 IRoleEnumerationPlugin, IRolesPlugin,30 IUpdatePlugin, IUserAdderPlugin,31 IUserEnumerationPlugin, IUserFactoryPlugin, IValidationPlugin):...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = function(config) {2 config.set({3 });4};5module.exports = function(config) {6 config.set({7 });8};

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2strykerParent.plugin();3var strykerChild = require('stryker-child');4strykerChild.plugin();5var strykerGrandChild = require('stryker-grandchild');6strykerGrandChild.plugin();7var strykerGreatGrandChild = require('stryker-greatgrandchild');8strykerGreatGrandChild.plugin();9var strykerGreatGreatGrandChild = require('stryker-greatgreatgrandchild');10strykerGreatGreatGrandChild.plugin();11var strykerGreatGreatGreatGrandChild = require('stryker-greatgreatgreatgrandchild');12strykerGreatGreatGreatGrandChild.plugin();13var strykerGreatGreatGreatGreatGrandChild = require('stryker-greatgreatgreatgreatgrandchild');14strykerGreatGreatGreatGreatGrandChild.plugin();15var strykerGreatGreatGreatGreatGreatGrandChild = require('stryker-greatgreatgreatgreatgreatgrandchild');16strykerGreatGreatGreatGreatGreatGrandChild.plugin();17var strykerGreatGreatGreatGreatGreatGreatGrandChild = require('stryker-greatgreatgreatgreatgreatgreatgrandchild');18strykerGreatGreatGreatGreatGreatGreatGrandChild.plugin();19var strykerGreatGreatGreatGreatGreatGreatGreatGrandChild = require('stryker-greatgreatgreatgreatgreatgreatgreatgrandchild');20strykerGreatGreatGreatGreatGreatGreatGreatGrandChild.plugin();21var strykerGreatGreatGreatGreatGreatGreatGreatGreatGrandChild = require('stryker-greatgreatgreatgreatgreatgreatgreatgreatgrandchild');

Full Screen

Using AI Code Generation

copy

Full Screen

1var myPlugin = require('stryker-parent').plugin;2myPlugin();3var myPlugin = require('stryker-child').plugin;4myPlugin();5var myPlugin = require('stryker-grandchild').plugin;6myPlugin();7var myPlugin = require('stryker-greatgrandchild').plugin;8myPlugin();9var myPlugin = require('stryker-greatgreatgrandchild').plugin;10myPlugin();11var myPlugin = require('stryker-greatgreatgreatgrandchild').plugin;12myPlugin();13var myPlugin = require('stryker-greatgreatgreatgreatgrandchild').plugin;14myPlugin();15var myPlugin = require('stryker-greatgreatgreatgreatgreatgrandchild').plugin;16myPlugin();17var myPlugin = require('stryker-greatgreatgreatgreatgreatgreatgrandchild').plugin;18myPlugin();19var myPlugin = require('stryker-greatgreatgreatgreatgreatgreatgreatgrandchild').plugin;20myPlugin();21var myPlugin = require('stryker-greatgreatgreatgreatgreatgreatgreatgreatgrandchild').plugin;22myPlugin();23var myPlugin = require('stryker-greatgreatgreatgreatgreatgreatgreatgreatgreatgrand

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var config = {3};4stryker.run(config).then(function (result) {5 console.log('Done!');6}, function (error) {7 console.error('Failed to run stryker. Error: ', error);8});9{10 "scripts": {11 },12 "devDependencies": {13 }14}

Full Screen

Using AI Code Generation

copy

Full Screen

1const parent = require('stryker-parent');2parent.method();3module.exports = {4 method: () => 'Hello world'5};6module.exports = function(config) {7 config.set({8 });9};10module.exports = function() {11 return {12 method: () => 'Hello world'13 };14};15module.exports = function(config) {16 config.set({17 });18};19module.exports = {20 createPlugin: function() {21 return {22 method: () => 'Hello world'23 };24 }25};26module.exports = function(config) {27 config.set({28 });29};30module.exports = {31 createPlugin: function() {32 return {33 method: () => 'Hello world'34 };35 }36};37module.exports = function(config) {38 config.set({39 });40};41module.exports = {42 createPlugin: function() {43 return {44 method: () => 'Hello world'45 };46 }47};48module.exports = function(config) {49 config.set({50 });51};52module.exports = {53 createPlugin: function() {54 return {55 method: () => 'Hello world'56 };57 }58};

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2module.exports = function (strykerConfig) {3 return strykerParent(strykerConfig, {4 });5};6module.exports = function (config) {7 config.set({8 mochaOptions: {9 },10 });11};

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful