Beispiel #1
0
def gen_extracts(change, tmp_filepath):
    """
    Will generate the file extracts for this change. The extracts include the thumbnail.
    
    :param change: is the change object.
    :param tmp_filepath: is the path to the original file
    """

    # find previous change
    previous = change.entity.get_change(version=change.version - 1)

    extracts = []
    indices = dd(lambda: 0)  #each type of file will have its own count
    raw_extracts, parse_info = image.extract(tmp_filepath)
    change.file_type = parse_info.file_type
    raw_extracts += gen_diffs(previous, raw_extracts)
    for e in raw_extracts:

        change_extract = projects.ChangeExtract(
            change=change,
            extract_type=e.extract_type,
            order_index=indices[e.extract_type])
        change_extract.set_contents(e.filename)
        Session.add(change_extract)
        extracts.append(change_extract)

        indices[e.extract_type] += 1

    change.parse_type = parse_info.type
    change.parse_status = parse_info.status

    commit()
    return extracts
Beispiel #2
0
 def _gen_extracts(self, tmp_contents_filepath):
     """
     Will generate the file extracts for this change. The extracts include the thumbnail.
     
     This will eventually be async.
     """
     
     #this is really ghetto.
     if not is_testing():
         import subprocess
         import desio.utils as dutils
         commit()
         
         proj_root = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
         
         ini_file = os.path.join(proj_root, 'development.ini')
         if dutils.is_production():
             ini_file = os.path.join(proj_root, 'production.ini')
         
         cmd = [
             'python',
             os.path.join(proj_root, 'desio', 'backend', 'run_extract.py'),
             ini_file,
             self.eid,
             tmp_contents_filepath
         ]
         subprocess.call(cmd)
     else:
         #not running this as an external process so we dont have to commit.
         from desio.backend import run_extract
         print 'Generating extracts for testing env'
         run_extract.gen_extracts(self, tmp_contents_filepath)
Beispiel #3
0
def gen_extracts(change, tmp_filepath):
    """
    Will generate the file extracts for this change. The extracts include the thumbnail.
    
    :param change: is the change object.
    :param tmp_filepath: is the path to the original file
    """
    
    # find previous change
    previous = change.entity.get_change(version=change.version-1)
    
    extracts = []
    indices = dd(lambda: 0) #each type of file will have its own count
    raw_extracts, parse_info = image.extract(tmp_filepath)
    change.file_type = parse_info.file_type
    raw_extracts += gen_diffs(previous, raw_extracts)
    for e in raw_extracts:
        
        change_extract = projects.ChangeExtract(change=change, extract_type=e.extract_type, order_index=indices[e.extract_type])
        change_extract.set_contents(e.filename)
        Session.add(change_extract)
        extracts.append(change_extract)
        
        indices[e.extract_type] += 1
    
    change.parse_type = parse_info.type
    change.parse_status = parse_info.status
    
    commit()
    return extracts
Beispiel #4
0
def create(real_user, user, email, entity=None, project=None, organization=None, role=APP_ROLE_READ):
    
    class Form(formencode.Schema):
        email = formencode.All(fv.Email(not_empty=True), fv.MaxLength(256))
        role = fv.OneOf(APP_ROLES, not_empty=True)
    validate(Form, role=role, email=email)
    
    obj = entity or project or organization
    try:
        invite = users.Invite.create(user, email, obj, role=role)
        commit()
    except AppException, e:
        if e.code == DUPLICATE:
            raise ClientException('%s has already been invited to %s' % (email, obj.name), DUPLICATE)
        raise ClientException(e.msg, e.code)
Beispiel #5
0
def create(real_user,
           user,
           email,
           entity=None,
           project=None,
           organization=None,
           role=APP_ROLE_READ):
    class Form(formencode.Schema):
        email = formencode.All(fv.Email(not_empty=True), fv.MaxLength(256))
        role = fv.OneOf(APP_ROLES, not_empty=True)

    validate(Form, role=role, email=email)

    obj = entity or project or organization
    try:
        invite = users.Invite.create(user, email, obj, role=role)
        commit()
    except AppException, e:
        if e.code == DUPLICATE:
            raise ClientException(
                '%s has already been invited to %s' % (email, obj.name),
                DUPLICATE)
        raise ClientException(e.msg, e.code)