Beispiel #1
0
 def __init__(self, controls):
     self.controls = controls        
     ChildTopWindow.__init__(self, _("Download Manager"))
     self.set_resizable(True)
     self.set_default_size(900, 700)
     
     vbox = gtk.VBox(False, 0)
     #paned = gtk.HPaned()
     #paned.set_position(200)
     
     self.navigation = DMNavigationTreeControl()
         
     self.navigation.append(FDModel("All").add_artist("All").add_status(DOWNLOAD_STATUS_ALL))
     self.navigation.append(FDModel("Downloading").add_artist("Downloading").add_status(DOWNLOAD_STATUS_DOWNLOADING))
     self.navigation.append(FDModel("Completed").add_artist("Completed").add_status(DOWNLOAD_STATUS_COMPLETED))
     self.navigation.append(FDModel("Active").add_artist("Active").add_status(DOWNLOAD_STATUS_ACTIVE))
     self.navigation.append(FDModel("Inactive").add_artist("Inactive").add_status(DOWNLOAD_STATUS_INACTIVE))
     
     self.dm_list = DownloadManagerTreeControl(self.navigation)
     self.navigation.dm_list = self.dm_list
     #paned.pack1(self.navigation.scroll)
     #paned.pack2(self.dm_list.scroll)
     playback = DMControls(self.controls, self.dm_list)
     
     vbox.pack_start(playback, False, True)
     #vbox.pack_start(paned, True, True)
     vbox.pack_start(self.dm_list.scroll, True, True)
                    
     self.add(vbox)
     thread.start_new_thread(self.dowloader, (self.dm_list,))
Beispiel #2
0
    def __init__(self, controls):
        self.controls = controls
        ChildTopWindow.__init__(self, _("Download Manager"))
        self.set_resizable(True)
        self.set_default_size(900, 700)

        vbox = gtk.VBox(False, 0)
        #paned = gtk.HPaned()
        #paned.set_position(200)

        self.navigation = DMNavigationTreeControl()

        self.navigation.append(
            FDModel("All").add_artist("All").add_status(DOWNLOAD_STATUS_ALL))
        self.navigation.append(
            FDModel("Downloading").add_artist("Downloading").add_status(
                DOWNLOAD_STATUS_DOWNLOADING))
        self.navigation.append(
            FDModel("Completed").add_artist("Completed").add_status(
                DOWNLOAD_STATUS_COMPLETED))
        self.navigation.append(
            FDModel("Active").add_artist("Active").add_status(
                DOWNLOAD_STATUS_ACTIVE))
        self.navigation.append(
            FDModel("Inactive").add_artist("Inactive").add_status(
                DOWNLOAD_STATUS_INACTIVE))

        self.dm_list = DownloadManagerTreeControl(self.navigation)
        self.navigation.dm_list = self.dm_list
        #paned.pack1(self.navigation.scroll)
        #paned.pack2(self.dm_list.scroll)
        playback = DMControls(self.controls, self.dm_list)

        vbox.pack_start(playback, False, True)
        #vbox.pack_start(paned, True, True)
        vbox.pack_start(self.dm_list.scroll, True, True)

        self.add(vbox)
        thread.start_new_thread(self.dowloader, (self.dm_list, ))
Beispiel #3
0
class DM(ChildTopWindow):
    def __init__(self, controls):
        self.controls = controls        
        ChildTopWindow.__init__(self, _("Download Manager"))
        self.set_resizable(True)
        self.set_default_size(900, 700)
        
        vbox = gtk.VBox(False, 0)
        #paned = gtk.HPaned()
        #paned.set_position(200)
        
        self.navigation = DMNavigationTreeControl()
            
        self.navigation.append(FDModel("All").add_artist("All").add_status(DOWNLOAD_STATUS_ALL))
        self.navigation.append(FDModel("Downloading").add_artist("Downloading").add_status(DOWNLOAD_STATUS_DOWNLOADING))
        self.navigation.append(FDModel("Completed").add_artist("Completed").add_status(DOWNLOAD_STATUS_COMPLETED))
        self.navigation.append(FDModel("Active").add_artist("Active").add_status(DOWNLOAD_STATUS_ACTIVE))
        self.navigation.append(FDModel("Inactive").add_artist("Inactive").add_status(DOWNLOAD_STATUS_INACTIVE))
        
        self.dm_list = DownloadManagerTreeControl(self.navigation)
        self.navigation.dm_list = self.dm_list
        #paned.pack1(self.navigation.scroll)
        #paned.pack2(self.dm_list.scroll)
        playback = DMControls(self.controls, self.dm_list)
        
        vbox.pack_start(playback, False, True)
        #vbox.pack_start(paned, True, True)
        vbox.pack_start(self.dm_list.scroll, True, True)
                       
        self.add(vbox)
        thread.start_new_thread(self.dowloader, (self.dm_list,))
        
           
    def demo_tasks(self):
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        
        
    def show(self):
        self.show_all()
    
    def append_task(self, bean):
        bean.status = DOWNLOAD_STATUS_ACTIVE
        self.dm_list.append(bean)
    
    def append_tasks(self, beans):
        self.show()
        for bean in beans:
            self.append_task(bean)
    
    def dowloader(self, dm_list):
        semaphore = threading.Semaphore(5)
        while True:
            time.sleep(2)
            #self.navigation.use_filter()
            
            
            semaphore.acquire()
            bean = dm_list.get_next_bean_to_dowload()            
            if bean:
                if not bean.path:                 
                    vk = self.controls.vk_service.find_one_track(bean.get_display_name())
                    if not vk:
                        bean.status = DOWNLOAD_STATUS_ERROR
                        dm_list.update_bean_info(bean)
                        logging.debug("Source for song not found" + bean.text)
                        semaphore.release()
                        continue
                        
                    bean.path = vk.path
                         
                def notify_finish():
                    self.navigation.update_statistics()                    
                    semaphore.release()
                    
                thread = Dowloader(dm_list.update_bean_info, bean, notify_finish)                
                thread.start()
            else:
                time.sleep(1)
                semaphore.release()
Beispiel #4
0
class DM(ChildTopWindow):
    def __init__(self, controls):
        self.controls = controls
        ChildTopWindow.__init__(self, _("Download Manager"))
        self.set_resizable(True)
        self.set_default_size(900, 700)

        vbox = gtk.VBox(False, 0)
        #paned = gtk.HPaned()
        #paned.set_position(200)

        self.navigation = DMNavigationTreeControl()

        self.navigation.append(
            FDModel("All").add_artist("All").add_status(DOWNLOAD_STATUS_ALL))
        self.navigation.append(
            FDModel("Downloading").add_artist("Downloading").add_status(
                DOWNLOAD_STATUS_DOWNLOADING))
        self.navigation.append(
            FDModel("Completed").add_artist("Completed").add_status(
                DOWNLOAD_STATUS_COMPLETED))
        self.navigation.append(
            FDModel("Active").add_artist("Active").add_status(
                DOWNLOAD_STATUS_ACTIVE))
        self.navigation.append(
            FDModel("Inactive").add_artist("Inactive").add_status(
                DOWNLOAD_STATUS_INACTIVE))

        self.dm_list = DownloadManagerTreeControl(self.navigation)
        self.navigation.dm_list = self.dm_list
        #paned.pack1(self.navigation.scroll)
        #paned.pack2(self.dm_list.scroll)
        playback = DMControls(self.controls, self.dm_list)

        vbox.pack_start(playback, False, True)
        #vbox.pack_start(paned, True, True)
        vbox.pack_start(self.dm_list.scroll, True, True)

        self.add(vbox)
        thread.start_new_thread(self.dowloader, (self.dm_list, ))

    def demo_tasks(self):
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))

        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))

    def show(self):
        self.show_all()

    def append_task(self, bean, save_to=None):
        """download only remote files"""
        #if bean.path and not bean.path.startswith("http"):
        #    return

        bean.status = DOWNLOAD_STATUS_ACTIVE
        if save_to:
            bean.save_to = save_to

        self.dm_list.append(bean)
        logging.debug("Begin download %s" % bean)

    def append_tasks_with_dialog(self, beans):
        paths = directory_chooser_dialog(_("Choose Folder"), FC().last_dir)
        if paths:
            self.append_tasks(beans, paths[0])

    def append_tasks(self, beans, save_to=None):
        self.show()
        for bean in beans:
            self.append_task(bean, save_to)

    def dowloader(self, dm_list):
        semaphore = threading.Semaphore(FC().amount_dm_threads)
        while True:
            time.sleep(2)
            #self.navigation.use_filter()

            semaphore.acquire()
            bean = dm_list.get_next_bean_to_dowload()
            if bean:
                if not bean.path:
                    vk = self.controls.vk_service.find_one_track(
                        bean.get_display_name())
                    if not vk:
                        bean.status = DOWNLOAD_STATUS_ERROR
                        dm_list.update_bean_info(bean)
                        logging.debug("Source for song not found" + bean.text)
                        semaphore.release()
                        continue

                    bean.path = vk.path

                def notify_finish():
                    self.navigation.update_statistics()
                    semaphore.release()

                thread = Dowloader(dm_list.update_bean_info, bean,
                                   notify_finish)
                thread.start()
            else:
                time.sleep(1)
                semaphore.release()
Beispiel #5
0
class DM(ChildTopWindow):
    def __init__(self, controls):
        self.controls = controls        
        ChildTopWindow.__init__(self, _("Download Manager"))
        self.set_resizable(True)
        self.set_default_size(900, 700)
        
        vbox = gtk.VBox(False, 0)
        #paned = gtk.HPaned()
        #paned.set_position(200)
        
        self.navigation = DMNavigationTreeControl()
            
        self.navigation.append(FDModel("All").add_artist("All").add_status(DOWNLOAD_STATUS_ALL))
        self.navigation.append(FDModel("Downloading").add_artist("Downloading").add_status(DOWNLOAD_STATUS_DOWNLOADING))
        self.navigation.append(FDModel("Completed").add_artist("Completed").add_status(DOWNLOAD_STATUS_COMPLETED))
        self.navigation.append(FDModel("Active").add_artist("Active").add_status(DOWNLOAD_STATUS_ACTIVE))
        self.navigation.append(FDModel("Inactive").add_artist("Inactive").add_status(DOWNLOAD_STATUS_INACTIVE))
        
        self.dm_list = DownloadManagerTreeControl(self.navigation)
        self.navigation.dm_list = self.dm_list
        #paned.pack1(self.navigation.scroll)
        #paned.pack2(self.dm_list.scroll)
        playback = DMControls(self.controls, self.dm_list)
        
        vbox.pack_start(playback, False, True)
        #vbox.pack_start(paned, True, True)
        vbox.pack_start(self.dm_list.scroll, True, True)
                       
        self.add(vbox)
        thread.start_new_thread(self.dowloader, (self.dm_list,))
        
           
    def demo_tasks(self):
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        self.append_task(FModel("Madonna - Sorry"))
        self.append_task(FModel("Madonna - Frozen"))
        
        
    def show(self):
        self.show_all()
        analytics.action("DM");
    
    def append_task(self, bean, save_to=None):
        """download only remote files"""
        #if bean.path and not bean.path.startswith("http"):
        #    return 
          
        bean.status = DOWNLOAD_STATUS_ACTIVE
        if save_to:
            bean.save_to = save_to
            
        self.dm_list.append(bean)
        logging.debug("Begin download %s" % bean)
    
    def append_tasks_with_dialog(self, beans):
        paths = directory_chooser_dialog(_("Choose Folder"), FC().last_dir)
        if paths:
            self.append_tasks(beans, paths[0])
    
    def append_tasks(self, beans, save_to=None):
        self.show()
        for bean in beans:
            self.append_task(bean, save_to)
    
    def dowloader(self, dm_list):
        semaphore = threading.Semaphore(FC().amount_dm_threads)
        while True:
            time.sleep(3)
            #self.navigation.use_filter()
            semaphore.acquire()
            bean = dm_list.get_next_bean_to_dowload()            
            if bean:
                if not bean.path or not self.controls.check_path(bean.path):                
                    vk = self.controls.vk_service.find_one_track(bean.get_display_name())
                    if not vk:
                        bean.status = DOWNLOAD_STATUS_ERROR
                        dm_list.update_bean_info(bean)
                        logging.debug("Source for song not found" + bean.text)
                        semaphore.release()
                        continue
                        
                    bean.path = vk.path
                         
                def notify_finish():
                    self.navigation.update_statistics()                    
                    semaphore.release()
                    
                thread = Dowloader(dm_list.update_bean_info, bean, notify_finish)                
                thread.start()
            else:
                time.sleep(1)
                semaphore.release()