def _handle_uploaded_file(f, name): '''Handles a file upload to the projects QUOTE_FILES_ROOT Expects a django InMemoryUpload object, and a filename''' logger.debug('*** _handle_uploaded_file: enter ***') retval = False try: ensure_repo_filestore_dir_with_owner(settings.QUOTE_FILES_ROOT) destfname = os.path.join(settings.QUOTE_FILES_ROOT, name ) destination = open(destfname, 'wb+') for chunk in f.chunks(): destination.write(chunk) destination.close() retval = set_repo_file_ownerships(destfname) except Exception, e: retval = False logger.debug('\tException in file upload: %s' % (str(e)) )
def _handle_uploaded_file(f, name): '''Handles a file upload to the projects QUOTE_FILES_ROOT Expects a django InMemoryUpload object, and a filename''' logger.debug('*** _handle_uploaded_file: enter ***') retval = False try: ensure_repo_filestore_dir_with_owner(settings.QUOTE_FILES_ROOT) destfname = os.path.join(settings.QUOTE_FILES_ROOT, name) destination = open(destfname, 'wb+') for chunk in f.chunks(): destination.write(chunk) destination.close() retval = set_repo_file_ownerships(destfname) except Exception, e: retval = False logger.debug('\tException in file upload: %s' % (str(e)))
def ensure_dir(self): """ Creates all the experiment storage directories if they don't exist, and sets their permissions. """ other_dirs = ["Project Background", "Data Processing", "Bioinformatics Analysis", "Report"] # filter the other_dirs to remove ones which exist somewhere # within the tree existing_dirs = set(chain(*(d for r, d, f in os.walk(self.other_files_dir)))) other_dirs = [os.path.join(self.other_files_dir, subdir) for subdir in other_dirs if subdir not in existing_dirs] for dir in [self.experiment_dir] + other_dirs: try: ensure_repo_filestore_dir_with_owner(dir) except Exception, e: pass # the exception is already logged in the ensure function
def _handle_uploaded_file(f, name): '''Handles a file upload to the projects REPO_FILES_ROOT Expects a django InMemoryUpload object, and a filename''' logger.debug('*** _handle_uploaded_file: enter ***') retval = False try: import os reldir = os.path.dirname(name) dest_fname = str(os.path.join(settings.REPO_FILES_ROOT, name)) ensure_repo_filestore_dir_with_owner(reldir) destination = open(dest_fname, 'wb+') for chunk in f.chunks(): destination.write(chunk) destination.close() retval = set_repo_file_ownerships(dest_fname) except Exception, e: retval = False logger.exception('Exception in file upload')
def _handle_uploaded_file(f, name): """Handles a file upload to the projects REPO_FILES_ROOT Expects a django InMemoryUpload object, and a filename""" logger.debug("*** _handle_uploaded_file: enter ***") retval = False try: import os reldir = os.path.dirname(name) dest_fname = str(os.path.join(settings.REPO_FILES_ROOT, name)) ensure_repo_filestore_dir_with_owner(reldir) destination = open(dest_fname, "wb+") for chunk in f.chunks(): destination.write(chunk) destination.close() retval = set_repo_file_ownerships(dest_fname) except Exception, e: retval = False logger.exception("Exception in file upload")
def ensure_dir(self): "Creates the data directory if it doesn't exist, and sets permissions." ensure_repo_filestore_dir_with_owner(self.run_dir) return self.run_dir
def _filepath(self, filename): ensure_repo_filestore_dir_with_owner(sopdir) return os.path.join(sopfs.location, self.version, filename)
def sop_filepath(sop, filename): ensure_repo_filestore_dir_with_owner(sopdir) return os.path.join(sopfs.location, sop.version, filename)