Skip to content

Commit

Permalink
Ignoring tgz - thanks @antgonza
Browse files Browse the repository at this point in the history
  • Loading branch information
josenavas committed Mar 24, 2017
1 parent e90ad50 commit 587e5bf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
10 changes: 6 additions & 4 deletions qiita_pet/handlers/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from .base_handlers import BaseHandler
from qiita_pet.handlers.api_proxy import study_get_req
from qiita_db.study import Study
from qiita_db.util import (filepath_id_to_rel_path, get_db_files_base_dir,
compute_checksum)
from qiita_db.util import filepath_id_to_rel_path, get_db_files_base_dir
from qiita_db.meta_util import validate_filepath_access_by_user
from qiita_core.util import execute_as_transaction

Expand Down Expand Up @@ -73,6 +72,10 @@ def get(self, study_id):
if (i == 0 and not vfabu(user, fid)):
to_add = False
break
# ignore if tgz as they could create problems and the
# raw data is in the folder
if data_type == 'tgz':
continue
if data_type == 'directory':
# If we have a directory, we actually need to list
# all the files from the directory so NGINX can
Expand Down Expand Up @@ -106,8 +109,7 @@ def get(self, study_id):
% a.id))

# If we don't have nginx, write a file that indicates this
all_files = '\n'.join(["%s %s /protected/%s %s"
% (compute_checksum(fp), getsize(fp), sfp, n)
all_files = '\n'.join(["- %s /protected/%s %s" % (getsize(fp), sfp, n)
for fp, sfp, n in to_download])
self.write("%s\n" % all_files)

Expand Down
31 changes: 17 additions & 14 deletions qiita_pet/test/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ def test_download_study(self):
biom_fp = join(tmp_dir, 'otu_table.biom')
smr_dir = join(tmp_dir, 'sortmerna_picked_otus')
log_dir = join(smr_dir, 'seqs_otus.log')
tgz = join(tmp_dir, 'sortmerna_picked_otus.tgz')

with biom_open(biom_fp, 'w') as f:
et.to_hdf5(f, "test")
makedirs(smr_dir)
with open(log_dir, 'w') as f:
f.write('\n')
with open(tgz, 'w') as f:
f.write('\n')

self._clean_up_files.append(tmp_dir)

files_biom = [(biom_fp, 'biom'), (smr_dir, 'directory')]
files_biom = [(biom_fp, 'biom'), (smr_dir, 'directory'), (tgz, 'tgz')]

params = Parameters.from_default_params(
Command(3).default_parameter_sets.next(), {'input_data': 1})
Expand All @@ -88,28 +91,28 @@ def test_download_study(self):
response = self.get('/download_study_bioms/1')
self.assertEqual(response.code, 200)
exp = (
'[0-9]* 1256812 /protected/processed_data/1_study_1001_closed_'
'- 1256812 /protected/processed_data/1_study_1001_closed_'
'reference_otu_table.biom processed_data/1_study_1001_closed_'
'reference_otu_table.biom\n'
'[0-9]* 36615 /protected/templates/1_prep_1_qiime_[0-9]*-'
'- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-'
'[0-9]*.txt mapping_files/4_mapping_file.txt\n'
'[0-9]* 1256812 /protected/processed_data/'
'- 1256812 /protected/processed_data/'
'1_study_1001_closed_reference_otu_table.biom processed_data/'
'1_study_1001_closed_reference_otu_table.biom\n'
'[0-9]* 36615 /protected/templates/1_prep_1_qiime_[0-9]*-'
'- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-'
'[0-9]*.txt mapping_files/5_mapping_file.txt\n'
'[0-9]* 1256812 /protected/processed_data/'
'- 1256812 /protected/processed_data/'
'1_study_1001_closed_reference_otu_table_Silva.biom processed_data'
'/1_study_1001_closed_reference_otu_table_Silva.biom\n'
'[0-9]* 36615 /protected/templates/1_prep_1_qiime_[0-9]*-'
'- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-'
'[0-9]*.txt mapping_files/6_mapping_file.txt\n'
'[0-9]* 36615 /protected/templates/1_prep_2_qiime_[0-9]*-'
'- 36615 /protected/templates/1_prep_2_qiime_[0-9]*-'
'[0-9]*.txt mapping_files/7_mapping_file.txt\n'
'[0-9]* 39752 /protected/BIOM/{0}/otu_table.biom '
'- 39752 /protected/BIOM/{0}/otu_table.biom '
'BIOM/{0}/otu_table.biom\n'
'[0-9]* 1 /protected/BIOM/{0}/sortmerna_picked_otus/seqs_otus.log '
'- 1 /protected/BIOM/{0}/sortmerna_picked_otus/seqs_otus.log '
'BIOM/{0}/sortmerna_picked_otus/seqs_otus.log\n'
'[0-9]* 36615 /protected/templates/1_prep_1_qiime_[0-9]*-[0-9]*.'
'- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-[0-9]*.'
'txt mapping_files/{0}_mapping_file.txt\n'.format(a.id))
self.assertRegexpMatches(response.body, exp)

Expand All @@ -126,11 +129,11 @@ def test_download_study(self):
response = self.get('/download_study_bioms/1')
self.assertEqual(response.code, 200)
exp = (
'[0-9]* 39752 /protected/BIOM/{0}/otu_table.biom '
'- 39752 /protected/BIOM/{0}/otu_table.biom '
'BIOM/{0}/otu_table.biom\n'
'[0-9]* 1 /protected/BIOM/{0}/sortmerna_picked_otus/seqs_otus.log '
'- 1 /protected/BIOM/{0}/sortmerna_picked_otus/seqs_otus.log '
'BIOM/{0}/sortmerna_picked_otus/seqs_otus.log\n'
'[0-9]* 36615 /protected/templates/1_prep_1_qiime_[0-9]*-[0-9]*.'
'- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-[0-9]*.'
'txt mapping_files/{0}_mapping_file.txt\n'.format(a.id))
self.assertRegexpMatches(response.body, exp)

Expand Down

0 comments on commit 587e5bf

Please sign in to comment.