forked from fumail/monsta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
57 lines (48 loc) · 1.66 KB
/
setup.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
46
47
48
49
50
51
52
53
54
55
56
from distutils.core import setup
import glob
import sys
import os
sys.path.insert(0,'src')
#store old content of version file here
#if we have git available, temporarily overwrite the file
#so we can report the git commit id in fuglu --version
OLD_VERSFILE_CONTENT=None
VERSFILE='src/monsta/__init__.py'
def git_version():
from monsta import MONSTA_VERSION
global VERSFILE,OLD_VERSFILE_CONTENT
try:
import subprocess
x=subprocess.Popen(['git','describe'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
ret=x.wait()
if ret==0:
stdout,stderr=x.communicate()
vers=stdout.strip()
#replace fuglu version in file
if os.path.isfile(VERSFILE):
OLD_VERSFILE_CONTENT=open(VERSFILE,'r').read()
buff=OLD_VERSFILE_CONTENT.replace(MONSTA_VERSION,vers)
open(VERSFILE,'w').write(buff)
return vers
else:
return MONSTA_VERSION
except Exception,e:
return MONSTA_VERSION
setup(name = "monsta",
version = git_version(),
description = "Monsta Monitoring Daemon",
url = "https://github.com/gryphius/monsta",
author = "O. Schacher",
author_email = "[email protected]",
package_dir={'':'src'},
packages = ['monsta','monsta.check','monsta.notification'],
scripts = ["scripts/main/monsta"],
long_description = """Monsta Monitoring Daemon""" ,
data_files=[
('/etc/monsta',glob.glob('conf/*.dist')),
# ('/etc/init.d',['scripts/init.d-centos/monsta']),
]
)
#cleanup
if OLD_VERSFILE_CONTENT!=None:
open(VERSFILE,'w').write(OLD_VERSFILE_CONTENT)