-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverd.py
45 lines (38 loc) · 1.36 KB
/
serverd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
import sys,os
import glob
import ConfigParser
from distutils.util import get_platform
pyver = "py"+sys.version[:3]
platform = get_platform()
eggs = ['zope.interface','Twisted','setuptools','PyYAML','Mako','MarkupSafe']
dpHome = os.path.dirname(os.path.realpath(__file__))
sysPath = [dpHome]
config = ConfigParser.ConfigParser()
def autoCheckEggs():
global eggs
dpEggPath = os.path.join(dpHome,'eggs','')#sys.path[0]
dpEggs = [glob.glob("%s%s-*%s*egg"%(dpEggPath,name,pyver)) for name in eggs]
for eggs in dpEggs:
bestEgg = None
for egg in eggs:
basename = os.path.basename(egg)
spLen = len(basename.split("-"))
if spLen==3 or (spLen>4 and basename.find(platform)>0):
bestEgg = egg
if bestEgg :
sysPath.append(bestEgg)
autoCheckEggs()
sys.path[0:0] = sysPath
if __name__ == '__main__':
import twisted.scripts.twistd
config.read(os.path.join(dpHome,'conf','serverd.cfg'))
loginfo = []
if platform.find('win') == -1:
logdir = os.path.join(dpHome,'data','log')
if not os.path.exists(logdir):
os.makedirs(logdir)
loginfo = ['-l','data/log/serverd.log','--pidfile','data/log/serverd.pid']
sys.argv = sys.argv[:1]+loginfo+['dpserver','-m',config.get('basic','mainPort'),\
'-f',config.getint('basic','ftpPort'),'-h',config.getint('basic','httpPort')]
twisted.scripts.twistd.run()