Esempio n. 1
0
    def process_task(obj):
        
        # to prevent circular import errors
        from util.process import Process
        
        processor = Process()
        
        # duplicate check by sha1
        media_id = processor.id_by_sha1(obj.file)
        log.debug('Got something by sha1?: %s' % media_id)
        # duplicate check by echoprint
        if not media_id:
            media_id = processor.id_by_echoprint(obj.file)
            log.debug('Got something by echoprint?: %s' % media_id)

        try:
            metadata = processor.extract_metadata(obj.file)
            if metadata:
                log.info('sucessfully extracted metadata')

        except Exception, e:
            print e
            obj.error = '%s' % e
            obj.status = 99
            obj.save()
            return
Esempio n. 2
0
    def dependency_check(self):
        ''' Check that required programs are installed '''
        required_apps = [
            'airmon-ng', 'iwconfig', 'ifconfig', 'aircrack-ng', 'aireplay-ng',
            'airodump-ng', 'tshark'
        ]
        optional_apps = [
            'packetforge-ng', 'reaver', 'bully', 'cowpatty', 'pyrit', 'stdbuf',
            'macchanger'
        ]
        missing_required = False
        missing_optional = False

        for app in required_apps:
            if not Process.exists(app):
                missing_required = True
                Color.pl('{!} {R}error: required app {O}%s{R} was not found' %
                         app)

        for app in optional_apps:
            if not Process.exists(app):
                missing_optional = True
                Color.pl(
                    '{!} {O}warning: recommended app {R}%s{O} was not found' %
                    app)

        if missing_required:
            Color.pl('{!} {R}required app(s) were not found, exiting.{W}')
            sys.exit(-1)

        if missing_optional:
            Color.pl('{!} {O}recommended app(s) were not found')
            Color.pl('{!} {O}wifite may not work as expected{W}')
Esempio n. 3
0
    def process_task(obj):

        processor = Process()
        metadata = processor.extract_metadata(obj.file)

        #time.sleep(1)

        obj.results_tag = metadata
        print "DONE!!!"
        print metadata
        obj.status = 3
        obj.save()

        obj.results_acoustid = processor.get_aid(obj.file)
        obj.save()
Esempio n. 4
0
    def process_task(obj):
        
        processor = Process()
        metadata = processor.extract_metadata(obj.file)


        #time.sleep(1)

        obj.results_tag = metadata
        print "DONE!!!"
        print metadata
        obj.status = 3
        obj.save()
        
        
        obj.results_acoustid = processor.get_aid(obj.file)
        obj.save()
Esempio n. 5
0
    def process_task(obj):

        target = 'download'

        from atracker.util import create_event

        process = Process()
        status, result, messages = process.run(instance=obj,
                                               format=obj.fileformat)

        if target == 'download':

            if result:

                obj.filesize = os.path.getsize(result)
                obj.file = DjangoFile(open(result), u'archive')

                # update status
                obj.status = 1
                obj.save()
                process.clear_cache()
            else:
                obj.status = 99
                obj.status_msg = messages
                obj.save()
                process.clear_cache()
Esempio n. 6
0
    def process_task(obj):

        target = 'download'

        from atracker.util import create_event

        process = Process()
        status, result, messages = process.run(instance=obj, format=obj.fileformat)

        if target == 'download':

            if result:

                obj.filesize = os.path.getsize(result)
                obj.file = DjangoFile(open(result), u'archive')

                # update status
                obj.status = 1
                obj.save()
                process.clear_cache()
            else:
                obj.status = 99
                obj.status_msg = messages
                obj.save()
                process.clear_cache()
Esempio n. 7
0
    def process_task(obj):
        
        # to prevent circular import errors
        from util.process import Process
        
        processor = Process()
        
        # duplicate check by sha1
        media_id = processor.id_by_sha1(obj.file)
        
        # duplicate check by echoprint
        if not media_id:
            media_id = processor.id_by_echoprint(obj.file)

        try:
            metadata = processor.extract_metadata(obj.file)

        except Exception, e:
            print e
            obj.error = '%s' % e
            obj.status = 99
            obj.save()
            return
Esempio n. 8
0
    def process_task(obj):

        from atracker.util import create_event

        process = Process()

        dbox = None
        # dbox = Synchronizer(obj.user)

        log = logging.getLogger('exporter.models.process_task')

        archive_dir = create_archive_dir(obj)
        archive_cache_dir = os.path.join(archive_dir, 'cache/')
        archive_path = os.path.join(archive_dir, 'archive') # .zip appended by 'make_archive'

        # clean cache and recreate
        shutil.rmtree(archive_cache_dir, True)
        os.makedirs(archive_cache_dir)

        log.debug('archive_dir: %s' % (archive_dir))
        log.debug('archive_cache_dir: %s' % (archive_cache_dir))
        log.debug('archive_path: %s' % (archive_path))

        """
        first collect respective items and store everything in a temporary directory
        (the archive_cache_dir)
        """

        try:


            for item in obj.export_items.all():

                log.debug('export ctype: %s | id: %s' % (item.content_type, item.object_id))

                # switching processing for different types

                """
                Releases
                """
                if item.content_type.name.lower() == 'release':

                    t_item = item.content_object

                    """
                    create item specific path
                    < Artist Name >/< Release Name >/...
                    """

                    # relative path, for any target
                    item_rel_dir = os.path.join(safe_name(t_item.get_artist_display()), safe_name(t_item.name))
                    item_cache_dir = os.path.join(archive_cache_dir, item_rel_dir)

                    os.makedirs(item_cache_dir)

                    # holder for playlist entries
                    playlist_items = []

                    # string format for filename
                    filename_format = '%s - %s - %s.%s'

                    for media in t_item.media_release.all():

                        log.debug('export item: %s | id: %s' % ( media.name, media.pk))

                        if obj.fileformat == 'mp3':

                            filename = filename_format % (media.tracknumber, media.name, media.artist.name, 'mp3')
                            filename = safe_name(filename)
                            #filepath = os.path.join(archive_cache_dir, filename)
                            filepath = os.path.join(item_cache_dir, filename)

                            shutil.copyfile(media.get_cache_file('mp3', 'base'), filepath)
                            try:
                                process.inject_metadata(filepath, media)
                            except Exception, e:
                                pass

                        # just dummy - not possible...
                        if obj.fileformat == 'flac':

                            filename = filename_format % (media.tracknumber, media.name, media.artist.name, 'mp3')
                            filename = safe_name(filename)
                            filepath = os.path.join(item_cache_dir, filename)

                            shutil.copyfile(media.get_cache_file('mp3', 'base'), filepath)
                            try:
                                process.inject_metadata(filepath, media)
                            except Exception, e:
                                pass

                        playlist_items.append({'filename': filename, 'item': media})

                        if dbox:
                            dbox.upload(filepath, os.path.join('Releases', item_rel_dir, filename))

                        create_event(obj.user, media, None, 'download')

                    if t_item.main_image:
                        try:
                            shutil.copyfile(t_item.main_image.path, os.path.join(item_cache_dir, 'cover.jpg'))
                        except Exception, e:
                            print e
                            pass


                            #archive_file.write(t_item.main_image.path, 'cover.jpg')

                    """
                    Add additional assets
                    REATME.TXT LICENSE.TXT etc
                    """
                    with open(os.path.join(item_cache_dir, 'README.TXT'), "w") as txt:
                        str = render_to_string('exporter/txt/README.TXT', {'object': t_item})
                        txt.write(str)

                    """
Esempio n. 9
0
    def process_task(obj):

        from atracker.util import create_event

        process = Process()

        log = logging.getLogger('exporter.models.process_task')

        archive_dir = create_archive_dir(obj)
        archive_cache_dir = os.path.join(archive_dir, 'cache/')
        archive_path = os.path.join(
            archive_dir, 'archive')  # .zip appended by 'make_archive'
        #archive_file = ZipFile(archive_path, "w")

        log.debug('archive_dir: %s' % (archive_dir))
        log.debug('archive_cache_dir: %s' % (archive_cache_dir))
        log.debug('archive_path: %s' % (archive_path))

        # do shizzle
        for item in obj.export_items.all():
            print
            print 'item: %s' % item.content_type
            print 'pk: %s' % item.object_id

            # maybe not too elegant.. switching processing for different types
            if item.content_type.name.lower() == 'release':

                t_item = item.content_object

                filename_format = '%s - %s - %s.%s'

                print 'GOT RELEAZE!'

                for media in t_item.media_release.all():
                    print 'Media: %s' % media.name

                    if obj.fileformat == 'mp3':

                        filename = filename_format % (media.tracknumber,
                                                      media.name,
                                                      media.artist.name, 'mp3')
                        filepath = os.path.join(archive_cache_dir, filename)

                        shutil.copyfile(media.get_cache_file('mp3', 'base'),
                                        filepath)
                        process.incect_metadata(filepath, media)

                    # just dummy - not possible...
                    if obj.fileformat == 'flac':

                        filename = filename_format % (media.tracknumber,
                                                      media.name,
                                                      media.artist.name, 'mp3')
                        filepath = os.path.join(archive_cache_dir, filename)

                        shutil.copyfile(media.get_cache_file('mp3', 'base'),
                                        filepath)
                        process.incect_metadata(filepath, media)

                    create_event(obj.user, media, None, 'download')

                if t_item.main_image:
                    pass
                    #archive_file.write(t_item.main_image.path, 'cover.jpg')

            print

        shutil.make_archive(archive_path, 'zip', archive_cache_dir)

        obj.file = DjangoFile(open(archive_path + '.zip'), u'archive.zip')
        obj.filesize = os.path.getsize(archive_path + '.zip')

        # get filesize
        obj.filename = generate_export_filename(obj.export_items)
        #obj.filename = 'asdasdas'

        # update status
        obj.status = 1
        obj.save()
Esempio n. 10
0
    def process_task(obj):

        # to prevent circular import errors
        from util.process import Process

        processor = Process()

        # duplicate check by sha1
        media_id = processor.id_by_sha1(obj.file)

        # duplicate check by echoprint
        if not media_id:
            media_id = processor.id_by_echoprint(obj.file)

        metadata = processor.extract_metadata(obj.file)

        # try to get media by id returned from fingerprinter
        media = None
        if media_id:
            try:
                media = Media.objects.get(pk=media_id)
            except:
                pass

        if media:
            obj.results_tag = metadata

            obj.media = media

            print "DUPLICATE!!!"
            # obj.results_tag_status = True
            # obj.status = 5
            # obj.save()

        else:

            pass

        #time.sleep(1)

        obj.results_tag = metadata
        print "DONE!!!"
        print metadata
        print
        obj.status = 3
        obj.results_tag_status = True
        obj.save()

        obj.results_acoustid = processor.get_aid(obj.file)
        obj.results_acoustid_status = True
        obj.save()

        obj.results_musicbrainz = processor.get_musicbrainz(obj)
        obj.results_discogs_status = True
        obj.save()

        # requeue if no results yet
        print 'MB YET!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
        if len(obj.results_musicbrainz) < 1:
            s = {'skip_tracknumber': True}
            obj.settings = s
            obj.save()
            obj.results_musicbrainz = processor.get_musicbrainz(obj)
            obj.save()

        obj.status = 2

        if media:
            obj.status = 5
            # add to session
            obj.import_session.add_importitem(obj)

        obj.results_tag_status = True
        obj.save()
Esempio n. 11
0
    def process_task(obj):
        
        # to prevent circular import errors
        from util.process import Process
        
        processor = Process()
        
        # duplicate check by sha1
        media_id = processor.id_by_sha1(obj.file)
        
        # duplicate check by echoprint
        if not media_id:
            media_id = processor.id_by_echoprint(obj.file)
        
        metadata = processor.extract_metadata(obj.file)
        
        
        # try to get media by id returned from fingerprinter
        media = None
        if media_id:
            try:
                media = Media.objects.get(pk=media_id)
            except:
                pass
        
        
        if media:
            obj.results_tag = metadata

            obj.media = media
            
            print "DUPLICATE!!!"
            # obj.results_tag_status = True
            # obj.status = 5
            # obj.save()
            
        else:
            
            pass
            
    
        #time.sleep(1)

        obj.results_tag = metadata
        print "DONE!!!"
        print metadata
        print 
        obj.status = 3
        obj.results_tag_status = True
        obj.save()
        
        
        obj.results_acoustid = processor.get_aid(obj.file)
        obj.results_acoustid_status = True
        obj.save()

        obj.results_musicbrainz = processor.get_musicbrainz(obj)
        obj.results_discogs_status = True
        obj.save()
        
        # requeue if no results yet
        print 'MB YET!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
        if len(obj.results_musicbrainz) < 1:
            s = {'skip_tracknumber': True}
            obj.settings = s
            obj.save()
            obj.results_musicbrainz = processor.get_musicbrainz(obj)
            obj.save()
            
        
        obj.status = 2
        
        if media:
            obj.status = 5
            # add to session
            obj.import_session.add_importitem(obj)
        
        obj.results_tag_status = True
        obj.save()
Esempio n. 12
0
    def process_task(obj):
        
        from atracker.util import create_event
        
        process = Process()
        
        log = logging.getLogger('exporter.models.process_task')
        
        archive_dir = create_archive_dir(obj)
        archive_cache_dir = os.path.join(archive_dir, 'cache/')
        archive_path = os.path.join(archive_dir, 'archive') # .zip appended by 'make_archive'
        #archive_file = ZipFile(archive_path, "w")
        
        log.debug('archive_dir: %s' % (archive_dir))
        log.debug('archive_cache_dir: %s' % (archive_cache_dir))
        log.debug('archive_path: %s' % (archive_path))
        
        # do shizzle
        for item in obj.export_items.all():
            print
            print 'item: %s' % item.content_type
            print 'pk: %s' % item.object_id
            
            # maybe not too elegant.. switching processing for different types
            if item.content_type.name.lower() == 'release':
                
                t_item = item.content_object
                
                filename_format = '%s - %s - %s.%s'
                
                print 'GOT RELEAZE!'
                
                for media in t_item.media_release.all():
                    print 'Media: %s' % media.name
                
                    if obj.fileformat == 'mp3':
                
                        filename = filename_format % (media.tracknumber, media.name, media.artist.name, 'mp3')
                        filepath = os.path.join(archive_cache_dir, filename)
                        
                        shutil.copyfile(media.get_cache_file('mp3', 'base'), filepath)
                        process.incect_metadata(filepath, media)
                
                    # just dummy - not possible...
                    if obj.fileformat == 'flac':
                
                        filename = filename_format % (media.tracknumber, media.name, media.artist.name, 'mp3')
                        filepath = os.path.join(archive_cache_dir, filename)
                        
                        shutil.copyfile(media.get_cache_file('mp3', 'base'), filepath)
                        process.incect_metadata(filepath, media)
                        
                    create_event(obj.user, media, None, 'download')
                    
                if t_item.main_image:
                    pass
                    #archive_file.write(t_item.main_image.path, 'cover.jpg')
                    
                    
                
            
            print
            
        shutil.make_archive(archive_path, 'zip', archive_cache_dir)
            
        
        obj.file = DjangoFile(open(archive_path + '.zip'), u'archive.zip')
        obj.filesize = os.path.getsize(archive_path + '.zip')

            
        # get filesize
        obj.filename = generate_export_filename(obj.export_items)
        #obj.filename = 'asdasdas'
        
        # update status
        obj.status = 1;
        obj.save()