Ejemplo n.º 1
0
    def import_task(obj):

        log = logging.getLogger('importer.models.import_task')
        log.info('Starting import task for:  %s' % (obj.pk))

        pre_sleep = 1
        log.debug('sleping for %s seconds' % pre_sleep)
        time.sleep(pre_sleep)
        log.debug('wakeup after %s seconds' % pre_sleep)


        # to prevent circular import errors
        from util.importer import Importer
        importer = Importer()
        
        media, status = importer.run(obj)

        if media:
            obj.media = media

            obj.status = 1
            
        else:
            obj.status = 99
        
        log.info('Ending import task for:  %s' % (obj.pk))
        obj.save()
Ejemplo n.º 2
0
    def save(self, skip_apply_import_tag=False, *args, **kwargs):
        
        msg = {'key': 'save', 'content': 'object saved'}
        #self.messages.update(msg);

        if not self.filename:
            self.filename = self.file.name
            
        # check/update import_tag
        if self.status == 2: # ready
            from util.importer import Importer
            importer = Importer()
            
            self.import_tag = importer.complete_import_tag(self)
            

        if self.status == 2: # ready
            # try to apply import_tag to other files of this import session
            if not skip_apply_import_tag and self.import_session:
                self.import_session.apply_import_tag(self)
                
        # check import_tag for completeness
        if self.status == 2 or self.status == 4: # ready
            media = self.import_tag.get('name', None)
            artist = self.import_tag.get('artist', None)
            release = self.import_tag.get('release', None)
            
            #print 'media: %s' % media
            #print 'artist: %s' % artist
            #print 'release: %s' % release
            
            if media and artist and release:
                print 'all ok'
                self.status = 2
            else:
                print 'missing!'
                self.status = 4

            

        super(ImportFile, self).save(*args, **kwargs)
Ejemplo n.º 3
0
    def import_task(obj):
        log = logging.getLogger('importer.models.import_task')
        log.info('Starting import task for:  %s' % (obj.pk))
        # to prevent circular import errors
        from util.importer import Importer
        importer = Importer()

        media, status = importer.run(obj)

        if media:
            print 'GOT MEDIA - SAVE IT'
            print media
            obj.media = media
            print obj.media

            obj.status = 1

        else:
            obj.status = 99

        log.info('Ending import task for:  %s' % (obj.pk))
        obj.save()
Ejemplo n.º 4
0
    def import_task(obj):
        log = logging.getLogger('importer.models.import_task')
        log.info('Starting import task for:  %s' % (obj.pk))
        # to prevent circular import errors
        from util.importer import Importer
        importer = Importer()
        
        media, status = importer.run(obj)

        if media:
            print 'GOT MEDIA - SAVE IT'
            print media
            obj.media = media
            print obj.media
            
            obj.status = 1
            
        else:
            obj.status = 99
        
        log.info('Ending import task for:  %s' % (obj.pk))
        obj.save()
Ejemplo n.º 5
0
    def save(self, skip_apply_import_tag=False, *args, **kwargs):

        msg = {'key': 'save', 'content': 'object saved'}
        #self.messages.update(msg);

        if not self.filename:
            self.filename = self.file.name

        # check/update import_tag
        if self.status == 2:  # ready
            from util.importer import Importer
            importer = Importer()

            self.import_tag = importer.complete_import_tag(self)

        if self.status == 2:  # ready
            # try to apply import_tag to other files of this import session
            if not skip_apply_import_tag:
                self.import_session.apply_import_tag(self)

        # check import_tag for completeness
        if self.status == 2 or self.status == 4:  # ready
            media = self.import_tag.get('name', None)
            artist = self.import_tag.get('artist', None)
            release = self.import_tag.get('release', None)

            print 'media: %s' % media
            print 'artist: %s' % artist
            print 'release: %s' % release

            if media and artist and release:
                print 'all ok'
                self.status = 2
            else:
                print 'missing!'
                self.status = 4

        super(ImportFile, self).save(*args, **kwargs)
Ejemplo n.º 6
0
    def save(self, skip_apply_import_tag=False, *args, **kwargs):
        
        msg = {'key': 'save', 'content': 'object saved'}
        #self.messages.update(msg);

        # self._pushy_ignore = True

        if not self.filename:
            self.filename = self.file.name
            
        # check/update import_tag
        if self.status == 2: # ready
            from util.importer import Importer
            importer = Importer()
            
            self.import_tag = importer.complete_import_tag(self)
            

        if self.status == 2: # ready
            # try to apply import_tag to other files of this import session
            if not skip_apply_import_tag and self.import_session:
                # TODO: this breaks the interface, as nearly infinite loop arises
                #print 'skipping import_session.apply_import_tag'
                print 'import_session.apply_import_tag'
                self.import_session.apply_import_tag(self)
                
        # check import_tag for completeness
        if self.status == 2 or self.status == 4: # ready
            media = self.import_tag.get('name', None)
            artist = self.import_tag.get('artist', None)
            release = self.import_tag.get('release', None)
            
            if media and artist and release:
                self.status = 2
            else:
                self.status = 4

        super(ImportFile, self).save(*args, **kwargs)