Esempio n. 1
0
 def _init_fetch(self, tasks: dict, cancel_fetch: mp.Event):
     self.scanned_urls.clear()
     tasks.clear()
     cancel_fetch.clear()
     self.cancel_tasks.clear()
     self.settings = options.load_settings()
     self.cookie_jar = load_cookies(self.settings)
Esempio n. 2
0
 def create_profiles_submenu(self):
     # loop through any menus still attached and delete
     for profile in self._profile_ids:
         self.profiles_submenu.Delete(profile.id)
     # set the list to default and add 9999 as default ID
     self._profile_ids = [ProfileSubMenuItem(9999, "default")]
     # put the default at the top
     self.profiles_submenu.Append(self._profile_ids[-1].id,
                                  self._profile_ids[-1].name,
                                  kind=wx.ITEM_RADIO)
     self.profiles_submenu.Check(self._profile_ids[-1].id, True)
     self.parent.Bind(wx.EVT_MENU,
                      self._on_load_profile,
                      id=self._profile_ids[-1].id)
     profiles = load_profiles()
     for profile_index, profile_name in enumerate(profiles):
         if profile_name not in "default":
             self._profile_ids.append(
                 ProfileSubMenuItem(profile_index + 10000, profile_name))
             p = self._profile_ids[-1]
             self.profiles_submenu.Append(p.id, p.name, kind=wx.ITEM_RADIO)
             self.parent.Bind(wx.EVT_MENU, self._on_load_profile, id=p.id)
     settings = load_settings()
     selected_profile = list(
         filter(lambda p: p.name == settings["profile-name"],
                self._profile_ids))[0]
     self.profiles_submenu.Check(selected_profile.id, True)
Esempio n. 3
0
 def _init_start_tasks(self, tasks: dict):
     tasks.clear()
     self.blacklist.clear()
     self.settings = options.load_settings()
     self.cookie_jar = load_cookies(self.settings)
     self.filters = parsing.compile_filter_list(
         self.settings["filter-search"])
    def __init__(self, parent, id, dialog):
        super().__init__(parent=parent, id=id)

        self.dlg = dialog
        self.app = wx.GetApp()

        settings = options.load_settings()

        self.cmbox = wx.Choice(self, -1, choices=options.load_profiles())
        self.cmbox.SetStringSelection(settings["profile-name"])
        btn_new = wx.Button(self, -1, "New")
        btn_delete = wx.Button(self, -1, "Delete")

        vs = wx.StaticBoxSizer(wx.VERTICAL, self, "Profile")
        hs = wx.BoxSizer(wx.HORIZONTAL)
        hs.Add(self.cmbox, 1, wx.EXPAND | wx.ALL, 0)
        hs.AddSpacer(5)
        hs.Add(btn_delete, 0, wx.EXPAND | wx.ALL, 0)
        hs.AddSpacer(5)
        hs.Add(btn_new, 0, wx.EXPAND | wx.ALL, 0)
        vs.Add(hs, 1, wx.EXPAND | wx.ALL, 0)
        self.SetSizer(vs)

        btn_new.Bind(wx.EVT_BUTTON, self._on_new_profile, btn_new)
        btn_delete.Bind(wx.EVT_BUTTON, self._on_btn_delete, btn_delete)
        self.cmbox.Bind(wx.EVT_CHOICE, self._on_choice, self.cmbox)
Esempio n. 5
0
 def _create_status_bar(self):
     self.sbar = wx.StatusBar(parent=self, id=-1)
     font = self.sbar.GetFont()
     font.SetPointSize(10)
     self.sbar.SetFont(font)
     self.sbar.SetFieldsCount(2, [-2, -1])
     self.SetStatusBar(self.sbar)
     self.set_profile_status(options.load_settings()["profile-name"])
Esempio n. 6
0
 def _on_fetch_finished(self, msg: Message):
     urls_length = msg.data["length"]
     self.SetStatusText(f"{urls_length} Links found")
     # Set the progress bar maximum range
     self.dld_panel.progressbar.reset_progress(urls_length)
     self.detached_frame.reset(urls_length)
     # set Frame title from fetched Url title. similar to how a Browser behaves
     # we will use this to generate a unique folder name
     self.SetTitle(f'{msg.data["title"]} - Links found: {urls_length}')
     if urls_length > 0:
         self.dld_panel.treeview.Expand(
             self.dld_panel.treeview.GetRootItem())
         if options.load_settings()["auto-download"]:
             # start the download automatically no wait
             self.dld_panel.start_tasks()
Esempio n. 7
0
 def _on_settings(self, evt):
     dlg = SettingsDialog(parent=self.parent,
                          id=-1,
                          title="Settings",
                          size=wx.DefaultSize,
                          pos=wx.DefaultPosition,
                          style=wx.DEFAULT_DIALOG_STYLE,
                          name="settings_dialog",
                          settings=load_settings())
     dlg.CenterOnParent()
     if dlg.ShowModal() == wx.ID_OK:
         settings = dlg.get_settings()
         save_settings(settings)
         self.create_profiles_submenu()
     dlg.Destroy()
 def _on_btn_delete(self, evt):
     name = self.cmbox.GetStringSelection()
     try:
         if options.delete_profile(name):
             settings = options.load_settings()
             self.dlg.load_settings(settings)
             self.cmbox.Delete(self.cmbox.GetSelection())
             self.cmbox.SetStringSelection(settings["profile-name"])
     except NameError as err:
         dlg = wx.MessageDialog(self,
                                err.__str__(),
                                "Error",
                                style=wx.OK | wx.CENTER | wx.ICON_ERROR)
         dlg.ShowModal()
         dlg.Destroy()
Esempio n. 9
0
 def _on_scraping_complete(self):
     self.detached_frame.Hide()
     # play the notification sound if required
     if options.load_settings()["notify-done"]:
         self.app.sounds["complete"].Play()
         notify.NotificationBar(None,
                                -1,
                                "",
                                "PixGrabber has completed",
                                timeout=notify.NOTIFY_LONG)
     # kill the timer thread
     timer_quit.set()
     self.SetStatusText("All Tasks have completed")
     self.dld_panel.progressbar.reset_progress(0)
     self.dld_panel.addressbar.txt_address.SetValue("")
     self.dld_panel.enable_controls(True)
Esempio n. 10
0
    def message_from_thread(self, msg: Message):
        """Message from the background thread

        Args:
            msg (Message): is a Message object
                    Message: thread  (int): thread which sent the message
                             event   (int): the type of message
                             id      (int): this is only used if a task process has sent the message
                             status  (int): the status of the message either STATUS_OK, STATUS_ERROR or STATUS_IGNORED
                             data   (dict): extra information depending on the message event
        """
        if msg.thread == const.THREAD_COMMANDER:
            # MESSAGE
            if msg.event == const.EVENT_MESSAGE:
                self.SetStatusText(msg.data["message"])

            elif msg.event == const.EVENT_CANCEL:
                self.dld_panel.set_progress_indeterminate()
                self.SetStatusText("""Cancelling Tasks, Please wait...
                     This could take several seconds depending on the Connection timeout"""
                                   )

            elif msg.event == const.EVENT_PAUSE:
                pause = msg.data["pause"]
                if pause:
                    self.dld_panel.set_progress_indeterminate()
                    self.SetStatusText("Paused Tasks")
                else:
                    self.dld_panel.set_progress_determinate()
                    self.SetStatusText("Resuming...")

            # ALL TASKS COMPLETED
            elif msg.event == const.EVENT_COMPLETE:
                self._on_scraping_complete()

            elif msg.event == const.EVENT_FETCH:
                self.dld_panel.treeview.add_to_root(msg)

            elif msg.event == const.EVENT_FETCH_START:
                self._on_fetch_start(msg)

            elif msg.event == const.EVENT_FETCH_COMPLETE:
                timer_quit.set()
                self.dld_panel.addressbar.txt_address.SetValue("")
                self.dld_panel.progressbar.reset_progress(100)
                if msg.status == const.STATUS_OK:
                    self._on_fetch_finished(msg)
                elif msg.status == const.STATUS_ERROR:
                    self._on_fetch_error(msg)
                elif msg.status == const.STATUS_IGNORED:
                    self._on_fetch_ignored(msg)

            # TASKS HAVE BEEN CREATED AND ARE NOW SEARCHING
            elif msg.event == const.EVENT_START and msg.status == const.STATUS_OK:
                self._on_start_scraping()

        elif msg.thread == const.THREAD_TASK:
            # TASK HAS COMPLETED
            if msg.event == const.EVENT_FINISHED:
                self.dld_panel.progressbar.increment()
                self.dld_panel.treeview.child_complete(msg)
                self.detached_frame.add_progress()
            # IMAGE ERROR
            elif msg.event == const.EVENT_DOWNLOAD_IMAGE and msg.status == const.STATUS_ERROR:
                self.dld_panel.treeview.add_url(msg)
                self.dld_panel.errors.add_stat()
                self.detached_frame.add_error()
            # IMAGE SAVED
            elif msg.event == const.EVENT_DOWNLOAD_IMAGE and msg.status == const.STATUS_OK:
                self.dld_panel.imgsaved.add_stat()
                self.detached_frame.add_saved()
                self.dld_panel.treeview.add_url(msg)
            # IMAGE IGNORED
            elif msg.event == const.EVENT_DOWNLOAD_IMAGE and msg.status == const.STATUS_IGNORED:
                self.dld_panel.ignored.add_stat()
                self.dld_panel.treeview.add_url(msg)
                self.detached_frame.add_ignored()
            # TASK HAS STARTED
            elif msg.event == const.EVENT_SEARCHING and msg.status == const.STATUS_OK:
                self.dld_panel.treeview.set_searching(msg.id)
                # Detach Progress frame if option set
                if options.load_settings().get("detach-progress", True):
                    self.detached_frame.Show()
                else:
                    self.detached_frame.Hide()
Esempio n. 11
0
def _open_save_path():
    path = load_settings().get("save_path", "")
    if os.path.exists(path):
        webbrowser.open(path)
Esempio n. 12
0
 def _on_choice(self, evt):
     name = evt.GetString()
     options.use_profile(name)
     self.app.window.set_profile_status(name)
     self.dlg.load_settings(options.load_settings())