13 Star 27 Fork 9

staugur / Sdp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sdp 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
staugur 提交于 2016-06-23 12:08 . Libs to lib
#!/usr/bin/python -O
# coding:utf8
__doc__ = 'Sdp entry file, all the start.'
import os
import sys
from lib.Public import Sysinfo, Time, Precheck, SOA
from lib.Config import LANG, WEBS, APPS
from lib.Web import StartWeb
from lib.App import StartApp
from lib import __version__
def SdpCloudRun(**kwargs):
reload(sys)
sys.setdefaultencoding(LANG)
if not isinstance(kwargs, (dict)):
raise('Bad Parameter, ask dict.')
if kwargs['service'] in WEBS:
StartWeb(**kwargs)
elif kwargs['service'] in APPS:
StartApp(**kwargs)
if __name__ == '__main__':
user = SOA()
Precheck(**user).checkargs()
# check exec user is root?
if os.geteuid() != 0:
print "\033[0;31;40mAborting:this program must be run as root.\033[0m"
sys.exit(1)
try:
SdpCloudRun(**user)
print """\033[0;32;40mUser(%s, %s, %s) build sucessfully.
CreateTime => %s
ExpireTime => %s
Hostname => %s
Sdp Version => %s
Kernel Version => %s
CPUs => %d
Memory Free => %s
Memory Usage => %s\033[m""" % (user['name'], user['email'], user['service'], Time(), Time(user['time']), Sysinfo.Hostname, __version__.split()[1], Sysinfo.Kernel, Sysinfo.CPUs, Sysinfo.mem_free, Sysinfo.MemPerc)
except KeyboardInterrupt as e:
print "捕获到终止信号,程序非正常退出! %s" % e
sys.exit(1)
Python
1
https://gitee.com/staugur/Sdp.git
git@gitee.com:staugur/Sdp.git
staugur
Sdp
Sdp
master

搜索帮助