{"id":22883633,"url":"https://github.com/deadbits/py-potential","last_synced_at":"2025-03-31T16:54:09.828Z","repository":{"id":144910306,"uuid":"69130086","full_name":"deadbits/py-potential","owner":"deadbits","description":"Libraries for code I use often and got tired of rewriting in every application","archived":false,"fork":false,"pushed_at":"2018-03-03T14:43:26.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T22:15:57.642Z","etag":null,"topics":["file-handling","python-library","python-threading","system-administration","useful-functions"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deadbits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-24T22:07:08.000Z","updated_at":"2018-03-03T14:42:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"6326db59-6741-49fc-808f-42d081ad3d04","html_url":"https://github.com/deadbits/py-potential","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadbits%2Fpy-potential","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadbits%2Fpy-potential/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadbits%2Fpy-potential/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadbits%2Fpy-potential/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deadbits","download_url":"https://codeload.github.com/deadbits/py-potential/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246500689,"owners_count":20787739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file-handling","python-library","python-threading","system-administration","useful-functions"],"created_at":"2024-12-13T18:39:28.640Z","updated_at":"2025-03-31T16:54:09.796Z","avatar_url":"https://github.com/deadbits.png","language":"Python","readme":"# Potentially Useful Python Functions\n`potent.py` is meant to be a single library that contain many Python functions I would end up using on a regular basis and across multiple projects. There were so many times that I would re-write the same functions every {day|week|month}, I figured this might be a better solution: do it once, import, repeat.\n\nThere are multiple classes within potent.py and each function of within the classes are static methods so they aim to be more easily accessible. The classes are purely organizational.\n\nThis is obviously by no means meant to be all-inclusive and is more tailored towards use-cases I've encountered during my personal and professional projects, but this repo is glad to accept Pull Requests and Issues :D\n\n***\n\nTake a quick look at the following example that checks if a certain process is running and kill any of it's child processes using the built-in threading support:\n\n```\nfrom potent import System\nfrom potent import threaded\n\n@threaded\ndef kill_child_procs(process_id):    \n    System.kill_process(process_id)\n\ndef my_func(arg):    \n    if System.is_running(args):        \n        children = System.get_children(arg)        \n        results = []        \n        for proc in children:            \n            results.append(kill_child_procs(proc))        \n            print results\n```  \n\n### Batteries Included\n- threading decorator\n- System class    \n    - check if PID is running    \n    - check if PID has threads and return them    \n    - check if PID has children and return them      \n    - kill those children    \n    - safely execute a system command        \n        - maybe wrap this the threading decorator, eh? ;-)    \n    - get random n bytes from /dev/urandom    \n    - get random n bytes from /dev/random\n- Validate class    \n     - verify string is acceptable for filenames and HTML display    \n     - verify URL    \n     - verify IPv4 address\n     - validate Yara rule syntax **not yet implemented**\n- Time   \n    - UTC timestamp as string    \n    - UTC timestamp as object    \n    - get duration of a thing you run **not yet implemented**\n- Encode    \n    - XOR        \n        - single byte        \n        - four byte        \n        - rolling    \n    - RC4 encrypt \u0026 decrypt    \n    - base64 encode    \n    - base64 decode    \n    - get digest of HMA SHA256 from data and key  **not yet implemented**\n    - base64 encode and zlib compress data    **not yet implemented**\n    - base64 decode and zlib decompress data    **not yet implemented**\n    - convert hex to integer    **not yet implemented**\n    - convert integer to hex **not yet implemented**\n- Files    \n    - get entropy of file or buffer    \n    - check if file is valid (path exists, is not a directory, and size is greater than 0)    \n    - write data to a file    \n    - read data from a file        \n        - optionally split data lines and return as list    \n    - get size of file    \n    - get basename of file path    \n    - get Magic MIME type from file path or buffer    \n    - run Yara {directory|file} signature against {file|buffer}  **not yet implemented**\n    - create temporary directory   **not yet implemented** \n    - create temporary file    **not yet implemented**\n    - write a JSON object or instance of object to file as dictionary **not yet implemented**\n- Network  **not yet implemented**\n    - make DNS request and get all response data  \n    - open a listening TCP socket on port {whatever}  \n    - connect to a listening TCP socket  \n    - initialize a SOCKS5 proxy to a {host:port} of your choosing  - execute a command on a remote SSH server\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadbits%2Fpy-potential","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeadbits%2Fpy-potential","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadbits%2Fpy-potential/lists"}