Joe 9 ماه پیش
والد
کامیت
28bcd7cef4
7فایلهای تغییر یافته به همراه68 افزوده شده و 12 حذف شده
  1. 8 0
      .idea/.gitignore
  2. 6 0
      .idea/inspectionProfiles/profiles_settings.xml
  3. 7 0
      .idea/misc.xml
  4. 8 0
      .idea/modules.xml
  5. 8 0
      .idea/recommend-emr-dataprocess.iml
  6. 6 0
      .idea/vcs.xml
  7. 25 12
      qiaojialiang/demo01.py

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 6 - 0
.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 7 - 0
.idea/misc.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Black">
+    <option name="sdkName" value="Python 3.12" />
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/recommend-emr-dataprocess.iml" filepath="$PROJECT_DIR$/.idea/recommend-emr-dataprocess.iml" />
+    </modules>
+  </component>
+</project>

+ 8 - 0
.idea/recommend-emr-dataprocess.iml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>

+ 25 - 12
qiaojialiang/demo01.py

@@ -1,14 +1,27 @@
 import subprocess
+from datetime import datetime
 
-# 调用script1.sh
-result = subprocess.run(['./script1.sh'], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
-
-# 检查返回码
-if result.returncode == 0:
-    print("script1.sh 执行成功")
-    # 调用script2.sh
-    result2 = subprocess.run(['./script2.sh'], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
-    print("script2.sh 执行成功")
-else:
-    print("script1.sh 执行失败")
-    print(f"错误输出: {result.stderr}")
+# 获取当前日期,并格式化为字符串
+now = datetime.now()
+date_str = now.strftime("%Y-%m-%d")
+
+# 定义日志文件名
+log_file = f"script_output_{date_str}.log"
+
+# 定义Shell脚本的路径
+script1_path = "./script1.sh"
+script2_path = "./script1.sh"
+
+with open(log_file, 'w') as f:
+    # 调用script1.sh
+    result = subprocess.run([script1_path], shell=True, stdout=f, stderr=subprocess.STDOUT)
+
+    # 检查返回码
+    if result.returncode == 0:
+        print("script1.sh 执行成功")
+        # 调用script2.sh
+        result2 = subprocess.run([script2_path], shell=True, stdout=f, stderr=subprocess.STDOUT)
+        print("script2.sh 执行成功")
+    else:
+        print("script1.sh 执行失败")
+        print(f"错误输出: {result.stderr}")