DiGyt commited on
Commit
d796a3a
1 Parent(s): 4f3541d

try printing subprocess output

Browse files
Files changed (1) hide show
  1. ecoset.py +15 -2
ecoset.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import csv
2
  import json
3
  import os
@@ -119,6 +120,16 @@ class Ecoset(datasets.GeneratorBasedBuilder):
119
  def abslist(path):
120
  """Helper function to give abspaths of os.listdir"""
121
  return [op.join(path, p) for p in os.listdir(path)]
 
 
 
 
 
 
 
 
 
 
122
 
123
  def s3_zipfile_download(source_url, target_dir):
124
  """Extremely slow download"""
@@ -156,9 +167,11 @@ class Ecoset(datasets.GeneratorBasedBuilder):
156
  Callback=lambda bytes_transferred: pbar.update(bytes_transferred))
157
  # unzip using platform-based subprocess
158
  if platform.system() in ("Linux", "Darwin"):
159
- subprocess.call(["unzip", "-n", "-P", password.encode("ascii"), "-o", zip_path, "-d", target_dir], shell=False)
 
160
  else:
161
- subprocess.call(["tar.exe", "-xf", zip_path, "-C", target_dir, "--passphrase", password], shell=False)
 
162
 
163
 
164
  def subprocess_download2(source_url, target_dir):
 
1
+ import sys
2
  import csv
3
  import json
4
  import os
 
120
  def abslist(path):
121
  """Helper function to give abspaths of os.listdir"""
122
  return [op.join(path, p) for p in os.listdir(path)]
123
+
124
+ def subprocess_call_print(command_list):
125
+ """Execute a subprocess while printing the command line output"""
126
+ p = subprocess.Popen(command_list, stdout=subprocess.PIPE)
127
+ while True:
128
+ line = p.stdout.readline()
129
+ if not line:
130
+ break
131
+ print(line.strip())
132
+ sys.stdout.flush()
133
 
134
  def s3_zipfile_download(source_url, target_dir):
135
  """Extremely slow download"""
 
167
  Callback=lambda bytes_transferred: pbar.update(bytes_transferred))
168
  # unzip using platform-based subprocess
169
  if platform.system() in ("Linux", "Darwin"):
170
+ #subprocess.call(["unzip", "-n", "-P", password.encode("ascii"), "-o", zip_path, "-d", target_dir], shell=False)
171
+ subprocess_call_print(["unzip", "-n", "-P", password.encode("ascii"), "-o", zip_path, "-d", target_dir])
172
  else:
173
+ #subprocess.call(["tar.exe", "-xf", zip_path, "-C", target_dir, "--passphrase", password], shell=False)
174
+ subprocess_call_print(["tar.exe", "-xf", zip_path, "-C", target_dir, "--passphrase", password])
175
 
176
 
177
  def subprocess_download2(source_url, target_dir):