Skip to content

Instantly share code, notes, and snippets.

@kaka19ace
Last active December 25, 2015 05:59
Show Gist options
  • Save kaka19ace/6928907 to your computer and use it in GitHub Desktop.
Save kaka19ace/6928907 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# 设置 uid gid
kakaGID = grp.getgrnam('kaka')[2]
os.setgid(kakaGID)
kakaUID = pwd.getpwnam('kaka')[2]
os.setuid(kakaUID)
# geit root dir py
ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)))
# 获得字符串名(模块名字)
modulename = "kaka"
root_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, root_dir)
config = __import__(modulename)
# 判断合法ip
import socket
addr = "127.0.0.1"
try:
socket.inet_aton(addr)
# legal
except socket.error:
# Not legal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment