def load_script(zap_helper, **options): """Load a script from a file.""" with zap_error_handler(): if not os.path.isfile(options['file_path']): raise ZAPError( 'No file found at "{0}", cannot load script.'.format( options['file_path'])) if not _is_valid_script_engine(zap_helper.zap, options['engine']): engines = zap_helper.zap.script.list_engines raise ZAPError( 'Invalid script engine provided. Valid engines are: {0}'. format(', '.join(engines))) console.debug('Loading script "{0}" from "{1}"'.format( options['name'], options['file_path'])) result = zap_helper.zap.script.load( options['name'], options['script_type'], options['engine'], options['file_path'], scriptdescription=options['description']) if result != 'OK': raise ZAPError('Error loading script: {0}'.format(result)) console.info('Script "{0}" loaded'.format(options['name']))
def load_session(zap_helper, file_path): """Load a given session.""" with zap_error_handler(): if not os.path.isfile(file_path): raise ZAPError('No file found at "{0}", cannot load session.'.format(file_path)) console.debug('Loading session from "{0}"'.format(file_path)) zap_helper.zap.core.load_session(file_path)
def load_session(zap_helper, file_path): """Load a given session.""" with zap_error_handler(): if not os.path.isfile(file_path): raise ZAPError( 'No file found at "{0}", cannot load session.'.format( file_path)) console.debug('Loading session from "{0}"'.format(file_path)) zap_helper.zap.core.load_session(file_path)
def remove_script(zap_helper, script_name): """Remove a script.""" with zap_error_handler(): console.debug('Removing script "{0}"'.format(script_name)) result = zap_helper.zap.script.remove(script_name) if result != 'OK': raise ZAPError('Error removing script: {0}'.format(result)) console.info('Script "{0}" removed'.format(script_name))
def disable_script(zap_helper, script_name): """Disable a script.""" with zap_error_handler(): console.debug('Disabling script "{0}"'.format(script_name)) result = zap_helper.zap.script.disable(script_name) if result != 'OK': raise ZAPError('Error disabling script: {0}'.format(result)) console.info('Script "{0}" disabled'.format(script_name))
def load_script(zap_helper, **options): """Load a script from a file.""" with zap_error_handler(): if not os.path.isfile(options['file_path']): raise ZAPError('No file found at "{0}", cannot load script.'.format(options['file_path'])) if not _is_valid_script_engine(zap_helper.zap, options['engine']): engines = zap_helper.zap.script.list_engines raise ZAPError('Invalid script engine provided. Valid engines are: {0}'.format(', '.join(engines))) console.debug('Loading script "{0}" from "{1}"'.format(options['name'], options['file_path'])) result = zap_helper.zap.script.load(options['name'], options['script_type'], options['engine'], options['file_path'], scriptdescription=options['description']) if result != 'OK': raise ZAPError('Error loading script: {0}'.format(result)) console.info('Script "{0}" loaded'.format(options['name']))
def save_session(zap_helper, file_path): """Save the session.""" console.debug('Saving the session to "{0}"'.format(file_path)) zap_helper.zap.core.save_session(file_path, overwrite='true')
def new_session(zap_helper): """Start a new session.""" console.debug('Starting a new session') zap_helper.zap.core.new_session()