コード例 #1
0
 def run(self):
     p = subprocess.Popen(['perl', 'fusioninventory-agent', '--stdout'],
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE,
                          env=get_launcher_env(),
                          cwd=get_launcher_env()['FUSION_BIN_PATH'])
     inventory, error = p.communicate()
     if not p.returncode == 0:
         return ("%f E: %s" % (time.time(), error), p.returncode)
     # Send the inventory to the DLP
     if self.command.dlp_client.send_inventory(inventory):
         return ("%f O: Inventory sent to the Pulse Inventory Server" % time.time(), 0)
     return ("%f E: Failed to send inventory to the Pulse Inventory Server" % time.time(), 1)
コード例 #2
0
ファイル: launcher.py プロジェクト: andrewlukoshko/mmc
def launcher(start_file, params, workdir):
    """
    Function for running commands in cygwin
    """
    output_queue = Queue.Queue()
    output = ""
    cmd_bash = "bash -c \"%s %s\"" % (start_file, params)
    output_queue.put("%f C: %s\n" % (time.time(), cmd_bash))
    logger.debug("Running %s" % cmd_bash)
    p = Popen(shlex.split(cmd_bash),
              bufsize=0,
              stderr=PIPE,
              stdout=PIPE,
              env=get_launcher_env(),
              cwd=workdir)

    err_reader = ReadFlux(p.stderr, output_queue, prepend="E:")
    err_reader.daemon = True
    err_reader.start()
    std_reader = ReadFlux(p.stdout, output_queue, prepend="O:")
    std_reader.daemon = True
    std_reader.start()
    # Wait for command to end
    exitcode = p.wait()
    logger.debug("Finisehd %s, exitcode: %d" % (cmd_bash, exitcode))
    output_queue.put("%f X: %d\n" % (time.time(), exitcode))
    err_reader.stop()
    std_reader.stop()
    # get and return the output
    while not output_queue.empty():
        output += output_queue.get()
        output_queue.task_done()
    return output, exitcode
コード例 #3
0
ファイル: launcher.py プロジェクト: AnatomicJC/mmc
def launcher(start_file, params, workdir):
    """
    Function for running commands in cygwin
    """
    output_queue = Queue.Queue()
    output = ""
    stf = NamedTemporaryFile(mode="w", delete=False)
    cmd_bash = "%s %s" % (start_file, params)
    stf.write(cmd_bash)
    stf.close()

    output_queue.put("%f C: %s\n" % (time.time(), cmd_bash))
    logger.debug("Running %s" % cmd_bash)
    p = Popen(["bash", stf.name],
              bufsize=0,
              stderr=PIPE,
              stdout=PIPE,
              env=get_launcher_env(),
              cwd=workdir)

    err_reader = ReadFlux(p.stderr, output_queue, prepend="E:")
    err_reader.daemon = True
    err_reader.start()
    std_reader = ReadFlux(p.stdout, output_queue, prepend="O:")
    std_reader.daemon = True
    std_reader.start()
    # Wait for command to end
    exitcode = p.wait()
    logger.debug("Finished %s, exitcode: %d" % (cmd_bash, exitcode))
    output_queue.put("%f X: %d\n" % (time.time(), exitcode))
    err_reader.stop()
    std_reader.stop()
    # get and return the output
    while not output_queue.empty():
        output += output_queue.get()
        output_queue.task_done()

    os.unlink(stf.name)

    return output, exitcode
コード例 #4
0
ファイル: launcher.py プロジェクト: gnumaniac/pulse
def launcher(start_file, params, workdir):
    """
    Function for running commands in cygwin
    """
    output_queue = Queue.Queue()
    output = ""
    stf = NamedTemporaryFile(mode="w", delete=False)
    cmd_bash = "%s %s" % (start_file, params)
    stf.write(cmd_bash)
    stf.close()

    output_queue.put("%f C: %s\n" % (time.time(), cmd_bash))
    logger.debug("Running %s" % cmd_bash)
    p = Popen(["bash", stf.name],
              bufsize=0,
              stderr=PIPE,
              stdout=PIPE,
              env=get_launcher_env(),
              cwd=workdir)

    err_reader = ReadFlux(p.stderr, output_queue, prepend="E:")
    err_reader.daemon = True
    err_reader.start()
    std_reader = ReadFlux(p.stdout, output_queue, prepend="O:")
    std_reader.daemon = True
    std_reader.start()
    # Wait for command to end
    exitcode = p.wait()
    logger.debug("Finished %s, exitcode: %d" % (cmd_bash, exitcode))
    output_queue.put("%f X: %d\n" % (time.time(), exitcode))
    err_reader.stop()
    std_reader.stop()
    # get and return the output
    while not output_queue.empty():
        output += output_queue.get()
        output_queue.task_done()

    os.unlink(stf.name)

    return output, exitcode