def move_plugins(valid_plugins,app_dest): ''' Moves valid plugins into the app folder for install valid_plugins: a list of full paths to valid plugin folders app_dest: full path to app destination folder ''' moved_plugins = [] for valid_plugin in valid_plugins: try: plugin_folder = os.path.basename(valid_plugin) copy_directory(valid_plugin,"%s/wordfish/plugins/%s" %(app_dest,plugin_folder)) moved_plugins.append(valid_plugin) except: print("Cannot move %s, will not be installed." %(valid_plugin)) return moved_plugins
def move_plugins(valid_plugins, app_dest): ''' Moves valid plugins into the app folder for install valid_plugins: a list of full paths to valid plugin folders app_dest: full path to app destination folder ''' moved_plugins = [] for valid_plugin in valid_plugins: try: plugin_folder = os.path.basename(valid_plugin) copy_directory( valid_plugin, "%s/wordfish/plugins/%s" % (app_dest, plugin_folder)) moved_plugins.append(valid_plugin) except: print("Cannot move %s, will not be installed." % (valid_plugin)) return moved_plugins
def generate_app(app_dest, app_repo=None, plugin_repo=None, plugins=None): '''generate create an app (python module) from a template and list of plugins Parameters ========== app_dest: path folder to generate the app (python module) in app_repo: path full path to wordfish-python (template) repo plugins: list full paths to plugin folders for inclusion ''' # We can only generate an in a folder that does not exist, to be safe if not os.path.exists(app_dest): if app_repo == None or plugin_repo == None: tmpdir = custom_app_download() if app_repo == None: app_repo = "%s/python" % (tmpdir) if plugin_repo == None: plugin_repo = "%s/plugins" % (tmpdir) # Copy app skeleton to destination copy_directory(app_repo, app_dest) valid_plugins = get_plugins(plugin_repo) # If the user wants to select a subset if plugins != None: subset_plugins = [ x for x in valid_plugins if os.path.basename(x) in plugins ] valid_plugins = subset_plugins # Generate the requirements.txt from template to include all python dependencies for plugins generate_requirements(valid_plugins, app_dest) # Copy valid plugins into app_repo move_plugins(valid_plugins, app_dest) # Generate run commands setup_extraction(valid_plugins, app_dest) else: print("Folder exists at %s, cannot generate." % (battery_dest))
def generate_app(app_dest,app_repo=None,plugin_repo=None,plugins=None): '''generate create an app (python module) from a template and list of plugins Parameters ========== app_dest: path folder to generate the app (python module) in app_repo: path full path to wordfish-python (template) repo plugins: list full paths to plugin folders for inclusion ''' # We can only generate an in a folder that does not exist, to be safe if not os.path.exists(app_dest): if app_repo == None or plugin_repo == None: tmpdir = custom_app_download() if app_repo == None: app_repo = "%s/python" %(tmpdir) if plugin_repo == None: plugin_repo = "%s/plugins" %(tmpdir) # Copy app skeleton to destination copy_directory(app_repo,app_dest) valid_plugins = get_plugins(plugin_repo) # If the user wants to select a subset if plugins != None: subset_plugins = [x for x in valid_plugins if os.path.basename(x) in plugins] valid_plugins = subset_plugins # Generate the requirements.txt from template to include all python dependencies for plugins generate_requirements(valid_plugins,app_dest) # Copy valid plugins into app_repo move_plugins(valid_plugins,app_dest) # Generate run commands setup_extraction(valid_plugins,app_dest) else: print("Folder exists at %s, cannot generate." %(battery_dest))