BBrother commited on
Commit
d59e240
·
1 Parent(s): 6277d0e

Update SW_run.py

Browse files
Files changed (1) hide show
  1. SW_run.py +7 -5
SW_run.py CHANGED
@@ -27,11 +27,14 @@ logging.getLogger().addHandler(console_handler)
27
  sys.stdout = logging.getLogger().handlers[0].stream
28
  sys.stderr = logging.getLogger().handlers[0].stream
29
 
 
 
 
30
  try:
31
- # 直接运行 launch.py 文件,并将输出重定向到日志文件
32
  with open(log_file, 'a') as log_file_handle:
33
- process = subprocess.Popen(['python', '/bushu/ui/launch.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, bufsize=1)
34
- for line in iter(process.stdout.readline, ''):
35
  if "Running on" in line:
36
  # 如果日志行包含 "Running on",将它写入 url.txt 文件
37
  with open(url_file, 'a') as url_file_handle:
@@ -40,7 +43,6 @@ try:
40
  # 否则,将日志行写入 logs_run.txt 文件
41
  log_file_handle.write(line)
42
  log_file_handle.flush()
43
- process.stdout.close()
44
  process.wait()
45
  except subprocess.CalledProcessError as e:
46
  # 捕获异常并记录到日志文件
@@ -51,4 +53,4 @@ except Exception as e:
51
  finally:
52
  # 最后,关闭日志处理程序,以确保所有日志都被写入到日志文件
53
  logging.getLogger().removeHandler(console_handler)
54
- console_handler.close()
 
27
  sys.stdout = logging.getLogger().handlers[0].stream
28
  sys.stderr = logging.getLogger().handlers[0].stream
29
 
30
+ # 切换到/bushu/ui目录
31
+ subprocess.run(["cd", "/bushu/ui"], shell=True)
32
+
33
  try:
34
+ # 在try块中运行v2_3.py,并将输出重定向到日志文件
35
  with open(log_file, 'a') as log_file_handle:
36
+ process = subprocess.Popen(['python', 'launch.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
37
+ for line in process.stdout:
38
  if "Running on" in line:
39
  # 如果日志行包含 "Running on",将它写入 url.txt 文件
40
  with open(url_file, 'a') as url_file_handle:
 
43
  # 否则,将日志行写入 logs_run.txt 文件
44
  log_file_handle.write(line)
45
  log_file_handle.flush()
 
46
  process.wait()
47
  except subprocess.CalledProcessError as e:
48
  # 捕获异常并记录到日志文件
 
53
  finally:
54
  # 最后,关闭日志处理程序,以确保所有日志都被写入到日志文件
55
  logging.getLogger().removeHandler(console_handler)
56
+ console_handler.close()