2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-28 05:07:46 +00:00
hacker-scripts/python3/hackerutils.py

24 lines
486 B
Python
Raw Normal View History

2015-11-24 00:30:08 +08:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pathlib
import subprocess
from dotenv import Dotenv
def get_dotenv(filename='.env'):
return Dotenv(str(pathlib.Path(__file__).parent / filename))
def sh(*args):
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
return stdout
def get_log_path(name):
path = pathlib.Path(__file__).parent / 'logs' / name
path.parent.mkdir(parents=True, exist_ok=True)
return path