Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e1d6876 authored by Steve Block's avatar Steve Block
Browse files

Fix a bug in DumpRenderTree2's run_apache2.py script

We use a printf style approach when setting the run command in the
command string to be executed. When doing so, the printf must be
applied to only the relevant part of the string. This avoids problems
in the case that other parts of the string contain special character
sequences, such as '%s' in a custom log directive.

Change-Id: I87df773a2872320386a34cb6a5041a9e0ba6f31e
parent 34f3851e
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -109,18 +109,17 @@ def main(options, args):

  # Try to execute the commands
  logging.info("Will " + run_cmd + " apache2 server.")
  cmd_template = export_envvars_cmd + " && " + apache2_restart_template + directives + conf_file_cmd

  # It is worth noting here that if the configuration file with which we restart the server points
  # to a different PidFile it will not work and result in second apache2 instance.
  # to a different PidFile it will not work and will result in a second apache2 instance.
  if (run_cmd == 'restart'):
    logging.info("First will stop...")
    execute_cmd(cmd_template % ('stop'))
    execute_cmd(export_envvars_cmd + " && " + (apache2_restart_template % ('stop')) + directives + conf_file_cmd)
    logging.info("Stopped. Will start now...")
    # We need to sleep breifly to avoid errors with apache being stopped and started too quickly
    time.sleep(0.5)

  execute_cmd(cmd_template % (run_cmd))
  execute_cmd(export_envvars_cmd + " && " + (apache2_restart_template % (run_cmd)) + directives + conf_file_cmd)

def execute_cmd(cmd):
  p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)