-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathparboil
executable file
·50 lines (40 loc) · 1.38 KB
/
parboil
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
#! /usr/bin/env python
# (c) 2007 The Board of Trustees of the University of Illinois.
import sys
def checkout_dataset():
import os
if not os.path.exists("datasets"):
import urllib
print "Datasets are being downloaded and installed. It will take a few minutes."
url = "https://bitbucket.org/hwuligans/public/downloads/datasets.tar.bz2"
datafile = "datasets.tar.bz2"
urllib.urlretrieve (url, datafile)
import os
import tarfile
import zipfile
def extract_file(path, to_directory='.'):
if path.endswith('.zip'):
opener, mode = zipfile.ZipFile, 'r'
elif path.endswith('.tar.gz') or path.endswith('.tgz'):
opener, mode = tarfile.open, 'r:gz'
elif path.endswith('.tar.bz2') or path.endswith('.tbz'):
opener, mode = tarfile.open, 'r:bz2'
else:
raise ValueError, "Could not extract `%s` as no appropriate extractor is found" % path
cwd = os.getcwd()
os.chdir(to_directory)
try:
file = opener(path, mode)
try: file.extractall()
finally: file.close()
finally:
os.chdir(cwd)
extract_file(datafile)
print "Done. You may delete %s." % datafile
try:
checkout_dataset()
import driver
except ImportError:
sys.stderr.write("Cannot run driver. Are you running it from the parboil root directory?")
sys.exit(-1)
sys.exit(driver.run())