-
Notifications
You must be signed in to change notification settings - Fork 23
/
util.py
36 lines (31 loc) · 1.07 KB
/
util.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# FileName : util.py
# Author : Feather.et.ELF <[email protected]>
# Created : Thu Jun 14 20:23:14 2012 by Feather.et.ELF
# Copyright : Feather Workshop (c) 2012
# Description : description
# Time-stamp: <2012-06-14 20:54:34 andelf>
import getpass
import re
def getpass_or_quit(msg):
try:
value = getpass.getpass(msg)
except KeyboardInterrupt:
print 'Interrupt!'
sys.exit(1)
return value.strip()
def extract_deploy_id(url):
return extract_ci_id(url) or extract_noah_id(url)
def extract_ci_id(url):
matches = re.findall(r'http://.*?noah\.baidu\.com/ci-web/index.php\?r=ProcessView/QueryTask&listid=(\d+)', url)
if matches:
return int(matches[0])
else:
return 0 # or to return False?
def extract_noah_id(url):
matches = re.findall(r'http://.*?noah\.baidu\.com.*?ViewDeployProcess.*?id=(\d+)', url)
if matches:
return int(matches[0])
else:
return 0 # or to return False?