【问题标题】:Need a solution to design an automated system需要解决方案来设计自动化系统
【发布时间】:2020-01-19 09:25:03
【问题描述】:

我有 5 个 exe 文件。每个 exe 文件都接受一个输入并返回一个输出,该输出将作为另一个 exe 文件的输入。用户现在手动将值传递给 exe 文件,我想通过使用其中一种编程语言来自动化这个过程。我的方法应该是什么。我应该如何为上述场景构建自动化

例如

input1 +input2 ->[ exe 1 ] ->output +input3 -> [ exe 2 ] -> output +input 4 ->
[ exe 3 ] -> output +input 5 -> [ exe 4 ] -> output -> [ exe 5 ] -> final output

【问题讨论】:

    标签: java python automation architecture software-design


    【解决方案1】:

    假设 .exes 的输出指的是控制台输出,那么我认为最简单的方法是使用 Python 的 subprocess 模块,将输入作为参数提供并控制可执行文件的输出。

    import subprocess
    
    
    def run_exe(exe_location, *args):
        arguments = " ".join(args)
        try:
            exe_output = subprocess.check_output(f"{exe_location} {arguments}")
            return exe_output
        except subprocess.CalledProcessError, e:
            print(f"There were issues encountered when running {exe_location}")
    
    

    因此,您可以编排运行不同可执行文件并捕获其输出的不同可能性,以按照您的示例中描述的方式用作其他可执行文件的输入。

    first_output = run_exe(first_exe_location, initial_input)
    
    second_output = run_exe(second_exe_location, first_output, additional_input)
    

    并且可以根据所需的流程继续或修改循环。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-09
      • 2016-03-31
      • 1970-01-01
      • 1970-01-01
      • 2023-01-26
      • 2014-02-21
      相关资源
      最近更新 更多