This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #/usr/bin/env python3 | |
| """ | |
| LogScan - by David Daniel ([email protected]) | |
| =================================================== | |
| Usage | |
| ----- | |
| usage: logscan.py [-h] [--end_time end_time] [--start_time start_time] | |
| directory [directory ...] date pattern |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import django.http | |
| def convert_curl_to_httprequest(curl_statement): | |
| import re | |
| # Split by spaces | |
| curl_parts = curl_statement.split(' ') | |
| # Get method | |
| method = curl_parts[1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| import json | |
| # Get a list of all nodes in the Docker swarm | |
| result = subprocess.run(["docker", "node", "ls", "--format", "{{json .}}"], stdout=subprocess.PIPE, text=True) | |
| nodes = json.loads("[" + result.stdout.strip().replace("}\n{", "},\n{") + "]") | |
| # Iterate over the nodes and print their hostname and IP address | |
| for node in nodes: | |
| print("Node:", node['Hostname']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| def print_logging_params(logging_dict): | |
| # Print handlers | |
| if 'handlers' in logging_dict: | |
| print('* Handlers:') | |
| for name, handler in logging_dict['handlers'].items(): | |
| print(f" * {name.capitalize()} '{name}'") | |
| if 'class' in handler: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| from django.test import RequestFactory | |
| from django.http import QueryDict | |
| def generate_http_request(url, user, method='GET', query_params=None, data=None, headers=None, request_attrs=None): | |
| """ | |
| Generate an HTTP request for a given URL and user. | |
| Args: | |
| url (str): The URL for the request. |
OlderNewer