2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-31 22:55:12 +00:00

Add Python 3 implementation

This commit is contained in:
Tzu-ping Chung
2015-11-24 00:30:08 +08:00
parent 8260c7dca5
commit 11a67dfaac
6 changed files with 223 additions and 0 deletions

23
python3/hackerutils.py Normal file
View File

@@ -0,0 +1,23 @@
#!/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