107 lines
3.8 KiB
Python
107 lines
3.8 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
def main():
|
|
print("=== Python Investigation Script ===")
|
|
|
|
# Change to /home/bam directory
|
|
os.chdir('/home/bam')
|
|
print(f"Current working directory: {os.getcwd()}")
|
|
|
|
# List directory contents
|
|
print("\n=== Directory Contents ===")
|
|
try:
|
|
contents = os.listdir('.')
|
|
if contents:
|
|
for item in contents:
|
|
item_path = os.path.join('.', item)
|
|
if os.path.isdir(item_path):
|
|
print(f" [DIR] {item}")
|
|
else:
|
|
print(f" [FILE] {item}")
|
|
else:
|
|
print(" Directory is empty")
|
|
except Exception as e:
|
|
print(f"Error listing directory: {e}")
|
|
|
|
# Check for git repository
|
|
print("\n=== Git Repository Check ===")
|
|
try:
|
|
result = subprocess.run(['git', 'rev-parse', '--git-dir'],
|
|
cwd='/home/bam', capture_output=True, text=True)
|
|
if result.returncode == 0:
|
|
print("Git repository detected")
|
|
print(f"Git dir: {result.stdout.strip()}")
|
|
|
|
# Get current branch
|
|
branch_result = subprocess.run(['git', 'branch', '--show-current'],
|
|
capture_output=True, text=True)
|
|
print(f"Current branch: {branch_result.stdout.strip() if branch_result.stdout.strip() else 'No current branch'}")
|
|
|
|
# Get all branches
|
|
branches_result = subprocess.run(['git', 'branch', '-a'],
|
|
capture_output=True, text=True)
|
|
print("Available branches:")
|
|
print(branches_result.stdout)
|
|
|
|
# Check last commits
|
|
log_result = subprocess.run(['git', 'log', '--oneline', '-3'],
|
|
capture_output=True, text=True)
|
|
if log_result.stdout.strip():
|
|
print("Recent commits:")
|
|
print(log_result.stdout)
|
|
else:
|
|
print("No commits found in repository")
|
|
|
|
else:
|
|
print("No git repository found")
|
|
except Exception as e:
|
|
print(f"Error checking git: {e}")
|
|
|
|
# Look for project files
|
|
print("\n=== Project Files ===")
|
|
project_files = [
|
|
'package.json', 'requirements.txt', 'setup.py', 'pyproject.toml',
|
|
'Makefile', 'Dockerfile', 'pom.xml', 'build.gradle', 'Cargo.toml',
|
|
'README.md', 'README.txt', '.gitignore', 'Pipfile', 'poetry.lock',
|
|
'yarn.lock', 'package-lock.json'
|
|
]
|
|
|
|
found_files = []
|
|
for file in project_files:
|
|
if os.path.exists(file):
|
|
found_files.append(file)
|
|
|
|
if found_files:
|
|
print("Found project files:")
|
|
for file in found_files:
|
|
print(f" - {file}")
|
|
else:
|
|
print("No common project files found")
|
|
|
|
# Check system environment
|
|
print("\n=== System Environment ===")
|
|
try:
|
|
python_version = subprocess.run(['python3', '--version'],
|
|
capture_output=True, text=True)
|
|
print(f"Python: {python_version.stdout.strip()}")
|
|
|
|
node_version = subprocess.run(['node', '--version'],
|
|
capture_output=True, text=True)
|
|
print(f"Node.js: {node_version.stdout.strip()}")
|
|
|
|
git_version = subprocess.run(['git', '--version'],
|
|
capture_output=True, text=True)
|
|
print(f"Git: {git_version.stdout.strip()}")
|
|
|
|
docker_version = subprocess.run(['docker', '--version'],
|
|
capture_output=True, text=True)
|
|
print(f"Docker: {docker_version.stdout.strip()}")
|
|
|
|
except Exception as e:
|
|
print(f"Error checking system versions: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
main() |