Last active
December 25, 2015 05:59
-
-
Save kaka19ace/6928907 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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