1+ #!/usr/bin/env python3
2+ """Quick environment check for Java processes without psutil dependency."""
3+
4+ import subprocess
5+ import os
6+ import sys
7+
8+ def check_java_processes ():
9+ """Check for Java processes using ps command."""
10+ print ("CDM Ontologies Java Process Environment Check" )
11+ print ("=" * 60 )
12+
13+ # Check current user
14+ print (f"Current user: { os .environ .get ('USER' , 'unknown' )} " )
15+ print (f"Python version: { sys .version } " )
16+ print (f"Platform: { sys .platform } " )
17+
18+ # Check if we're in Docker
19+ if os .path .exists ('/.dockerenv' ):
20+ print ("Running in Docker container: YES" )
21+ else :
22+ print ("Running in Docker container: NO" )
23+
24+ print ("\n " + "-" * 60 )
25+ print ("Checking for Java processes using 'ps'..." )
26+ print ("-" * 60 )
27+
28+ try :
29+ # Try different ps commands
30+ commands = [
31+ ("ps aux | grep -i java | grep -v grep" , "Standard ps aux" ),
32+ ("ps -ef | grep -i java | grep -v grep" , "System V style ps" ),
33+ ("pgrep -la java" , "pgrep for java processes" ),
34+ ]
35+
36+ found_any = False
37+ for cmd , desc in commands :
38+ print (f"\n { desc } ({ cmd } ):" )
39+ try :
40+ result = subprocess .run (cmd , shell = True , capture_output = True , text = True )
41+ if result .stdout .strip ():
42+ print (result .stdout )
43+ found_any = True
44+ else :
45+ print (" No Java processes found with this command" )
46+ except Exception as e :
47+ print (f" Error: { e } " )
48+
49+ if not found_any :
50+ print ("\n ⚠️ No Java processes found. This is normal if no Java tools are running." )
51+ print ("\n To test with a Java process, you could:" )
52+ print ("1. Start the CDM pipeline in another terminal" )
53+ print ("2. Or run a simple Java command like: java -version" )
54+
55+ except Exception as e :
56+ print (f"Error checking processes: { e } " )
57+
58+ # Check Java installation
59+ print ("\n " + "-" * 60 )
60+ print ("Checking Java installation..." )
61+ print ("-" * 60 )
62+
63+ try :
64+ result = subprocess .run (['java' , '-version' ], capture_output = True , text = True )
65+ print ("Java is installed:" )
66+ print (result .stderr if result .stderr else result .stdout )
67+ except FileNotFoundError :
68+ print ("❌ Java not found in PATH" )
69+
70+ # Check for psutil
71+ print ("\n " + "-" * 60 )
72+ print ("Checking Python package requirements..." )
73+ print ("-" * 60 )
74+
75+ try :
76+ import psutil
77+ print ("✅ psutil is installed (version: {})" .format (psutil .__version__ ))
78+ except ImportError :
79+ print ("❌ psutil is NOT installed" )
80+ print ("\n To install psutil, run one of:" )
81+ print (" pip install psutil" )
82+ print (" pip3 install psutil" )
83+ print (" python -m pip install psutil" )
84+ print (" conda install psutil (if using conda)" )
85+
86+ # Check if we're in a virtual environment
87+ if hasattr (sys , 'real_prefix' ) or (hasattr (sys , 'base_prefix' ) and sys .base_prefix != sys .prefix ):
88+ print ("\n ⚠️ You appear to be in a virtual environment." )
89+ print ("Make sure to install psutil in this environment." )
90+
91+ if __name__ == "__main__" :
92+ check_java_processes ()
0 commit comments