예제 #1
0
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)) )
예제 #2
0
파일: views.py 프로젝트: eschen42/mastr-ms
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)))
예제 #3
0
    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
예제 #4
0
파일: views.py 프로젝트: eschen42/mastr-ms
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')
예제 #5
0
파일: models.py 프로젝트: eschen42/mastr-ms
    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
예제 #6
0
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")
예제 #7
0
 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
예제 #8
0
 def _filepath(self, filename):
     ensure_repo_filestore_dir_with_owner(sopdir)
     return os.path.join(sopfs.location, self.version, filename)
예제 #9
0
파일: models.py 프로젝트: eschen42/mastr-ms
 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
예제 #10
0
파일: models.py 프로젝트: eschen42/mastr-ms
def sop_filepath(sop, filename):
    ensure_repo_filestore_dir_with_owner(sopdir)
    return os.path.join(sopfs.location, sop.version, filename)