Skip to main content

pyhacks

Python module to ease writing scripts go over big amount of data in order to perform the same actions. A simple preconfigured threads and queue management and more hacking utils

Will elaborate more when it will get mature enough :)

capabilities

PyHacks

Using all below capabilities to easily manage threads and queue to perform operations on Item objects.

from pyhacks import PyHacks, Net

if __name__ == "__main__":
	net = Net()
	
	def handle_item(item):
		host = item.get("host")
		url = item.get("url")
		replied_to_ping = net.reply_to_ping(host)
		ip = net.resolve(host)
		if ip == None:
			return False
		item.set("Reply To Ping", replied_to_ping)
		item.set("ip", ip)
		hacks.logger.green("{} {} {}".format(host, replied_to_ping, ip))
		hacks.exporter.put(item)
		return True
	
	hacks = PyHacks(handle_item, 25, "output.csv")
	hosts = hacks.parse.csv("ips.csv")
	
	for host in hosts:
		hacks.qt.put(host)
	
	hacks.finish()

    
QueueThreads

QueueThreads class allows you to manage queue and threads easily.

qt = QueueThreads(handle_function, num_worker_threads, logger)
qt.put({"counter":1, "key1":"value1"})
qt.finish() # waiting until job is finished
parameters

handle_function - a function recevies item parameter from queue, will be used in all threads defined, return value has to be bool

def handle_item(item):
		host = item.get("host")
		url = item.get("url")
		replied_to_ping = net.reply_to_ping(host)
		ip = net.resolve(host)
		if ip == None:
			return False
		item.set("Reply To Ping", replied_to_ping)
		item.set("ip", ip)
		hacks.logger.green("{} {} {}".format(host, replied_to_ping, ip))
		hacks.exporter.put(item)
		return True

num_worker_threads - numbers of threads used to run handle_functions on queue items logger - a Logger instance to be used for automatic logging

Parser

Parse files and returns list of Item objects

parse = Parser()
items = parse.csv("ips.csv")
for item in items:
	qt.put(item)
Logger

Easy logging mechanism + writing into files under logs directory, used by QueueThreads for autoamtic logging

logger = Logger(verbose=False)
logger.green("text")
logger.red("text")
logger.yellow("text")
Exporter

Exporting Item objects into a csv/txt file

export = Exporter(output.csv)
export.put({"counter":1,"key1":"value"})
export.finish()

Release files for pyhacks 1.0.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyhacks 1.0.20
File Size Uploaded
pyhacks-1.0.20.tar.gz 8.1 kB Details

Release files / pyhacks-1.0.20.tar.gz

Download URL pyhacks-1.0.20.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d9e645c62c2a2054b347d3bf14a48cd2b5001a608330b41702e13a69efab2a8a
BLAKE2b-256 checksum
How to use checksums
9c24842df84f1b082d710cff146baa87fd1c3b174050e6b100180a36da05afe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.0.20 This release

1 release file

1.0.19

1 release file

1.0.18

2 release files

1.0.17

1 release file

1.0.16

1 release file

1.0.15

1 release file

1.0.14

1 release file

1.0.13

1 release file

1.0.12

1 release file

1.0.11

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page