Skip to content

Commit 52638a4

Browse files
committed
fix #3455
1 parent 08ce025 commit 52638a4

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

qiita_db/meta_util.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#
2323
# The full license is in the file LICENSE, distributed with this software.
2424
# -----------------------------------------------------------------------------
25-
from os import stat, rename
25+
from os import stat
26+
from shutil import move
2627
from os.path import join, relpath, basename
2728
from time import strftime, localtime
2829
import matplotlib.pyplot as plt
@@ -48,6 +49,8 @@
4849
"sName", "sVersion", "cID", "cName", "processing_job_id",
4950
"parameters", "samples", "columns", "input_size", "extra_info",
5051
"MaxRSSRaw", "ElapsedRaw", "Start", "node_name", "node_model"]
52+
RAW_DATA_ARTIFACT_TYPE = {
53+
'SFF', 'FASTQ', 'FASTA', 'FASTA_Sanger', 'per_sample_FASTQ'}
5154

5255

5356
def _get_data_fpids(constructor, object_id):
@@ -118,9 +121,7 @@ def validate_filepath_access_by_user(user, filepath_id):
118121

119122
if artifact.visibility == 'public':
120123
# TODO: https://github.com/biocore/qiita/issues/1724
121-
if artifact.artifact_type in ['SFF', 'FASTQ', 'FASTA',
122-
'FASTA_Sanger',
123-
'per_sample_FASTQ']:
124+
if artifact.artifact_type in RAW_DATA_ARTIFACT_TYPE:
124125
study = artifact.study
125126
has_access = study.has_access(user, no_public=True)
126127
if (not study.public_raw_download and not has_access):
@@ -469,7 +470,7 @@ def generate_biom_and_metadata_release(study_status='public'):
469470
for c in iter(lambda: f.read(4096), b""):
470471
md5sum.update(c)
471472

472-
rename(tgz_name, tgz_name_final)
473+
move(tgz_name, tgz_name_final)
473474

474475
vals = [
475476
('filepath', tgz_name_final[len(working_dir):], r_client.set),
@@ -543,7 +544,7 @@ def generate_plugin_releases():
543544
md5sum = md5()
544545
for c in iter(lambda: f.read(4096), b""):
545546
md5sum.update(c)
546-
rename(tgz_name, tgz_name_final)
547+
move(tgz_name, tgz_name_final)
547548
vals = [
548549
('filepath', tgz_name_final[len(working_dir):], r_client.set),
549550
('md5sum', md5sum.hexdigest(), r_client.set),

qiita_db/support_files/populate_test_db.sql

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ INSERT INTO qiita.artifact_type VALUES (5, 'per_sample_FASTQ', NULL, true, false
8888
INSERT INTO qiita.artifact_type VALUES (7, 'BIOM', 'BIOM table', false, false, true);
8989

9090

91+
9192
--
9293
-- Data for Name: data_type; Type: TABLE DATA; Schema: qiita; Owner: antoniog
9394
--

qiita_db/util.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from bcrypt import hashpw, gensalt
5050
from functools import partial
5151
from os.path import join, basename, isdir, exists, getsize
52-
from os import walk, remove, listdir, rename, stat, makedirs
52+
from os import walk, remove, listdir, stat, makedirs
5353
from glob import glob
5454
from shutil import move, rmtree, copy as shutil_copy
5555
from openpyxl import load_workbook
@@ -542,7 +542,7 @@ def move_upload_files_to_trash(study_id, files_to_move):
542542
new_fullpath = join(foldername, trash_folder, filename)
543543

544544
if exists(fullpath):
545-
rename(fullpath, new_fullpath)
545+
move(fullpath, new_fullpath)
546546

547547

548548
def get_mountpoint(mount_type, retrieve_all=False, retrieve_subdir=False):
@@ -2297,7 +2297,9 @@ def send_email(to, subject, body):
22972297
msg = MIMEMultipart()
22982298
msg['From'] = qiita_config.smtp_email
22992299
msg['To'] = to
2300-
msg['Subject'] = subject.strip()
2300+
# we need to do 'replace' because the subject can have
2301+
# new lines in the middle of the string
2302+
msg['Subject'] = subject.replace('\n', '')
23012303
msg.attach(MIMEText(body, 'plain'))
23022304

23032305
# connect to smtp server, using ssl if needed

qiita_pet/handlers/artifact_handlers/base_handlers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from qiita_db.processing_job import ProcessingJob
2222
from qiita_db.util import get_visibilities, send_email
2323
from qiita_db.logger import LogEntry
24+
from qiita_db.meta_util import RAW_DATA_ARTIFACT_TYPE
2425

2526

2627
PREP_TEMPLATE_KEY_FORMAT = 'prep_template_%s'
@@ -208,8 +209,7 @@ def artifact_summary_get_request(user, artifact_id):
208209
# TODO: https://github.com/biocore/qiita/issues/1724 Remove this hardcoded
209210
# values to actually get the information from the database once it stores
210211
# the information
211-
if artifact_type in ['SFF', 'FASTQ', 'FASTA', 'FASTA_Sanger',
212-
'per_sample_FASTQ']:
212+
if artifact_type in RAW_DATA_ARTIFACT_TYPE:
213213
# If the artifact is one of the "raw" types, only the owner of the
214214
# study and users that has been shared with can see the files
215215
study = artifact.study

0 commit comments

Comments
 (0)