forked from taiojia/get-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-modules.py
42 lines (27 loc) · 1.01 KB
/
install-modules.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
__author__ = 'Taio'
import os
from utils.noflib import Noflib
import logging
logger = logging.getLogger('install-modules')
logging.basicConfig(filename='/var/log/get-dns/install-modules.log', level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
run = Noflib()
def get_modules():
'''get modules from github'''
run.execute_get_output('git', 'clone', 'https://github.com/rthalley/dnspython.git')
def install_modules():
'''install dnspython to package-sites'''
run.execute_get_output('python', 'dnspython/setup.py', 'install')
def main():
if not os.path.exists('/var/log/get-dns'):
logger.info('Making directory /var/log/get-dns')
run.execute_get_output('sudo', 'mkdir', '/var/log/get-dns')
logger.info('Getting modules')
get_modules()
logger.info('Installing modules')
install_modules()
if __name__ == '__main__':
if os.getuid() == 0:
main()
else:
print 'You do not have permission, please run as root.'
exit()