-
Notifications
You must be signed in to change notification settings - Fork 0
/
call_server.py
46 lines (36 loc) · 1.35 KB
/
call_server.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
#!/usr/bin python
# -*- coding: UTF-8 -*-
import os
import sys
import logging
from xmlrpclib import ServerProxy
def call_to_process_pkgs(pkg_names_str_zip):
"""调用远程方法处理新生成的升级包
"""
try:
server = ServerProxy("http://192.168.25.20:8089")
result = server.deal_with_upgpkgs(pkg_names_str_zip)
if not result:
return False
except:
return False
return True
if __name__ == '__main__':
current_dir = os.path.abspath(os.path.dirname(__file__))
log_file = os.path.join(current_dir, 'call_server.log')
logging.basicConfig(filename = log_file, level = logging.DEBUG,
format = '%(asctime)s - %(levelname)s - %(name)s - %(message)s')
logger = logging.getLogger('call_server')
if len(sys.argv) == 2:
pkg_names_str_zip = sys.argv[1]
result = call_to_process_pkgs(pkg_names_str_zip)
if result:
logger.info('Status: success; Content: {0}.'.format(pkg_names_str_zip))
sys.exit(0)
else:
logger.error('Status: failed; Content: {0}.'.format(pkg_names_str_zip))
sys.exit(1)
else:
print 'Usage: {0} pkg_names_split_with_commas.'.format(sys.argv[0])
logger.error('Status: error; Usage: {0} pkg_names_split_with_commas.'.format(sys.argv[0]))
sys.exit(2)