Ejemplo n.º 1
0
 def render(self, request):
     # dropping multiple values
     form = dict([(k, v[0]) for k,v in request.args.iteritems()])
     voice = form.get('voice')
     text = form.get('text')
     if not text or not voice:
         return errorpage(request, "you need a voice and something for it to say")
     speech_url = self.speech_server.utter(text, voice=voice)
     request.setHeader('Content-type', 'audio/mpeg')
     request.redirect(speech_url)
     request.finish()
Ejemplo n.º 2
0
 def render(self, request):
     # dropping multiple values
     form = dict([(k, v[0]) for k,v in request.args.iteritems()])
     voice = form.get('voice')
     text = form.get('text')
     if not text or not voice:
         return errorpage(request, "you need a voice and something for it to say", 'mediaupload')
     speech_url = self.speech_server.utter(text, voice=voice)
     request.setHeader('Content-type', 'audio/mpeg')
     request.redirect(speech_url)
     request.finish()
Ejemplo n.º 3
0
    def failure_upload(self, exitcode, swf, thumbnail, form, request):
        """Nothing much to do but spread the word"""
        errMsg = 'Something went wrong.' #Change error message back to default - Gavin

        if form.get('mode', '') == 'replace':
            errMsg += ' Your media was not replaced.'
            # restore old file
            self.media_dict.restoreOldFile(form.get('oldfile'))

        AdminError.errorMsg = errMsg
        request.write(errorpage(request, 'SWF creation failed - maybe the image was bad. See img2swf.log for details', 'mediaupload'))
        request.finish() 
Ejemplo n.º 4
0
    def render(self, request):
        """Don't actually render, but calls a process which returns a
        deferred.

        Callbacks on the deferred do the rendering, which is actually
        achieved through redirection.

        """
        #natasha convert
        # turn form into simple dictionary, dropping multiple values.  
        reqargs = request.args
        
        self.assignedstages = reqargs.get('assigned')
        form = dict([(k, v[0]) for k,v in request.args.iteritems()])
        # natasha: added prefix value
        prefix = ''
        try:
            self.mediatype = form.pop('type', None)
            if not self.mediatype in self.mediatypes:
                raise UpstageError('Not a real kind of thing: %s' % self.mediatype)
            self.media_dict = self.mediatypes[self.mediatype] #self.media_dict = self.collections
            #change to starswith 'avcontents'
            if self.mediatype == 'avatar':
                prefix = 'av'
                # self.media_dict = self.collection.avatars
            elif self.mediatype == 'prop':
                prefix = 'pr'
            elif self.mediatype == 'backdrop':
                prefix = 'bk'
            elif self.mediatype == 'audio': #remem audio not included as things
                prefix = 'au'
            #imgs = [ (k, v) for k, v in form.iteritems() if k.startswith('contents') and v ]
            contentname = prefix + 'contents'
            imgs = [ (k, v) for k, v in form.iteritems() if k.startswith(prefix + 'contents') and v ]
            imgs.sort()
 
            # save input files in /tmp, also save file names
            tfns = [ save_tempfile(x[1]) for x in imgs ]

            # Alan (12/09/07) ==> Gets the size of image files using the previously created temp filenames.
            #natasha getfilesize
            fileSizes = getFileSizes(tfns)
            
            # imported from misc.py
            swf = new_filename(suffix='.swf')
            thumbnail = swf.replace('.swf', '.jpg')
            swf_full = os.path.join(config.MEDIA_DIR, swf)
            thumbnail_full = os.path.join(config.THUMBNAILS_DIR, thumbnail)

        except UpstageError, e:            
            return errorpage(request, e, 500)
Ejemplo n.º 5
0
 def failure(self, exitcode, swf, thumbnail, form, request):
     """Nothing much to do but spread the word"""
     AdminError.errorMsg = 'Something went wrong' #Change error message back to default - Gavin
     request.write(errorpage(request, 'SWF creation failed - maybe the image was bad. See img2swf.log for details'))
     request.finish() 
Ejemplo n.º 6
0
    def render(self, request):
        #XXX not checking rights.
        args = request.args
        
        
        # Natasha - get assigned stages
        self.assignedstages = request.args.get('assigned')
        name = args.pop('name',[''])[0]
        audio = args.pop('aucontents0', [''])[0] #was 'audio' before, aucontents0 is the name of the mp3 file field
        type = args.pop('audio_type', [''])[0]
        mediatype = args.pop('type',['audio'])[0]
        self.message = 'Audio file uploaded & registered as %s, called %s. ' % (type, name)
        #Corey, Heath, Karena 24/08/2011 - Added to store tags for this audiothing
        self.tags = args.pop('tags',[''])[0]
        # PQ & EB Added 13.10.07
        # Chooses a thumbnail image depending on type (adds to audios.xml file)
        
        if type == 'sfx':
             thumbnail = config.SFX_ICON_IMAGE_URL
        else:
             thumbnail = config.MUSIC_ICON_IMAGE_URL

        self.media_dict = self.mediatypes[mediatype]
        
        mp3name = new_filename(suffix=".mp3")
        the_url = config.AUDIO_DIR +"/"+ mp3name
        
        file = open(the_url, 'wb')
        file.write(audio)
        file.close()
        
        filenames = [the_url]
        
        # Alan (09/05/08) ==> Gets the size of audio files using the previously created temp filenames.
        fileSizes = getFileSizes(filenames)
        
        if not (fileSizes is None):
            if (validSizes(fileSizes, self.player.can_su()) or self.player.can_unlimited()):
                now = datetime.datetime.now() # AC () - Unformated datetime value
                self.media_dict.add(url='%s/%s' % (config.AUDIO_SUBURL, mp3name), #XXX dodgy? (windows safe?)
                               file=mp3name,
                               name=name,
                               voice="",
                               thumbnail=thumbnail, # PQ: 13.10.07 was ""
                               medium="%s" %(type),
                               # AC (14.08.08) - Passed values to be added to media XML files.
                               uploader=self.player.name,
                               dateTime=(now.strftime("%d/%m/%y @ %I:%M %p")),
                               tags=self.tags)#Corey, Heath, Karena 24/08/2011 - Added for media tagging set the tags to self.tags
                
                if self.assignedstages is not None:
                    for x in self.assignedstages:
                        self.media_dict.set_media_stage(x, mp3name)
                        
                request.write(successpage(request, 'Your Media "' + name + '" has uploaded successfully'))
                request.finish()
            else:
                try:
                    ''' Send new audio page back containing error message '''
                    """
                    self.player.set_setError(True)
                    os.remove(the_url)
                    request.redirect('/admin/new/%s' %(mediatype))
                    request.finish()
                    """
                    AdminError.errorMsg = 'File over 1MB' #Change error message to file exceed - Gavin
                    request.write(errorpage(request, 'Media uploads are limited to files of 1MB or less, to help ensure that unnecessarily large files do not cause long loading times for your stage. Please make your file smaller or, if you really need to upload a larger file, contact the administrator of this server to ask for permission.'))
                    request.finish()
                except OSError, e:
                    log.err("Error removing temp file %s (already gone?):\n %s" % (tfn, e))
Ejemplo n.º 7
0
    def render(self, request):
        """Don't actually render, but calls a process which returns a
        deferred.

        Callbacks on the deferred do the rendering, which is actually
        achieved through redirection.

        """
        # natasha convert
        # turn form into simple dictionary, dropping multiple values.  
        reqargs = request.args
        
        self.assignedstages = reqargs.get('assigned')
        form = dict([(k, v[0]) for k,v in request.args.iteritems()])
        
        # DEBUG: print form sent by request
        for key in form.iterkeys():
            if 'contents' in key:
                value = "[ binary data: %s Bytes ]" % len(form[key])
            else:
                value = form[key]
                if(len(value)>256):
                    value = value[:256] + " ... " # limit length to 256 chars
                value = "'" + value + "'"
            log.msg("SwfConversionWrapper render(): form: '%s' = %s" % (key, value))
        
        # FIXME: trim spaces from form values? (#104)
        
        # handle kind of images: upload or library:
        imagetype = form.get('imagetype','unknown')
        
        # handle upload imagetype
        if imagetype == 'upload':
            
            log.msg('SwfConversionWrapper: render(): imagetype UPLOAD')
            
            # natasha: added prefix value
            prefix = ''
            try:
                self.mediatype = form.pop('type', None)
                if not self.mediatype in self.mediatypes:
                    raise UpstageError('Not a real kind of thing: %s' % self.mediatype)
                self.media_dict = self.mediatypes[self.mediatype] #self.media_dict = self.collections
                # change to starswith 'avcontents'
                if self.mediatype == 'avatar':
                    prefix = 'av'
                    # self.media_dict = self.collection.avatars
                elif self.mediatype == 'prop':
                    prefix = 'pr'
                elif self.mediatype == 'backdrop':
                    prefix = 'bk'
                elif self.mediatype == 'audio': # remem audio not included as things
                    prefix = 'au'
                
                # imgs = [ (k, v) for k, v in form.iteritems() if k.startswith('contents') and v ]
                contentname = prefix + 'contents'
                imgs = [ (k, v) for k, v in form.iteritems() if k.startswith(contentname) and v ]
                imgs.sort()
                
                # DEBUG:
                #log.msg("SwfConversionWrapper: imgs = %s" % imgs);
     
                # save input files in /tmp, also save file names
                tfns = [ save_tempfile(x[1]) for x in imgs ]
    
                # Alan (12/09/07) ==> Gets the size of image files using the previously created temp filenames.
                # natasha getfilesize
                fileSizes = getFileSizes(tfns)
                
                swf = unique_custom_string(suffix='.swf')
                if form.get('mode', '') == 'replace':
                    oldfile = form.get('oldfile')
                    try:
                        self.media_dict.deleteFile(oldfile)
                    except KeyError:
                        log.msg('the file does not exist. nothing was deleted.')
                        request.write(errorpage(request, 'The file you want to replace does not exist. Accidentally pressed the back button? Tut, tut..', 'mediaedit'))
                        request.finish()

                thumbnail = swf.replace('.swf', '.jpg')         # FIXME: see #20 (Uploaded media is not converted to JPEG)
                swf_full = os.path.join(config.MEDIA_DIR, swf)
                thumbnail_full = os.path.join(config.THUMBNAILS_DIR, thumbnail)
    
            except UpstageError, e:            
                return errorpage(request, e, 'mediaupload')
    
            """ Alan (13/09/07) ==> Check the file sizes of avatar frame """
            # natasha continue conversion
            if not (fileSizes is None):
                if validSizes(fileSizes, self.player.can_upload_big_file()):
                    # call the process with swf filename and temp image filenames 
                    d = getProcessValue(config.IMG2SWF_SCRIPT, args=[swf_full, thumbnail_full] + tfns)
                    args = (swf, thumbnail, form, request)
                    d.addCallbacks(self.success_upload, self.failure_upload, args, {}, args, {})
                    d.addBoth(self.cleanup_upload, tfns)
                    d.setTimeout(config.MEDIA_TIMEOUT, timeoutFunc=d.errback)
                    d.addErrback(log.err)   # Make sure errors get logged - TODO is this working?
                else:
                    redirect = 'mediaupload'
                    if form.get('mode', '') == 'replace':
                        redirect = 'mediaedit'
                        self.media_dict.restoreOldFile(form.get('oldfile'))
                    ''' Send new avatar page back containing error message '''
                    self.player.set_setError(True)
                    self.cleanup_upload(None, tfns)
                    request.write(errorpage(request, 'You do not have the permission to upload a file over 1MB in size.', redirect))
                    # request.redirect('/admin/new/%s' %(self.mediatype))
                    request.finish()
Ejemplo n.º 8
0
class SwfConversionWrapper(Resource):
    """Start a subprocess to convert an image into swf.
    Upon completion of the process, redirect to NewAvatar page.
    Form should contain these elements:
       - name      - name of the uploaded thing
       - contents  - file contents of uploaded thing
       - type      - media type
     May have:
       - voice     - avatar voice
       - editmode  - ' merely editing' signals non conversion, just
                     metadata changes.
    """
    isLeaf = True
    
    def __init__(self, mediatypes, player, stages):
        Resource.__init__(self)
        self.mediatypes = mediatypes
        # Alan (14/09/07) - Gets the player trying to upload
        self.player = player
        self.assignedstages = '' #natasha
        self.mediatype = '' # Natasha trying to make it a global variable
        self.stages = stages
                 
    def render(self, request):
        """Don't actually render, but calls a process which returns a
        deferred.

        Callbacks on the deferred do the rendering, which is actually
        achieved through redirection.

        """
        # natasha convert
        # turn form into simple dictionary, dropping multiple values.  
        reqargs = request.args
        
        self.assignedstages = reqargs.get('assigned')
        form = dict([(k, v[0]) for k,v in request.args.iteritems()])
        
        # DEBUG: print form sent by request
        for key in form.iterkeys():
            if 'contents' in key:
                value = "[ binary data: %s Bytes ]" % len(form[key])
            else:
                value = form[key]
                if(len(value)>256):
                    value = value[:256] + " ... " # limit length to 256 chars
                value = "'" + value + "'"
            log.msg("SwfConversionWrapper render(): form: '%s' = %s" % (key, value))
        
        # FIXME: trim spaces from form values? (#104)
        
        # handle kind of images: upload or library:
        imagetype = form.get('imagetype','unknown')
        
        # handle upload imagetype
        if imagetype == 'upload':
            
            log.msg('SwfConversionWrapper: render(): imagetype UPLOAD')
            
            # natasha: added prefix value
            prefix = ''
            try:
                self.mediatype = form.pop('type', None)
                if not self.mediatype in self.mediatypes:
                    raise UpstageError('Not a real kind of thing: %s' % self.mediatype)
                self.media_dict = self.mediatypes[self.mediatype] #self.media_dict = self.collections
                # change to starswith 'avcontents'
                if self.mediatype == 'avatar':
                    prefix = 'av'
                    # self.media_dict = self.collection.avatars
                elif self.mediatype == 'prop':
                    prefix = 'pr'
                elif self.mediatype == 'backdrop':
                    prefix = 'bk'
                elif self.mediatype == 'audio': # remem audio not included as things
                    prefix = 'au'
                
                # imgs = [ (k, v) for k, v in form.iteritems() if k.startswith('contents') and v ]
                contentname = prefix + 'contents'
                imgs = [ (k, v) for k, v in form.iteritems() if k.startswith(contentname) and v ]
                imgs.sort()
                
                # DEBUG:
                #log.msg("SwfConversionWrapper: imgs = %s" % imgs);
     
                # save input files in /tmp, also save file names
                tfns = [ save_tempfile(x[1]) for x in imgs ]
    
                # Alan (12/09/07) ==> Gets the size of image files using the previously created temp filenames.
                # natasha getfilesize
                fileSizes = getFileSizes(tfns)
                
                swf = unique_custom_string(suffix='.swf')
                if form.get('mode', '') == 'replace':
                    oldfile = form.get('oldfile')
                    try:
                        self.media_dict.deleteFile(oldfile)
                    except KeyError:
                        log.msg('the file does not exist. nothing was deleted.')
                        request.write(errorpage(request, 'The file you want to replace does not exist. Accidentally pressed the back button? Tut, tut..', 'mediaedit'))
                        request.finish()

                thumbnail = swf.replace('.swf', '.jpg')         # FIXME: see #20 (Uploaded media is not converted to JPEG)
                swf_full = os.path.join(config.MEDIA_DIR, swf)
                thumbnail_full = os.path.join(config.THUMBNAILS_DIR, thumbnail)
    
            except UpstageError, e:            
                return errorpage(request, e, 'mediaupload')
    
            """ Alan (13/09/07) ==> Check the file sizes of avatar frame """
            # natasha continue conversion
            if not (fileSizes is None):
                if validSizes(fileSizes, self.player.can_upload_big_file()):
                    # call the process with swf filename and temp image filenames 
                    d = getProcessValue(config.IMG2SWF_SCRIPT, args=[swf_full, thumbnail_full] + tfns)
                    args = (swf, thumbnail, form, request)
                    d.addCallbacks(self.success_upload, self.failure_upload, args, {}, args, {})
                    d.addBoth(self.cleanup_upload, tfns)
                    d.setTimeout(config.MEDIA_TIMEOUT, timeoutFunc=d.errback)
                    d.addErrback(log.err)   # Make sure errors get logged - TODO is this working?
                else:
                    redirect = 'mediaupload'
                    if form.get('mode', '') == 'replace':
                        redirect = 'mediaedit'
                        self.media_dict.restoreOldFile(form.get('oldfile'))
                    ''' Send new avatar page back containing error message '''
                    self.player.set_setError(True)
                    self.cleanup_upload(None, tfns)
                    request.write(errorpage(request, 'You do not have the permission to upload a file over 1MB in size.', redirect))
                    # request.redirect('/admin/new/%s' %(self.mediatype))
                    request.finish()
            #return server.NOT_DONE_YET
        
        # handle library imagetype
        elif imagetype == 'library':
            
            log.msg('SwfConversionWrapper: render(): imagetype LIBRARY')
            
            name = form.get('name', '')
            while self.name_is_used(name):
                name += random.choice('1234567890')
            
            tags = form.get('tags','')
            
            has_streaming = form.get('hasstreaming','false')
            streamtype = form.get('streamtype','auto')
            streamserver = form.get('streamserver','')
            streamname = form.get('streamname','')
            
            medium = ''
            if (has_streaming.lower() == 'true'):
                medium = 'stream'
            
            now = datetime.datetime.now()
            voice = form.get('voice','')
            
            # create random strings for library items
            random_swf_id = util.random_string(config.LIBRARY_ID_LENGTH)
            random_thumbnail_id = util.random_string(config.LIBRARY_ID_LENGTH)
            
            # FIXME test if generated strings already exist, so choose another
            
            # set thumbnail according to streamtype
            thumbnail_image = 'IconLiveStream'   # default
            if streamtype == 'audio':
                thumbnail_image = 'IconAudioStream'
            elif streamtype == 'video':
                thumbnail_image = 'IconVideoStream'
            
            thumbnail = config.LIBRARY_PREFIX + random_thumbnail_id + ":" + thumbnail_image
            
            swf_image = 'VideoOverlay' 
            swf = config.LIBRARY_PREFIX + random_swf_id + ":" + swf_image
            
            log.msg("render(): has streaming? %s" % has_streaming)
            log.msg("render(): streamtype: %s" % streamtype)
            log.msg("render(): streamserver: %s" % streamserver)
            log.msg("render(): streamname: %s" % streamname)    
            log.msg("render(): swf (file): %s" % swf)
            log.msg("render(): name: %s" % name)
            log.msg("render(): voice: %s" % voice)
            log.msg("render(): now: %s" % now)
            log.msg("render(): tags: %s" % tags)
            log.msg("render(): medium: %s" % medium)
            log.msg("render(): thumbnail: %s" % thumbnail)
            log.msg("render(): swf: %s" % swf)
            
            try:
                self.mediatype = form.pop('type', None)
                if not self.mediatype in self.mediatypes:
                    raise UpstageError('Not a real kind of thing: %s' % self.mediatype)
                self.media_dict = self.mediatypes[self.mediatype]
                
                key = unique_custom_string(prefix=self.mediatype+'_', suffix='')
                # add avatar
                self.media_dict.add(file=swf,
                                    name=name,
                                    voice=voice,
                                    uploader=self.player.name,
                                    dateTime=(now.strftime("%d/%m/%y @ %I:%M %p")),
                                    tags=tags,
                                    streamserver=streamserver,
                                    streamname=streamname,
                                    medium=medium,
                                    thumbnail=thumbnail,
                                    key=key
                                    )
                
                # assign to stage?
                if self.assignedstages is not None:
                    log.msg("render(): assigning to stages: %s" % self.assignedstages)
                    self.assign_media_to_stages(self.assignedstages, key, self.mediatype)
                    
            except UpstageError, e:            
                return errorpage(request, e, 'mediaupload')
Ejemplo n.º 9
0
    def render(self, request):
        #XXX not checking rights.
        args = request.args
        
        # FIXME see SwfConversionWrapper: prepare form data
        
        # FIXME: trim spaces from form values? (#104)
        
        # Natasha - get assigned stages
        self.assignedstages = request.args.get('assigned')
        name = args.pop('name',[''])[0]
        audio = args.pop('aucontents0', [''])[0] #was 'audio' before, aucontents0 is the name of the mp3 file field
        type = args.pop('audio_type', [''])[0]
        mediatype = args.pop('type',['audio'])[0]
        self.message = 'Audio file uploaded & registered as %s, called %s. ' % (type, name)
        #Corey, Heath, Karena 24/08/2011 - Added to store tags for this audiothing
        self.tags = args.pop('tags',[''])[0]
        # PQ & EB Added 13.10.07
        # Chooses a thumbnail image depending on type (adds to audios.xml file)
        
        if type == 'sfx':
             thumbnail = config.SFX_ICON_IMAGE_URL
        else:
             thumbnail = config.MUSIC_ICON_IMAGE_URL

        self.media_dict = self.mediatypes[mediatype]

        mp3name = unique_custom_string(suffix=".mp3")
        mode = args.pop('mode', [''])[0]
        oldfile = args.pop('oldfile', [''])[0]
        if mode == 'replace':
            key = args.pop('key')[0]
            try:
                self.media_dict.deleteFile(oldfile)
            except KeyError:
                log.msg('the file does not exist. nothing was deleted.')
                request.write(errorpage(request, 'The file you want to replace does not exist. Accidentally pressed the back button? Tut, tut..', 'mediaedit'))
                request.finish()
        
        the_url = config.AUDIO_DIR +"/"+ mp3name
        
        file = open(the_url, 'wb')
        file.write(audio)
        file.close()
        
        filenames = [the_url]
        
        # Alan (09/05/08) ==> Gets the size of audio files using the previously created temp filenames.
        fileSizes = getFileSizes(filenames)

        from mad import MadFile
        duration = MadFile(the_url).total_time()
        
        if not (fileSizes is None and duration > 0):
            if validSizes(fileSizes, self.player.can_upload_big_file()):
                now = datetime.datetime.now() # AC () - Unformated datetime value
                duration = str(duration/float(1000))

                success_message = ''
                if mode == 'replace':
                    media = self.media_dict[key]

                    media.setUrl(mp3name)
                    setattr(media, 'file', mp3name)
                    setattr(media, 'width', duration) # Ing - width attribute is already there
                    setattr(media, 'uploader', self.player.name)
                    setattr(media, 'dateTime', now.strftime("%d/%m/%y @ %I:%M %p"))
                    self.media_dict.save()

                    success_message = 'Your Media "' + name + '" has been replaced successfully! '

                    # refresh assigned stages
                    stages = args.pop('stages', [''])[0]
                    if stages:
                        success_message += 'The following stage(s) has been reloaded:<strong> ' + stages +'</strong>.<br />'
                        reloadStagesInList(self.stages, stages.split(', '), media.url)
                    
                    success_message += 'Redirecting back to <a href="admin/workshop/mediaedit">Media Management...</a>'
                    redirectTo = 'mediaedit'

                else:
                    key = unique_custom_string(prefix='audio_', suffix='')
                    while self.name_is_used(name):
                        name += random.choice('1234567890')
                    # upload new assets
                    self.media_dict.add(url='%s/%s' % (config.AUDIO_SUBURL, mp3name), #XXX dodgy? (windows safe?)
                                       file=mp3name,
                                       name=name,
                                       voice="",
                                       thumbnail=thumbnail, # PQ: 13.10.07 was ""
                                       medium="%s" %(type),
                                       # AC (14.08.08) - Passed values to be added to media XML files.
                                       uploader=self.player.name,
                                       dateTime=(now.strftime("%d/%m/%y @ %I:%M %p")),
                                       tags=self.tags, #Corey, Heath, Karena 24/08/2011 - Added for media tagging set the tags to self.tags
                                       key=key,
                                       width=duration) # Ing - width attribute is already there, width-length-length-width, kinda similar ;p

                    if self.assignedstages is not None:
                        for x in self.assignedstages:
                            self.media_dict.set_media_stage(x, key)

                    redirectTo = 'mediaupload'
                    success_message = 'Your Media "' + name + '" has uploaded successfully'
                        
                request.write(successpage(request, success_message, redirect=redirectTo))
                request.finish()
            else:
                try:
                    ''' Send new audio page back containing error message '''
                    """
                    self.player.set_setError(True)
                    os.remove(the_url)
                    request.redirect('/admin/new/%s' %(mediatype))
                    request.finish()
                    """
                    errMsg = 'File over 1MB' #Change error message to file exceed - Gavin

                    if mode == 'replace':
                        errMsg += ' Your media was not replaced.'
                        # restore old file
                        self.media_dict.restoreOldFile(oldfile)

                    AdminError.errorMsg = errMsg
                    request.write(errorpage(request, 'Media uploads are limited to files of 1MB or less, \
                                                    to help ensure that unnecessarily large files do not cause long loading times for your stage. \
                                                    Please make your file smaller or, if you really need to upload a larger file, \
                                                    contact the administrator of this server to ask for permission.', 'mediaupload'))
                    request.finish()
                except OSError, e:
                    log.err("Error removing temp file %s (already gone?):\n %s" % (tfn, e))
Ejemplo n.º 10
0
                    log.msg("render(): assigning to stages: %s" % self.assignedstages)
                    self.assign_media_to_stages(self.assignedstages, key, self.mediatype)
                    
            except UpstageError, e:            
                return errorpage(request, e, 'mediaupload')
            
            log.msg("render(): got past media_dict.add, YES")
            
            request.write(successpage(request, 'Your Avatar "' + name + '" has been added successfully'))
            request.finish()
        
        # handle unknown imagetypes
        else:
            # output error, because we do not have a valid imagetype
            log.err('SwfConversionWrapper: render(): Unsupported imagetype: %s' % imagetype)
            request.write(errorpage(request, "Unsupported image type '%s'." % imagetype, 'mediaupload'))
            request.finish() 
        
        return server.NOT_DONE_YET
    
    """
     Modified by: Corey, Heath, Karena 24/08/2011 - Added media tagging to self.media_dict.add
    """

    def success_upload(self, exitcode, swf, thumbnail, form, request):
        """Catch results of the process.  If it seems to have worked,
        register the new thing."""
        if exitcode:
        #request.write(exitcode)
            return self.failure_upload(exitcode, swf, thumbnail, form, request)