forked from QuantFans/quantdigger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.py
31 lines (27 loc) · 738 Bytes
/
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
def download(url,target):
import sys
if sys.version_info.major >= 3:
import urllib.request,re,sys
data = urllib.request.urlopen(url).read()
else:
import urllib2
data = urllib2.urlopen(url).read()
with open(target,"wb") as code:
code.write(data)
def decompress(target,dist):
import tarfile
tar = tarfile.open(target)
names = tar.getnames()
for name in names:
tar.extract(name,dist)
#tar.extractall()
tar.close()
def decompressZip(target,dist):
import zipfile
f= zipfile.ZipFile(target,'r')
for file in f.namelist():
f.extract(file,dist)
f.close()
def printCommandResult(result):
for line in result:
print(line)