示例#1
0
 def action(self):
     from miro.dl_daemon import download
     mark_reply = True
     for dlid, (cmd, args) in self.args[0].iteritems():
         if cmd == self.PAUSE:
             upload = args['upload']
             if upload:
                 download.pause_upload(dlid)
             else:
                 download.pause_download(dlid)
         elif cmd == self.STOP:
             upload = args['upload']
             if upload:
                 download.stop_upload(dlid)
             else:
                 download.stop_download(dlid, args['delete'])
         elif cmd == self.RESUME:
             channel_name = args['channel_name']
             url = args['url']
             content_type = args['content_type']
             download.start_download(url, dlid, content_type, channel_name)
         elif cmd == self.RESTORE:
             # Restoring a downloader doesn't actually change any state
             # so don't reply.
             mark_reply = False
             downloader = args['downloader']
             download.restore_downloader(downloader)
         else:
             raise ValueError('unknown downloader batch command %s' % cmd)
     # Mark this so that the next time we run through the periodic update
     # which will be after all the above have been processed because we
     # are in the same thread.
     if mark_reply:
         download.DOWNLOAD_UPDATER.set_cmds_done()
示例#2
0
文件: command.py 项目: nxmirrors/miro
 def action(self):
     from miro.dl_daemon import download
     return download.pause_download(*self.args, **self.kws)