Best Python code snippet using molecule_python
Playbook Caller.py
Source: Playbook Caller.py
1"""2"""3import phantom.rules as phantom4import json5from datetime import datetime, timedelta6##############################7# Start - Global Code Block8def comment_and_debug(container, comment):9 phantom.debug(comment)10 phantom.comment(container=container, comment=comment)11# End - Global Code block12##############################13def on_start(container):14 phantom.debug('on_start() called')15 16 # call 'Get_Playbook' block17 Get_Playbook(container=container)18 return19def Get_Playbook(action=None, success=None, container=None, results=None, handle=None, filtered_artifacts=None, filtered_results=None, custom_function=None, **kwargs):20 phantom.debug('Get_Playbook() called')21 22 id_value = container.get('id', None)23 container_data = phantom.collect2(container=container, datapath=['artifact:*.id', 'artifact:*.cef.data', 'artifact:*.id'])24 container_item_0 = [item[0] for item in container_data]25 container_item_1 = [item[1] for item in container_data]26 Get_Playbook__playbook_name = None27 Get_Playbook__object_key = None28 ################################################################################29 ## Custom Code Start30 ################################################################################31 Get_Playbook__playbook_name = "playbooks/Playbook Called"32 ################################################################################33 ## Custom Code End34 ################################################################################35 phantom.save_run_data(key='Get_Playbook:playbook_name', value=json.dumps(Get_Playbook__playbook_name))36 phantom.save_run_data(key='Get_Playbook:object_key', value=json.dumps(Get_Playbook__object_key))37 playbook_playbooks_Playbook_Called_1(container=container)38 return39def playbook_playbooks_Playbook_Called_1(action=None, success=None, container=None, results=None, handle=None, filtered_artifacts=None, filtered_results=None, custom_function=None, **kwargs):40 phantom.debug('playbook_playbooks_Playbook_Called_1() called')41 42 playbook_name = json.loads(phantom.get_run_data(key='Get_Playbook:playbook_name'))43 44 # call playbook "playbooks/Playbook Called", returns the playbook_run_id45 playbook_run_id = phantom.playbook(playbook=playbook_name, container=container, name="playbook_playbooks_Playbook_Called_1")46 return47def on_finish(container, summary):48 phantom.debug('on_finish() called')49 # This function is called after all actions are completed.50 # summary of all the action and/or all details of actions51 # can be collected here.52 # summary_json = phantom.get_summary()53 # if 'result' in summary_json:54 # for action_result in summary_json['result']:55 # if 'action_run_id' in action_result:56 # action_results = phantom.get_action_results(action_run_id=action_result['action_run_id'], result_data=False, flatten=False)57 # phantom.debug(action_results)...
playbook.py
Source: playbook.py
...5from disarmsite.auth import login_required6from disarmsite.database import db_session7from disarmsite.models import Playbook8bp = Blueprint('playbook', __name__, url_prefix='/playbook')9def get_playbook(id, check_author=True):10 playbook = Playbook.query.filter(Playbook.id == id).first()11 if playbook is None:12 abort(404, f"Playbook id {id} doesn't exist.")13 return playbook14@bp.route('/')15def index():16 playbooks = Playbook.query.all() #.order_by("disarm_id")17 return render_template('playbook/index.html', playbooks=playbooks)18@bp.route('/create', methods=('GET', 'POST'))19@login_required20def create():21 if request.method == 'POST':22 disarm_id = request.form['disarm_id']23 object_id = request.form['object_id']24 name = request.form['name']25 summary = request.form['summary']26 error = None27 if not name:28 error = 'Name is required.'29 if error is not None:30 flash(error)31 else:32 playbook = Playbook(disarm_id, object_id, name, summary)33 db_session.add(playbook)34 db_session.commit()35 return redirect(url_for('playbook.index'))36 return render_template('playbook/create.html')37@bp.route('/<int:id>/update', methods=('GET', 'POST'))38@login_required39def update(id):40 playbook = get_playbook(id)41 if request.method == 'POST':42 name = request.form['name']43 summary = request.form['summary']44 error = None45 if not name:46 error = 'Name is required.'47 if error is not None:48 flash(error)49 else:50 playbook.name = name51 playbook.summary = summary52 db_session.add(playbook)53 db_session.commit() 54 return redirect(url_for('playbook.index'))55 return render_template('playbook/update.html', playbook=playbook)56@bp.route('/<int:id>/delete', methods=('POST',))57@login_required58def delete(id):59 playbook = get_playbook(id)60 db_session.delete(playbook)61 db_session.commit() ...
Check out the latest blogs from LambdaTest on this topic:
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
Most test automation tools just do test execution automation. Without test design involved in the whole test automation process, the test cases remain ad hoc and detect only simple bugs. This solution is just automation without real testing. In addition, test execution automation is very inefficient.
I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!