parameters: (username)
docstring: Write supervisord.conf configuration file if it does not exist yet.
docstring_summary: Write supervisord.conf configuration file if it does not exist yet.
docstring_tokens: Write supervisord . conf configuration file if it does not exist yet .
function: def write_supervisor_conf(username):
      """Write supervisord.conf configuration file if it does not exist yet."""
      # TODO Handle updates?
      if os.path.exists(cwd("supervisord.conf")):
          return
  
      if os.environ.get("VIRTUAL_ENV"):
          virtualenv = os.path.join(os.environ["VIRTUAL_ENV"], "bin")
          python_path = os.path.join(virtualenv, "python")
          cuckoo_path = os.path.join(virtualenv, "cuckoo")
      else:
          python_path = "python"
          cuckoo_path = "cuckoo"
  
      template = jinja2.Environment().from_string(
          open(cwd("cwd", "supervisord.jinja2", private=True), "rb").read()
      )
  
      with open(cwd("supervisord.conf"), "wb") as f:
          f.write(template.render({
              "cwd": cwd,
              "username": username,
              "cuckoo_path": cuckoo_path,
              "python_path": python_path,
          }).rstrip().encode("utf8") + "\n")
function_tokens: def write_supervisor_conf ( username ) : # TODO Handle updates? if os . path . exists ( cwd ( "supervisord.conf" ) ) : return if os . environ . get ( "VIRTUAL_ENV" ) : virtualenv = os . path . join ( os . environ [ "VIRTUAL_ENV" ] , "bin" ) python_path = os . path . join ( virtualenv , "python" ) cuckoo_path = os . path . join ( virtualenv , "cuckoo" ) else : python_path = "python" cuckoo_path = "cuckoo" template = jinja2 . Environment ( ) . from_string ( open ( cwd ( "cwd" , "supervisord.jinja2" , private = True ) , "rb" ) . read ( ) ) with open ( cwd ( "supervisord.conf" ) , "wb" ) as f : f . write ( template . render ( { "cwd" : cwd , "username" : username , "cuckoo_path" : cuckoo_path , "python_path" : python_path , } ) . rstrip ( ) . encode ( "utf8" ) + "\n" )