javascript – NodeJS executing multiple database queries using async library

I have a use case where I need to run multiple tasks in series. Each task is required to perform some database operations. In my code step_1, step_2 and step_3 are these task which get executed in series (Async Waterfall)

Following is my code

const config = require('config.json');
var mysql = require('mysql');
var async = require("async");

const pool = mysql.createPool({
  host: config.database.dbhost,
  user: config.database.dbuser,
  password: config.database.dbpassword,
  database: config.database.dbname

exports.handler = (event, context, callback) => {
    pool.getConnection((err, connection) => {
    if (err) throw new Error("Unable to get connection " + JSON.stringify(err));
        ), function (err, result) {
                throw new Error("something went south : "+ JSON.stringify(err));
                callback(null, "SUCCESS: " + JSON.stringify(result));

        function step_1(cb){
            connection.query("step 1 query", function (error, response) {
                      if (error){
                      let id=result.insertId;

        function step_2(error,id,cb){
                connection.query("step 2 query",,function (err,result){
                        if (err){
                          connection.query("error logging query",
                            if (er) cb(null,er,null);                    
                    cb(null,null, id, result);

        function step_3(error, id,result,cb){
                connection.query("step 3 query",function(err,result){
                    if (err) cb(err,null);                  


Although I have used a library to avoid nesting callbacks within callbacks, it still feels like bit callback-ish. Is there a better way to achieve my use case? Anything I can improve in my code, any suggestions please.

I have only included relevant parts of code, kindly let me know if any additional information is required.

simple automation executing platform in python

so as the title suggests i’m building a platform like Rundeck/AWX but for server reliebility testing.

people could log in to a web interface upload scripts, run them on servers and get statistics on them ( failure / success).

each script is made up of three parts, probes to check if the server is fine, methods to do stuff in the server, and rollback to reverse what we did to the server.

first we run the probes, if they past we run the methods, wait a certein time the user that created the method put, then run the probes again to check if the server self healed, if not then we run the rollbacks and probes again, then send the data to the db.

I have limited expirience with proggramming as a job and am very unsure if what im doing is good let alone efficient so I would love to get some really harsh criticism.

this is the micro-service that is in charge of running the scripts the users request, it gets a dns and the fault name (fault is the whole object of probes/methods/rollbacks)

import requests
from time import sleep
import subprocess
import time
import script_manipluator as file_manipulator

class InjectionSlave():

    def __init__(self,db_api_url = "http://chaos.db.openshift:5001"):
        self.db_api_url = db_api_url

    def initiate_fault(self,dns,fault):
        return self._orchestrate_injection(dns,fault)

    def _orchestrate_injection(self,dns,fault_name):
        try :
            # Gets fault full information from db
            fault_info = self._get_fault_info(fault_name)
        except Exception as E :
            return { "exit_code":"1" ,"status": "Injector failed gathering facts" }
        try :
            # Runs the probes,methods and rollbacks by order.
            logs_object = self._run_fault(dns, fault_info)
        except :
            return { "exit_code":"1" ,"status": "Injector failed injecting fault" }
        try :
            # Sends logs to db to be stored in the "logs" collection
            db_response = self._send_result(dns,logs_object,"logs")
            return db_response
        except Exception as E:
            return { "exit_code":"1" ,"status": "Injector failed sending logs to db" }

    def _get_fault_info(self,fault_name):
        # Get json object for db rest api
        db_fault_api_url = "{}/{}/{}".format(self.db_api_url, "fault", fault_name)
        fault_info = requests.get(db_fault_api_url).json()

        # Get the names of the parts of the fault
        probes = fault_info("probes")
        methods = fault_info("methods")
        rollbacks = fault_info("rollbacks")
        name  = fault_info("name")

        fault_structure = {'probes' : probes , 'methods' : methods , 'rollbacks' : rollbacks}

        # fault_section can be the probes/methods/rollbacks part of the fault
        for fault_section in fault_structure.keys():
            fault_section_parts = ()

            # section_part refers to a specific part of the probes/methods/rollbacks
            for section_part in fault_structure(fault_section):
                section_part_info = requests.get("{}/{}/{}".format(self.db_api_url,fault_section,section_part)).json()

            fault_structure(fault_section) = fault_section_parts

        fault_structure("name") =  name
        return fault_structure

    def _run_fault(self,dns,fault_info):

            # Gets fault parts from fault_info
            fault_name = fault_info('name')
            probes = fault_info('probes')
            methods = fault_info('methods')
            rollbacks = fault_info('rollbacks')

        except Exception as E :
            logs_object = {'name': "failed_fault" ,'exit_code' : '1' ,
                           'status' : 'expirement failed because parameters in db were missing ', 'error' : E}
            return logs_object

        try :

            method_logs = {}
            rollback_logs = {}
            probe_after_method_logs = {}

            # Run probes and get logs and final probes result
            probes_result,probe_logs  = self._run_probes(probes,dns)

            # If probes all passed continue
            if probes_result is True :

                probe_logs('exit_code')  =  "0"
                probe_logs('status') = "Probes checked on victim server successfully"

                # Run methods and  get logs and how much time to wait until checking self recovery
                methods_wait_time, method_logs = self._run_methods(methods, dns)

                # Wait the expected recovery wait time

                probes_result, probe_after_method_logs = self._run_probes(probes, dns)
                # Check if server self healed after injection
                if probes_result is True:
                    probe_after_method_logs('exit_code') = "0"
                    probe_after_method_logs('status') = "victim succsessfully self healed after injection"
                    probe_after_method_logs('exit_code') = "1"
                    probe_after_method_logs('status') = "victim failed self healing after injection"

                    # If server didnt self heal run rollbacks
                    for rollback in rollbacks:
                        part_name = rollback('name')
                        part_log = self._run_fault_part(rollback, dns)
                        rollback_logs(part_name) = part_log

                    probes_result, probe_after_method_logs = self._run_probes(probes, dns)

                    # Check if server healed after rollbacks
                    if probes_result is True:
                        rollbacks('exit_code') = "0"
                        rollbacks('status') = "victim succsessfully  healed after rollbacks"
                        rollbacks('exit_code') = "1"
                        rollbacks('status') = "victim failed healing after rollbacks"
            else :
                probe_logs('exit_code') = "1"
                probe_logs('status') = "Probes check failed on victim server"

            logs_object = {'name': fault_name ,'exit_code' : '0' ,
                           'status' : 'expirement ran as expected','rollbacks' : rollback_logs ,
                           'probes' : probe_logs , 'method_logs' : method_logs,
                           'probe_after_method_logs' : probe_after_method_logs}

            if logs_object("probe_after_method_logs")("exit_code") == "0" :
                logs_object("successful") = True
                logs_object("successful") = False

        except Exception as E:
            logs_object = {'name': fault_name ,'exit_code' : '1' ,
                           'status' : 'expirement failed because of an unexpected reason', 'error' : E}

        return logs_object

    def _inject_script(self,dns,script_path):
        # Run script
        proc = subprocess.Popen("python {} -dns {}".format(script_path,dns), stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT, shell=True)
        # get output from proc turn it from binary to ascii and then remove /n if there is one
        output = proc.communicate()(0).decode('ascii').rstrip()
        return output

    def _run_fault_part(self,fault_part,dns):
        script, script_name = file_manipulator._get_script(fault_part)
        script_file_path = file_manipulator._create_script_file(script, script_name)
        logs = self._inject_script(dns, script_file_path)
        return logs

    def _str2bool(self,output):
        return output.lower() in ("yes", "true", "t", "1")

    def _run_probes(self,probes,dns):

        probes_output  = {}

        # Run each probe and get back True/False boolean result
        for probe in probes :
            output = self._run_fault_part(probe, dns)
            result = self._str2bool(output)
            probes_output(probe('name')) =  result

        probes_result = probes_output.values()

        # If one of the probes returned False the probes check faild
        if False in probes_result :
            return False,probes_output

        return True,probes_output

    def _get_method_wait_time(self,method):
            return  method('method_wait_time')
        except Exception as E :
            return 0

    def _get_current_time(self):
        current_time =  time.strftime('%Y%m%d%H%M%S')
        return current_time

    def _run_methods(self,methods,dns):
        method_logs = {}
        methods_wait_time = 0

        for method in methods:
            part_name = method('name')
            part_log = self._run_fault_part(method, dns)
            method_wait_time = self._get_method_wait_time(method)
            method_logs(part_name) = part_log
            methods_wait_time += method_wait_time

        return  methods_wait_time,method_logs

    def _send_result(self,dns,logs_object,collection = "logs"):
        # Get current time to timestamp the object
        current_time = self._get_current_time()

        # Creating object we will send to the db
        db_log_object = {}
        db_log_object('date') = current_time
        db_log_object('name') = "{}-{}".format(logs_object('name'),current_time)
        db_log_object('logs') = logs_object
        db_log_object('successful') = logs_object('successful')
        db_log_object('target') = dns

        # Send POST request to db api in the logs collection
        db_api_logs_url = "{}/{}".format(self.db_api_url,collection)
        response =, json = db_log_object)

        return  response.content.decode('ascii')

import os
import requests

def _get_script(fault_part):
    file_share_url = fault_part('path')
    script_name = fault_part('name')
    script = requests.get(file_share_url).content.decode('ascii')
    return script, script_name

def _create_script_file(script, script_name):
    injector_home_dir = "/root"
    script_file_path = '{}/{}'.format(injector_home_dir, script_name)
    with open(script_file_path, 'w') as script_file:
    return script_file_path

def _remove_script_file( script_file_path):

please rip me to shreds and btw sorry if i made any spelling mistakes.

8 – Why container in Drush command is different than the container in the test case that is executing this command?

I created a functional test for my module: . It is using Drush commands to load/purge/list fixtures, so I wanted test case starting from the beginning: the Drush command. By looking at code of the scheduler module, I learned that I can test Drush commands by using DrushTestTrait (source for reference: ) I stumbled on an issue though: it looks like for whatever reason, container in Drush command is in different state, than the container in the test case executing this Drush command.

What happens:
In my test case I’m enabling content_fixtures_test module, this module defines fixture and service with the content_fixture tag, that is supposed to be added to my Loader class by the service_collector. It is correctly added to my loader available in my test case, but loader available in my Drush command is empty, like it’s a different instance!

This is code in question:

You can locally replace $loader->loadFixtures(); with $this->drush('content-fixtures:load'); (and uncomment trait above) – that should result in the same thing, but the latter will fail, because for some reason Drush will think that the Loader is empty, so it won’t load any fixtures.

Any ideas why it doesn’t work as expected? Am I missing something?

Handy command to run this module’s tests: ./vendor/bin/phpunit -c ./web/core ./web/modules/contrib/content_fixtures . Just clone/require 8.x-1.x-dev branch.

Oh, I’m running these tests on Drupal 9.

magento2 – My Observer is not executing

Create Module Step by step.


use MagentoFrameworkComponentComponentRegistrar;


File:- app/code/SussexDev/Observers/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi=""
    <module name="SussexDev_Observers" setup_version="1.0.0">


<?xml version="1.0"?>
<config xmlns:xsi=""

    <event name="checkout_submit_all_after">
        <observer name="place_order" instance="SussexDevObserversObserverNewOrder"/>



namespace SussexDevObserversObserver;

use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkEventObserver;

class NewOrder implements ObserverInterface
     protected $logger;

     public function __construct(
        PsrLogLoggerInterface $logger
        ) {
        $this->logger = $logger;

  public function execute(Observer $observer)
        $txt = "n aaaaaa ";

        $this->logger->log('DEBUG', $txt);


Your module is completely created wrong. Please check below link how to create the module in Magento 2

Check the above files with code. create one by one and then hit below commands

Run CLI Commands

sudo php bin/magento setup:upgrade
Sudo php bin/magento setup:di:compile
sudo php bin/magento setup:static-content:deploy -f
sudo php bin/magento ca:cl
sudo php bin/magento ca:fl

I hope this will help you..!

oracle – Oracle19C installation is stuck at executing datapatch in Windows 10 using dbca

I tried using dbca. There are no errors. It just hangs. I tried leaving it running for 4 hours. It is always stuck at 36% even after multiple tries.


[progressPage.flowWorker] [ 2020-05-25 00:26:04.206 IST ] [CloneDBCreationStep.executeImpl:823] executing datapatch %ORACLE_HOME%OPatchdatapatch.bat

json – Error executing the Garnstart / npm Start command

As soon as I run the create-react-app command and create the project. in the end when I run the "start yarn" command. follows the following error:

Yarn run v1.22.4
Warning package.json: No license field
Start command error not found.
info Documentation for this command can be found at

I tried different things, e.g. For example, delete the node_modules folder, delete yarn.lock, delete package.json, uninstall the node and reinstall it. I don't know what happened because I executed the command normally a day ago. I hope you help me. Thank you!

java – strange problem with JTable when executing the program (when using the keyboard arrows the lines are not scrolled unless …)

I'm developing a program that populates a JTable from an SQLite database. The program works well, but note that this is not possible if you start it and select a row to use the keyboard arrows to scroll through the rest of the table. I thought I would need to add a keyListener or something similar to the JTable for this to work.

In the frame in which the JTable is located there is a JButton for adding a new row to the table in the database, which starts a new frame of another class in which the data is placed. If the button is pressed, it is deactivated and reactivated when the second frame is closed, so that no new windows can be opened. At the same time, the JTable can still be observed.

The funny thing is that it can somehow run through the JTable with the arrows. Opening the second frame is already possible when I save information or just close the window without doing anything. I created a method called Update (), which is the same one I use in the constructor to populate the JTable when the program starts and to update the JTable when adding a new line. Why am I clarifying this method? Because I also have a JButton that activates this Update () method when pressed, and when I do it from there, the arrows are deactivated again. However, if the method is activated when new information is saved, this does not happen.
The JTable contains events in which the second frame is opened by double-clicking on a line. However, with the information loaded into the TextFields, it is exactly the same window of the same class as when the Add button was started, only if it is not activated and not deactivated if you first use the Add button. They are also not disabled when changes are saved that call the Update () method again.

The truth is that I have no idea why this is happening. I have already completely checked the button code and there is nothing special that really affects this problem. I even tried adding a new JButton with exactly the same code as the Add button, but no arrows are activated.

Explanation: The Update () method and the components of JTable and JButton are static, so I can edit them from the second frame without calling the class of the first frame again
Clarification2: I use NetBeans to develop this project

Terminal – Executing the script from the startup agent failed

I'm trying to run the next script through LaunchAgent:

on run argv
    set current_path to POSIX path of ((path to me as text) & "::")
    set common to load script (current_path & "common.scpt")
    set screenSharingApp to "Screen Sharing"

        if application screenSharingApp is running then do shell script "killall '" & screenSharingApp & "'"
    end try
    repeat until application screenSharingApp is not running
        delay 0.1
    end repeat

    tell application screenSharingApp
    end tell

end run

But I always get this error: Execution error: Screen Sharing got an error: Application isn’t running. (-600)

If I run the same script from the script editor or the terminal, OK will run.

What can it be? Why does not it work?