def _download(self, *e):
# If we're using threads, then delegate to the threaded
# downloader instead.
if self._use_threads:
return self._download_threaded(*e)
marked = [self._table[row, 'Identifier']
for row in range(len(self._table))
if self._table[row, 0] != '']
selection = self._table.selected_row()
if not marked and selection is not None:
marked = [self._table[selection, 'Identifier']]
download_iter = self._ds.incr_download(marked, self._ds.download_dir)
self._log_indent = 0
self._download_cb(download_iter, marked)
python类downloader()的实例源码
def _progress_alive(self):
c = self._progressbar
if not self._downloading:
c.itemconfig('gradient', state='hidden')
else:
c.itemconfig('gradient', state='normal')
x1, y1, x2, y2 = c.bbox('gradient')
if x1 <= -100:
c.move('gradient', (self._gradient_width*6)-4, 0)
else:
c.move('gradient', -4, 0)
afterid = self.top.after(200, self._progress_alive)
self._afterid['_progress_alive'] = afterid
#/////////////////////////////////////////////////////////////////
# Threaded downloader
#/////////////////////////////////////////////////////////////////
downloader.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 32
收藏 0
点赞 0
评论 0
def _download(self, *e):
# If we're using threads, then delegate to the threaded
# downloader instead.
if self._use_threads:
return self._download_threaded(*e)
marked = [self._table[row, 'Identifier']
for row in range(len(self._table))
if self._table[row, 0] != '']
selection = self._table.selected_row()
if not marked and selection is not None:
marked = [self._table[selection, 'Identifier']]
download_iter = self._ds.incr_download(marked, self._ds.download_dir)
self._log_indent = 0
self._download_cb(download_iter, marked)
downloader.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 43
收藏 0
点赞 0
评论 0
def _progress_alive(self):
c = self._progressbar
if not self._downloading:
c.itemconfig('gradient', state='hidden')
else:
c.itemconfig('gradient', state='normal')
x1, y1, x2, y2 = c.bbox('gradient')
if x1 <= -100:
c.move('gradient', (self._gradient_width*6)-4, 0)
else:
c.move('gradient', -4, 0)
afterid = self.top.after(200, self._progress_alive)
self._afterid['_progress_alive'] = afterid
#/////////////////////////////////////////////////////////////////
# Threaded downloader
#/////////////////////////////////////////////////////////////////
def _download(self, *e):
# If we're using threads, then delegate to the threaded
# downloader instead.
if self._use_threads:
return self._download_threaded(*e)
marked = [self._table[row, 'Identifier']
for row in range(len(self._table))
if self._table[row, 0] != '']
selection = self._table.selected_row()
if not marked and selection is not None:
marked = [self._table[selection, 'Identifier']]
download_iter = self._ds.incr_download(marked, self._ds.download_dir)
self._log_indent = 0
self._download_cb(download_iter, marked)
def _progress_alive(self):
c = self._progressbar
if not self._downloading:
c.itemconfig('gradient', state='hidden')
else:
c.itemconfig('gradient', state='normal')
x1, y1, x2, y2 = c.bbox('gradient')
if x1 <= -100:
c.move('gradient', (self._gradient_width*6)-4, 0)
else:
c.move('gradient', -4, 0)
afterid = self.top.after(200, self._progress_alive)
self._afterid['_progress_alive'] = afterid
#/////////////////////////////////////////////////////////////////
# Threaded downloader
#/////////////////////////////////////////////////////////////////
def _download(self, *e):
# If we're using threads, then delegate to the threaded
# downloader instead.
if self._use_threads:
return self._download_threaded(*e)
marked = [self._table[row, 'Identifier']
for row in range(len(self._table))
if self._table[row, 0] != '']
selection = self._table.selected_row()
if not marked and selection is not None:
marked = [self._table[selection, 'Identifier']]
download_iter = self._ds.incr_download(marked, self._ds.download_dir)
self._log_indent = 0
self._download_cb(download_iter, marked)
def _progress_alive(self):
c = self._progressbar
if not self._downloading:
c.itemconfig('gradient', state='hidden')
else:
c.itemconfig('gradient', state='normal')
x1, y1, x2, y2 = c.bbox('gradient')
if x1 <= -100:
c.move('gradient', (self._gradient_width*6)-4, 0)
else:
c.move('gradient', -4, 0)
afterid = self.top.after(200, self._progress_alive)
self._afterid['_progress_alive'] = afterid
#/////////////////////////////////////////////////////////////////
# Threaded downloader
#/////////////////////////////////////////////////////////////////
def _download(self, *e):
# If we're using threads, then delegate to the threaded
# downloader instead.
if self._use_threads:
return self._download_threaded(*e)
marked = [self._table[row, 'Identifier']
for row in range(len(self._table))
if self._table[row, 0] != '']
selection = self._table.selected_row()
if not marked and selection is not None:
marked = [self._table[selection, 'Identifier']]
download_iter = self._ds.incr_download(marked, self._ds.download_dir)
self._log_indent = 0
self._download_cb(download_iter, marked)
def _progress_alive(self):
c = self._progressbar
if not self._downloading:
c.itemconfig('gradient', state='hidden')
else:
c.itemconfig('gradient', state='normal')
x1, y1, x2, y2 = c.bbox('gradient')
if x1 <= -100:
c.move('gradient', (self._gradient_width*6)-4, 0)
else:
c.move('gradient', -4, 0)
afterid = self.top.after(200, self._progress_alive)
self._afterid['_progress_alive'] = afterid
#/////////////////////////////////////////////////////////////////
# Threaded downloader
#/////////////////////////////////////////////////////////////////
def _download(self, *e):
# If we're using threads, then delegate to the threaded
# downloader instead.
if self._use_threads:
return self._download_threaded(*e)
marked = [self._table[row, 'Identifier']
for row in range(len(self._table))
if self._table[row, 0] != '']
selection = self._table.selected_row()
if not marked and selection is not None:
marked = [self._table[selection, 'Identifier']]
download_iter = self._ds.incr_download(marked, self._ds.download_dir)
self._log_indent = 0
self._download_cb(download_iter, marked)
def _progress_alive(self):
c = self._progressbar
if not self._downloading:
c.itemconfig('gradient', state='hidden')
else:
c.itemconfig('gradient', state='normal')
x1, y1, x2, y2 = c.bbox('gradient')
if x1 <= -100:
c.move('gradient', (self._gradient_width*6)-4, 0)
else:
c.move('gradient', -4, 0)
afterid = self.top.after(200, self._progress_alive)
self._afterid['_progress_alive'] = afterid
#/////////////////////////////////////////////////////////////////
# Threaded downloader
#/////////////////////////////////////////////////////////////////
def _download(self, *e):
# If we're using threads, then delegate to the threaded
# downloader instead.
if self._use_threads:
return self._download_threaded(*e)
marked = [self._table[row, 'Identifier']
for row in range(len(self._table))
if self._table[row, 0] != '']
selection = self._table.selected_row()
if not marked and selection is not None:
marked = [self._table[selection, 'Identifier']]
download_iter = self._ds.incr_download(marked, self._ds.download_dir)
self._log_indent = 0
self._download_cb(download_iter, marked)
def _progress_alive(self):
c = self._progressbar
if not self._downloading:
c.itemconfig('gradient', state='hidden')
else:
c.itemconfig('gradient', state='normal')
x1, y1, x2, y2 = c.bbox('gradient')
if x1 <= -100:
c.move('gradient', (self._gradient_width*6)-4, 0)
else:
c.move('gradient', -4, 0)
afterid = self.top.after(200, self._progress_alive)
self._afterid['_progress_alive'] = afterid
#/////////////////////////////////////////////////////////////////
# Threaded downloader
#/////////////////////////////////////////////////////////////////
def _download(self, *e):
# If we're using threads, then delegate to the threaded
# downloader instead.
if self._use_threads:
return self._download_threaded(*e)
marked = [self._table[row, 'Identifier']
for row in range(len(self._table))
if self._table[row, 0] != '']
selection = self._table.selected_row()
if not marked and selection is not None:
marked = [self._table[selection, 'Identifier']]
download_iter = self._ds.incr_download(marked, self._ds.download_dir)
self._log_indent = 0
self._download_cb(download_iter, marked)
def _progress_alive(self):
c = self._progressbar
if not self._downloading:
c.itemconfig('gradient', state='hidden')
else:
c.itemconfig('gradient', state='normal')
x1, y1, x2, y2 = c.bbox('gradient')
if x1 <= -100:
c.move('gradient', (self._gradient_width*6)-4, 0)
else:
c.move('gradient', -4, 0)
afterid = self.top.after(200, self._progress_alive)
self._afterid['_progress_alive'] = afterid
#/////////////////////////////////////////////////////////////////
# Threaded downloader
#/////////////////////////////////////////////////////////////////
def _info_or_id(self, info_or_id):
if isinstance(info_or_id, compat.string_types):
return self.info(info_or_id)
else:
return info_or_id
# [xx] When during downloading is it 'safe' to abort? Only unsafe
# time is *during* an unzip -- we don't want to leave a
# partially-unzipped corpus in place because we wouldn't notice
# it. But if we had the exact total size of the unzipped corpus,
# then that would be fine. Then we could abort anytime we want!
# So this is really what we should do. That way the threaded
# downloader in the gui can just kill the download thread anytime
# it wants.
downloader.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 48
收藏 0
点赞 0
评论 0
def _info_or_id(self, info_or_id):
if isinstance(info_or_id, compat.string_types):
return self.info(info_or_id)
else:
return info_or_id
# [xx] When during downloading is it 'safe' to abort? Only unsafe
# time is *during* an unzip -- we don't want to leave a
# partially-unzipped corpus in place because we wouldn't notice
# it. But if we had the exact total size of the unzipped corpus,
# then that would be fine. Then we could abort anytime we want!
# So this is really what we should do. That way the threaded
# downloader in the gui can just kill the download thread anytime
# it wants.
def _info_or_id(self, info_or_id):
if isinstance(info_or_id, compat.string_types):
return self.info(info_or_id)
else:
return info_or_id
# [xx] When during downloading is it 'safe' to abort? Only unsafe
# time is *during* an unzip -- we don't want to leave a
# partially-unzipped corpus in place because we wouldn't notice
# it. But if we had the exact total size of the unzipped corpus,
# then that would be fine. Then we could abort anytime we want!
# So this is really what we should do. That way the threaded
# downloader in the gui can just kill the download thread anytime
# it wants.
def _info_or_id(self, info_or_id):
if isinstance(info_or_id, compat.string_types):
return self.info(info_or_id)
else:
return info_or_id
# [xx] When during downloading is it 'safe' to abort? Only unsafe
# time is *during* an unzip -- we don't want to leave a
# partially-unzipped corpus in place because we wouldn't notice
# it. But if we had the exact total size of the unzipped corpus,
# then that would be fine. Then we could abort anytime we want!
# So this is really what we should do. That way the threaded
# downloader in the gui can just kill the download thread anytime
# it wants.
def _info_or_id(self, info_or_id):
if isinstance(info_or_id, compat.string_types):
return self.info(info_or_id)
else:
return info_or_id
# [xx] When during downloading is it 'safe' to abort? Only unsafe
# time is *during* an unzip -- we don't want to leave a
# partially-unzipped corpus in place because we wouldn't notice
# it. But if we had the exact total size of the unzipped corpus,
# then that would be fine. Then we could abort anytime we want!
# So this is really what we should do. That way the threaded
# downloader in the gui can just kill the download thread anytime
# it wants.
def _info_or_id(self, info_or_id):
if isinstance(info_or_id, compat.string_types):
return self.info(info_or_id)
else:
return info_or_id
# [xx] When during downloading is it 'safe' to abort? Only unsafe
# time is *during* an unzip -- we don't want to leave a
# partially-unzipped corpus in place because we wouldn't notice
# it. But if we had the exact total size of the unzipped corpus,
# then that would be fine. Then we could abort anytime we want!
# So this is really what we should do. That way the threaded
# downloader in the gui can just kill the download thread anytime
# it wants.
def _info_or_id(self, info_or_id):
if isinstance(info_or_id, compat.string_types):
return self.info(info_or_id)
else:
return info_or_id
# [xx] When during downloading is it 'safe' to abort? Only unsafe
# time is *during* an unzip -- we don't want to leave a
# partially-unzipped corpus in place because we wouldn't notice
# it. But if we had the exact total size of the unzipped corpus,
# then that would be fine. Then we could abort anytime we want!
# So this is really what we should do. That way the threaded
# downloader in the gui can just kill the download thread anytime
# it wants.
def _info_or_id(self, info_or_id):
if isinstance(info_or_id, compat.string_types):
return self.info(info_or_id)
else:
return info_or_id
# [xx] When during downloading is it 'safe' to abort? Only unsafe
# time is *during* an unzip -- we don't want to leave a
# partially-unzipped corpus in place because we wouldn't notice
# it. But if we had the exact total size of the unzipped corpus,
# then that would be fine. Then we could abort anytime we want!
# So this is really what we should do. That way the threaded
# downloader in the gui can just kill the download thread anytime
# it wants.
def __init__(self, dataserver, use_threads=True):
self._ds = dataserver
self._use_threads = use_threads
# For the threaded downloader:
self._download_lock = threading.Lock()
self._download_msg_queue = []
self._download_abort_queue = []
self._downloading = False
# For tkinter after callbacks:
self._afterid = {}
# A message log.
self._log_messages = []
self._log_indent = 0
self._log('NLTK Downloader Started!')
# Create the main window.
top = self.top = Tk()
top.geometry('+50+50')
top.title('NLTK Downloader')
top.configure(background=self._BACKDROP_COLOR[1])
# Set up some bindings now, in case anything goes wrong.
top.bind('<Control-q>', self.destroy)
top.bind('<Control-x>', self.destroy)
self._destroyed = False
self._column_vars = {}
# Initialize the GUI.
self._init_widgets()
self._init_menu()
try:
self._fill_table()
except compat.HTTPError as e:
showerror('Error reading from server', e)
except compat.URLError as e:
showerror('Error connecting to server', e.reason)
self._show_info()
self._select_columns()
self._table.select(0)
# Make sure we get notified when we're destroyed, so we can
# cancel any download in progress.
self._table.bind('<Destroy>', self._destroy)
downloader.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 28
收藏 0
点赞 0
评论 0
def __init__(self, dataserver, use_threads=True):
self._ds = dataserver
self._use_threads = use_threads
# For the threaded downloader:
self._download_lock = threading.Lock()
self._download_msg_queue = []
self._download_abort_queue = []
self._downloading = False
# For tkinter after callbacks:
self._afterid = {}
# A message log.
self._log_messages = []
self._log_indent = 0
self._log('NLTK Downloader Started!')
# Create the main window.
top = self.top = Tk()
top.geometry('+50+50')
top.title('NLTK Downloader')
top.configure(background=self._BACKDROP_COLOR[1])
# Set up some bindings now, in case anything goes wrong.
top.bind('<Control-q>', self.destroy)
top.bind('<Control-x>', self.destroy)
self._destroyed = False
self._column_vars = {}
# Initialize the GUI.
self._init_widgets()
self._init_menu()
try:
self._fill_table()
except compat.HTTPError as e:
showerror('Error reading from server', e)
except compat.URLError as e:
showerror('Error connecting to server', e.reason)
self._show_info()
self._select_columns()
self._table.select(0)
# Make sure we get notified when we're destroyed, so we can
# cancel any download in progress.
self._table.bind('<Destroy>', self._destroy)
def __init__(self, dataserver, use_threads=True):
self._ds = dataserver
self._use_threads = use_threads
# For the threaded downloader:
self._download_lock = threading.Lock()
self._download_msg_queue = []
self._download_abort_queue = []
self._downloading = False
# For tkinter after callbacks:
self._afterid = {}
# A message log.
self._log_messages = []
self._log_indent = 0
self._log('NLTK Downloader Started!')
# Create the main window.
top = self.top = Tk()
top.geometry('+50+50')
top.title('NLTK Downloader')
top.configure(background=self._BACKDROP_COLOR[1])
# Set up some bindings now, in case anything goes wrong.
top.bind('<Control-q>', self.destroy)
top.bind('<Control-x>', self.destroy)
self._destroyed = False
self._column_vars = {}
# Initialize the GUI.
self._init_widgets()
self._init_menu()
try:
self._fill_table()
except compat.HTTPError as e:
showerror('Error reading from server', e)
except compat.URLError as e:
showerror('Error connecting to server', e.reason)
self._show_info()
self._select_columns()
self._table.select(0)
# Make sure we get notified when we're destroyed, so we can
# cancel any download in progress.
self._table.bind('<Destroy>', self._destroy)
def __init__(self, dataserver, use_threads=True):
self._ds = dataserver
self._use_threads = use_threads
# For the threaded downloader:
self._download_lock = threading.Lock()
self._download_msg_queue = []
self._download_abort_queue = []
self._downloading = False
# For tkinter after callbacks:
self._afterid = {}
# A message log.
self._log_messages = []
self._log_indent = 0
self._log('NLTK Downloader Started!')
# Create the main window.
top = self.top = Tk()
top.geometry('+50+50')
top.title('NLTK Downloader')
top.configure(background=self._BACKDROP_COLOR[1])
# Set up some bindings now, in case anything goes wrong.
top.bind('<Control-q>', self.destroy)
top.bind('<Control-x>', self.destroy)
self._destroyed = False
self._column_vars = {}
# Initialize the GUI.
self._init_widgets()
self._init_menu()
try:
self._fill_table()
except compat.HTTPError as e:
showerror('Error reading from server', e)
except compat.URLError as e:
showerror('Error connecting to server', e.reason)
self._show_info()
self._select_columns()
self._table.select(0)
# Make sure we get notified when we're destroyed, so we can
# cancel any download in progress.
self._table.bind('<Destroy>', self._destroy)
def __init__(self, dataserver, use_threads=True):
self._ds = dataserver
self._use_threads = use_threads
# For the threaded downloader:
self._download_lock = threading.Lock()
self._download_msg_queue = []
self._download_abort_queue = []
self._downloading = False
# For tkinter after callbacks:
self._afterid = {}
# A message log.
self._log_messages = []
self._log_indent = 0
self._log('NLTK Downloader Started!')
# Create the main window.
top = self.top = Tk()
top.geometry('+50+50')
top.title('NLTK Downloader')
top.configure(background=self._BACKDROP_COLOR[1])
# Set up some bindings now, in case anything goes wrong.
top.bind('<Control-q>', self.destroy)
top.bind('<Control-x>', self.destroy)
self._destroyed = False
self._column_vars = {}
# Initialize the GUI.
self._init_widgets()
self._init_menu()
try:
self._fill_table()
except compat.HTTPError as e:
showerror('Error reading from server', e)
except compat.URLError as e:
showerror('Error connecting to server', e.reason)
self._show_info()
self._select_columns()
self._table.select(0)
# Make sure we get notified when we're destroyed, so we can
# cancel any download in progress.
self._table.bind('<Destroy>', self._destroy)
def __init__(self, dataserver, use_threads=True):
self._ds = dataserver
self._use_threads = use_threads
# For the threaded downloader:
self._download_lock = threading.Lock()
self._download_msg_queue = []
self._download_abort_queue = []
self._downloading = False
# For tkinter after callbacks:
self._afterid = {}
# A message log.
self._log_messages = []
self._log_indent = 0
self._log('NLTK Downloader Started!')
# Create the main window.
top = self.top = Tk()
top.geometry('+50+50')
top.title('NLTK Downloader')
top.configure(background=self._BACKDROP_COLOR[1])
# Set up some bindings now, in case anything goes wrong.
top.bind('<Control-q>', self.destroy)
top.bind('<Control-x>', self.destroy)
self._destroyed = False
self._column_vars = {}
# Initialize the GUI.
self._init_widgets()
self._init_menu()
try:
self._fill_table()
except compat.HTTPError as e:
showerror('Error reading from server', e)
except compat.URLError as e:
showerror('Error connecting to server', e.reason)
self._show_info()
self._select_columns()
self._table.select(0)
# Make sure we get notified when we're destroyed, so we can
# cancel any download in progress.
self._table.bind('<Destroy>', self._destroy)