MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / clear_files

Method clear_files

utils.py:527–549  ·  view source on GitHub ↗
(self, handler)

Source from the content-addressed store, hash-verified

525 handler.wfile.write(json.dumps({"status": "error", "message": str(e)}).encode('utf-8'))
526
527 def clear_files(self, handler):
528 try:
529 command = """
530 sudo rm -rf config/*.json && sudo rm -rf data/*.csv && sudo rm -rf data/*.log && sudo rm -rf backup/backups/* && sudo rm -rf backup/uploads/* && sudo rm -rf data/output/data_stolen/* && sudo rm -rf data/output/crackedpwd/* && sudo rm -rf config/* && sudo rm -rf data/output/scan_results/* && sudo rm -rf __pycache__ && sudo rm -rf config/__pycache__ && sudo rm -rf data/__pycache__ && sudo rm -rf actions/__pycache__ && sudo rm -rf resources/__pycache__ && sudo rm -rf web/__pycache__ && sudo rm -rf *.log && sudo rm -rf resources/waveshare_epd/__pycache__ && sudo rm -rf data/logs/* && sudo rm -rf data/output/vulnerabilities/* && sudo rm -rf data/logs/*
531 """
532 result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
533 stdout, stderr = result.communicate()
534
535 if result.returncode == 0:
536 handler.send_response(200)
537 handler.send_header("Content-type", "application/json")
538 handler.end_headers()
539 handler.wfile.write(json.dumps({"status": "success", "message": "Files cleared successfully"}).encode('utf-8'))
540 else:
541 handler.send_response(500)
542 handler.send_header("Content-type", "application/json")
543 handler.end_headers()
544 handler.wfile.write(json.dumps({"status": "error", "message": stderr}).encode('utf-8'))
545 except Exception as e:
546 handler.send_response(500)
547 handler.send_header("Content-type", "application/json")
548 handler.end_headers()
549 handler.wfile.write(json.dumps({"status": "error", "message": str(e)}).encode('utf-8'))
550
551 def clear_files_light(self, handler):
552 try:

Callers

nothing calls this directly

Calls 2

writeMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected