computer-use-ootb-internal 0.0.190__py3-none-any.whl → 0.0.191__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,109 +1,109 @@
1
- import os
2
- import platform
3
- import subprocess
4
- import logging
5
- from pathlib import Path
6
- import time
7
-
8
- log = logging.getLogger(__name__)
9
-
10
- def run_preparation(state):
11
- """
12
- Performs environment preparation specific to Excel on Windows.
13
- Opens a specific template file located on the user's desktop and maximizes the window.
14
- Kills existing Excel processes first.
15
- """
16
- if platform.system() != "Windows":
17
- log.warning("Excel preparation skipped: Not running on Windows.")
18
- return
19
-
20
- log.info(f"Excel preparation: Starting on Windows platform...")
21
-
22
- try:
23
- # Determine the desktop path for Windows
24
- try:
25
- username = os.environ.get("USERNAME", "")
26
- if not username:
27
- log.error("Could not determine Windows username from environment")
28
- return
29
-
30
- log.info(f"Using Windows username: {username}")
31
- desktop_path = Path(f"C:/Users/{username}/Desktop")
32
-
33
- if not desktop_path.exists():
34
- log.error(f"Desktop path not found at: {desktop_path}")
35
- alt_path = Path(f"C:/Documents and Settings/{username}/Desktop")
36
- if alt_path.exists():
37
- desktop_path = alt_path
38
- log.info(f"Using alternative desktop path: {desktop_path}")
39
- else:
40
- log.error("Failed to find user's desktop directory")
41
- return
42
-
43
- except Exception as e:
44
- log.error(f"Error determining Windows user desktop: {e}", exc_info=True)
45
- return
46
-
47
- # Construct path to template file
48
- template_file = desktop_path / "template.xlsx" # Changed extension
49
- log.info(f"Looking for template file at: {template_file}")
50
-
51
- template_exists = template_file.exists()
52
- if not template_exists:
53
- log.warning(f"Template file not found at: {template_file}. Will attempt to launch Excel directly.")
54
-
55
- # --- Kill existing Excel processes ---
56
- log.info("Attempting to close existing Microsoft Excel processes...")
57
- try:
58
- # Command to forcefully terminate Excel processes by image name
59
- kill_cmd = ['taskkill', '/F', '/IM', 'EXCEL.EXE'] # Changed process name
60
- kill_result = subprocess.run(kill_cmd,
61
- capture_output=True, text=True, check=False)
62
-
63
- # Check taskkill result
64
- if kill_result.returncode == 0:
65
- log.info("Successfully sent termination signal to EXCEL.EXE processes.")
66
- elif "not found" in kill_result.stderr.lower() or "not found" in kill_result.stdout.lower():
67
- log.info("No running EXCEL.EXE processes found to close.")
68
- else:
69
- log.warning(f"taskkill command finished with return code {kill_result.returncode}. Output: {kill_result.stdout} Stderr: {kill_result.stderr}")
70
- time.sleep(2)
71
- except FileNotFoundError:
72
- log.error("Error: 'taskkill' command not found. Make sure it's in the system PATH.")
73
- except Exception as e:
74
- log.error(f"Error occurred while trying to close Excel: {e}", exc_info=True)
75
- # --- End of kill process ---
76
-
77
- # Open the file with Excel maximized on Windows
78
- try:
79
- # Check if template exists and construct command accordingly
80
- if template_file.exists():
81
- log.info(f"Template file found. Attempting to open {template_file} with Excel maximized...")
82
- cmd = ['cmd', '/c', 'start', '/max', 'excel', str(template_file)]
83
- else:
84
- log.info(f"Template file not found. Attempting to launch Excel maximized...")
85
- cmd = ['cmd', '/c', 'start', '/max', 'excel']
86
-
87
- log.info(f"Executing command: {' '.join(cmd)}")
88
- print(f"[DEBUG] Attempting command in excel_prepare: {' '.join(cmd)}")
89
- result = subprocess.run(cmd, check=False, capture_output=True, text=True, creationflags=subprocess.CREATE_NO_WINDOW)
90
-
91
- # ADDED PRINTS for result
92
- print(f"[DEBUG] excel_prepare command result:")
93
- print(f"[DEBUG] Return Code: {result.returncode}")
94
- print(f"[DEBUG] Stdout: {result.stdout.strip() if result.stdout else ''}")
95
- print(f"[DEBUG] Stderr: {result.stderr.strip() if result.stderr else ''}")
96
-
97
- if result.returncode == 0:
98
- log.info(f"Successfully executed command for Excel.")
99
- else:
100
- log.error(f"Error opening Excel: {result.stderr.strip()}")
101
- if result.stdout:
102
- log.error(f"Stdout from start command: {result.stdout.strip()}")
103
- except FileNotFoundError:
104
- log.error("Error: 'cmd' or 'start' command not found. Ensure system PATH is configured correctly.")
105
- except Exception as e:
106
- log.error(f"Exception opening Excel on Windows: {e}", exc_info=True)
107
-
108
- except Exception as e:
1
+ import os
2
+ import platform
3
+ import subprocess
4
+ import logging
5
+ from pathlib import Path
6
+ import time
7
+
8
+ log = logging.getLogger(__name__)
9
+
10
+ def run_preparation(state):
11
+ """
12
+ Performs environment preparation specific to Excel on Windows.
13
+ Opens a specific template file located on the user's desktop and maximizes the window.
14
+ Kills existing Excel processes first.
15
+ """
16
+ if platform.system() != "Windows":
17
+ log.warning("Excel preparation skipped: Not running on Windows.")
18
+ return
19
+
20
+ log.info(f"Excel preparation: Starting on Windows platform...")
21
+
22
+ try:
23
+ # Determine the desktop path for Windows
24
+ try:
25
+ username = os.environ.get("USERNAME", "")
26
+ if not username:
27
+ log.error("Could not determine Windows username from environment")
28
+ return
29
+
30
+ log.info(f"Using Windows username: {username}")
31
+ desktop_path = Path(f"C:/Users/{username}/Desktop")
32
+
33
+ if not desktop_path.exists():
34
+ log.error(f"Desktop path not found at: {desktop_path}")
35
+ alt_path = Path(f"C:/Documents and Settings/{username}/Desktop")
36
+ if alt_path.exists():
37
+ desktop_path = alt_path
38
+ log.info(f"Using alternative desktop path: {desktop_path}")
39
+ else:
40
+ log.error("Failed to find user's desktop directory")
41
+ return
42
+
43
+ except Exception as e:
44
+ log.error(f"Error determining Windows user desktop: {e}", exc_info=True)
45
+ return
46
+
47
+ # Construct path to template file
48
+ template_file = desktop_path / "template.xlsx" # Changed extension
49
+ log.info(f"Looking for template file at: {template_file}")
50
+
51
+ template_exists = template_file.exists()
52
+ if not template_exists:
53
+ log.warning(f"Template file not found at: {template_file}. Will attempt to launch Excel directly.")
54
+
55
+ # --- Kill existing Excel processes ---
56
+ log.info("Attempting to close existing Microsoft Excel processes...")
57
+ try:
58
+ # Command to forcefully terminate Excel processes by image name
59
+ kill_cmd = ['taskkill', '/F', '/IM', 'EXCEL.EXE'] # Changed process name
60
+ kill_result = subprocess.run(kill_cmd,
61
+ capture_output=True, text=True, check=False)
62
+
63
+ # Check taskkill result
64
+ if kill_result.returncode == 0:
65
+ log.info("Successfully sent termination signal to EXCEL.EXE processes.")
66
+ elif "not found" in kill_result.stderr.lower() or "not found" in kill_result.stdout.lower():
67
+ log.info("No running EXCEL.EXE processes found to close.")
68
+ else:
69
+ log.warning(f"taskkill command finished with return code {kill_result.returncode}. Output: {kill_result.stdout} Stderr: {kill_result.stderr}")
70
+ time.sleep(2)
71
+ except FileNotFoundError:
72
+ log.error("Error: 'taskkill' command not found. Make sure it's in the system PATH.")
73
+ except Exception as e:
74
+ log.error(f"Error occurred while trying to close Excel: {e}", exc_info=True)
75
+ # --- End of kill process ---
76
+
77
+ # Open the file with Excel maximized on Windows
78
+ try:
79
+ # Check if template exists and construct command accordingly
80
+ if template_file.exists():
81
+ log.info(f"Template file found. Attempting to open {template_file} with Excel maximized...")
82
+ cmd = ['cmd', '/c', 'start', '/max', 'excel', str(template_file)]
83
+ else:
84
+ log.info(f"Template file not found. Attempting to launch Excel maximized...")
85
+ cmd = ['cmd', '/c', 'start', '/max', 'excel']
86
+
87
+ log.info(f"Executing command: {' '.join(cmd)}")
88
+ print(f"[DEBUG] Attempting command in excel_prepare: {' '.join(cmd)}")
89
+ result = subprocess.run(cmd, check=False, capture_output=True, text=True, creationflags=subprocess.CREATE_NO_WINDOW)
90
+
91
+ # ADDED PRINTS for result
92
+ print(f"[DEBUG] excel_prepare command result:")
93
+ print(f"[DEBUG] Return Code: {result.returncode}")
94
+ print(f"[DEBUG] Stdout: {result.stdout.strip() if result.stdout else ''}")
95
+ print(f"[DEBUG] Stderr: {result.stderr.strip() if result.stderr else ''}")
96
+
97
+ if result.returncode == 0:
98
+ log.info(f"Successfully executed command for Excel.")
99
+ else:
100
+ log.error(f"Error opening Excel: {result.stderr.strip()}")
101
+ if result.stdout:
102
+ log.error(f"Stdout from start command: {result.stdout.strip()}")
103
+ except FileNotFoundError:
104
+ log.error("Error: 'cmd' or 'start' command not found. Ensure system PATH is configured correctly.")
105
+ except Exception as e:
106
+ log.error(f"Exception opening Excel on Windows: {e}", exc_info=True)
107
+
108
+ except Exception as e:
109
109
  log.error(f"An unexpected error occurred during Excel preparation: {e}", exc_info=True)
@@ -1,111 +1,111 @@
1
- import os
2
- import platform
3
- import subprocess
4
- import logging
5
- from pathlib import Path
6
- import time
7
-
8
- log = logging.getLogger(__name__)
9
-
10
- def run_preparation(state):
11
- """
12
- Performs environment preparation specific to PowerPoint on Windows.
13
- Opens a specific template file located on the user's desktop and maximizes the window.
14
- """
15
- if platform.system() != "Windows":
16
- log.warning("PowerPoint preparation skipped: Not running on Windows.")
17
- return
18
-
19
- log.info(f"PowerPoint preparation: Starting on Windows platform...")
20
-
21
- try:
22
- # Determine the desktop path for Windows
23
- try:
24
- username = os.environ.get("USERNAME", "")
25
- if not username:
26
- log.error("Could not determine Windows username from environment")
27
- return
28
-
29
- log.info(f"Using Windows username: {username}")
30
- desktop_path = Path(f"C:/Users/{username}/Desktop")
31
-
32
- if not desktop_path.exists():
33
- log.error(f"Desktop path not found at: {desktop_path}")
34
- alt_path = Path(f"C:/Documents and Settings/{username}/Desktop")
35
- if alt_path.exists():
36
- desktop_path = alt_path
37
- log.info(f"Using alternative desktop path: {desktop_path}")
38
- else:
39
- log.error("Failed to find user's desktop directory")
40
- return
41
-
42
- except Exception as e:
43
- log.error(f"Error determining Windows user desktop: {e}", exc_info=True)
44
- return
45
-
46
- # Construct path to template file
47
- template_file = desktop_path / "template.pptx"
48
- log.info(f"Looking for template file at: {template_file}")
49
-
50
- template_exists = template_file.exists()
51
- if not template_exists:
52
- log.warning(f"Template file not found at: {template_file}. Will attempt to launch PowerPoint directly.")
53
-
54
- # --- Kill existing PowerPoint processes ---
55
- log.info("Attempting to close existing Microsoft PowerPoint processes...")
56
- try:
57
- # Command to forcefully terminate PowerPoint processes by image name
58
- kill_cmd = ['taskkill', '/F', '/IM', 'POWERPNT.EXE']
59
- kill_result = subprocess.run(kill_cmd,
60
- capture_output=True, text=True, check=False)
61
-
62
- # Check taskkill result
63
- if kill_result.returncode == 0:
64
- log.info("Successfully sent termination signal to POWERPNT.EXE processes.")
65
- elif "not found" in kill_result.stderr.lower() or "not found" in kill_result.stdout.lower():
66
- log.info("No running POWERPNT.EXE processes found to close.")
67
- else:
68
- # Log potential issues if taskkill ran but didn't return 0 or expected "not found" message
69
- log.warning(f"taskkill command finished with return code {kill_result.returncode}. Output: {kill_result.stdout} Stderr: {kill_result.stderr}")
70
- # Add a small delay to allow processes to close
71
- time.sleep(2)
72
- except FileNotFoundError:
73
- log.error("Error: 'taskkill' command not found. Make sure it's in the system PATH.")
74
- except Exception as e:
75
- # Catch other potential errors during taskkill execution
76
- log.error(f"Error occurred while trying to close PowerPoint: {e}", exc_info=True)
77
- # --- End of kill process ---
78
-
79
- # Open the file with PowerPoint maximized on Windows
80
- try:
81
- # Check if template exists and construct command accordingly
82
- if template_file.exists():
83
- log.info(f"Template file found. Attempting to open {template_file} with PowerPoint maximized...")
84
- cmd = ['cmd', '/c', 'start', '/max', 'powerpnt', str(template_file)]
85
- else:
86
- log.info(f"Template file not found. Attempting to launch PowerPoint maximized...")
87
- cmd = ['cmd', '/c', 'start', '/max', 'powerpnt']
88
-
89
- log.info(f"Executing command: {' '.join(cmd)}")
90
- print(f"[DEBUG] Attempting command in powerpoint_prepare: {' '.join(cmd)}")
91
- result = subprocess.run(cmd, check=False, capture_output=True, text=True, creationflags=subprocess.CREATE_NO_WINDOW)
92
-
93
- # ADDED PRINTS for result
94
- print(f"[DEBUG] powerpoint_prepare command result:")
95
- print(f"[DEBUG] Return Code: {result.returncode}")
96
- print(f"[DEBUG] Stdout: {result.stdout.strip() if result.stdout else ''}")
97
- print(f"[DEBUG] Stderr: {result.stderr.strip() if result.stderr else ''}")
98
-
99
- if result.returncode == 0:
100
- log.info(f"Successfully executed command for PowerPoint.")
101
- else:
102
- log.error(f"Error opening PowerPoint: {result.stderr.strip()}")
103
- if result.stdout:
104
- log.error(f"Stdout from start command: {result.stdout.strip()}")
105
- except FileNotFoundError:
106
- log.error("Error: 'cmd' or 'start' command not found. Ensure system PATH is configured correctly.")
107
- except Exception as e:
108
- log.error(f"Exception opening PowerPoint on Windows: {e}", exc_info=True)
109
-
110
- except Exception as e:
1
+ import os
2
+ import platform
3
+ import subprocess
4
+ import logging
5
+ from pathlib import Path
6
+ import time
7
+
8
+ log = logging.getLogger(__name__)
9
+
10
+ def run_preparation(state):
11
+ """
12
+ Performs environment preparation specific to PowerPoint on Windows.
13
+ Opens a specific template file located on the user's desktop and maximizes the window.
14
+ """
15
+ if platform.system() != "Windows":
16
+ log.warning("PowerPoint preparation skipped: Not running on Windows.")
17
+ return
18
+
19
+ log.info(f"PowerPoint preparation: Starting on Windows platform...")
20
+
21
+ try:
22
+ # Determine the desktop path for Windows
23
+ try:
24
+ username = os.environ.get("USERNAME", "")
25
+ if not username:
26
+ log.error("Could not determine Windows username from environment")
27
+ return
28
+
29
+ log.info(f"Using Windows username: {username}")
30
+ desktop_path = Path(f"C:/Users/{username}/Desktop")
31
+
32
+ if not desktop_path.exists():
33
+ log.error(f"Desktop path not found at: {desktop_path}")
34
+ alt_path = Path(f"C:/Documents and Settings/{username}/Desktop")
35
+ if alt_path.exists():
36
+ desktop_path = alt_path
37
+ log.info(f"Using alternative desktop path: {desktop_path}")
38
+ else:
39
+ log.error("Failed to find user's desktop directory")
40
+ return
41
+
42
+ except Exception as e:
43
+ log.error(f"Error determining Windows user desktop: {e}", exc_info=True)
44
+ return
45
+
46
+ # Construct path to template file
47
+ template_file = desktop_path / "template.pptx"
48
+ log.info(f"Looking for template file at: {template_file}")
49
+
50
+ template_exists = template_file.exists()
51
+ if not template_exists:
52
+ log.warning(f"Template file not found at: {template_file}. Will attempt to launch PowerPoint directly.")
53
+
54
+ # --- Kill existing PowerPoint processes ---
55
+ log.info("Attempting to close existing Microsoft PowerPoint processes...")
56
+ try:
57
+ # Command to forcefully terminate PowerPoint processes by image name
58
+ kill_cmd = ['taskkill', '/F', '/IM', 'POWERPNT.EXE']
59
+ kill_result = subprocess.run(kill_cmd,
60
+ capture_output=True, text=True, check=False)
61
+
62
+ # Check taskkill result
63
+ if kill_result.returncode == 0:
64
+ log.info("Successfully sent termination signal to POWERPNT.EXE processes.")
65
+ elif "not found" in kill_result.stderr.lower() or "not found" in kill_result.stdout.lower():
66
+ log.info("No running POWERPNT.EXE processes found to close.")
67
+ else:
68
+ # Log potential issues if taskkill ran but didn't return 0 or expected "not found" message
69
+ log.warning(f"taskkill command finished with return code {kill_result.returncode}. Output: {kill_result.stdout} Stderr: {kill_result.stderr}")
70
+ # Add a small delay to allow processes to close
71
+ time.sleep(2)
72
+ except FileNotFoundError:
73
+ log.error("Error: 'taskkill' command not found. Make sure it's in the system PATH.")
74
+ except Exception as e:
75
+ # Catch other potential errors during taskkill execution
76
+ log.error(f"Error occurred while trying to close PowerPoint: {e}", exc_info=True)
77
+ # --- End of kill process ---
78
+
79
+ # Open the file with PowerPoint maximized on Windows
80
+ try:
81
+ # Check if template exists and construct command accordingly
82
+ if template_file.exists():
83
+ log.info(f"Template file found. Attempting to open {template_file} with PowerPoint maximized...")
84
+ cmd = ['cmd', '/c', 'start', '/max', 'powerpnt', str(template_file)]
85
+ else:
86
+ log.info(f"Template file not found. Attempting to launch PowerPoint maximized...")
87
+ cmd = ['cmd', '/c', 'start', '/max', 'powerpnt']
88
+
89
+ log.info(f"Executing command: {' '.join(cmd)}")
90
+ print(f"[DEBUG] Attempting command in powerpoint_prepare: {' '.join(cmd)}")
91
+ result = subprocess.run(cmd, check=False, capture_output=True, text=True, creationflags=subprocess.CREATE_NO_WINDOW)
92
+
93
+ # ADDED PRINTS for result
94
+ print(f"[DEBUG] powerpoint_prepare command result:")
95
+ print(f"[DEBUG] Return Code: {result.returncode}")
96
+ print(f"[DEBUG] Stdout: {result.stdout.strip() if result.stdout else ''}")
97
+ print(f"[DEBUG] Stderr: {result.stderr.strip() if result.stderr else ''}")
98
+
99
+ if result.returncode == 0:
100
+ log.info(f"Successfully executed command for PowerPoint.")
101
+ else:
102
+ log.error(f"Error opening PowerPoint: {result.stderr.strip()}")
103
+ if result.stdout:
104
+ log.error(f"Stdout from start command: {result.stdout.strip()}")
105
+ except FileNotFoundError:
106
+ log.error("Error: 'cmd' or 'start' command not found. Ensure system PATH is configured correctly.")
107
+ except Exception as e:
108
+ log.error(f"Exception opening PowerPoint on Windows: {e}", exc_info=True)
109
+
110
+ except Exception as e:
111
111
  log.error(f"An unexpected error occurred during PowerPoint preparation: {e}", exc_info=True)