Exemplo n.º 1
0
 def save_window_state(self):
     """Save windows location and layout to config."""
     top = self.top_widget
     layout = {'window_position': top.get_position(),
               'window_size': top.get_size(),
               'hpaned_position': self.hpaned.get_position(),
               'info_expander': self.photo_info_expander.get_expanded(),}
     config.set('webilder.layout', layout)
     config.save_config()
Exemplo n.º 2
0
 def save_window_state(self):
     """Save windows location and layout to config."""
     top = self.top_widget
     layout = {
         'window_position': top.get_position(),
         'window_size': top.get_size(),
         'hpaned_position': self.hpaned.get_position(),
         'info_expander': self.photo_info_expander.get_expanded(),
     }
     config.set('webilder.layout', layout)
     config.save_config()
Exemplo n.º 3
0
    def timer_event(self, *_args):
        """Called on regular basis to check if it is time to download photos
        or change wallpaper."""
        try:
            reload_config()
            now = time.time()
            rotate_interval = (config.get('rotate.enabled')
                               and config.get('rotate.interval') * 60)
            autodownload_interval = (config.get('autodownload.enabled')
                                     and config.get('autodownload.interval') *
                                     3600)
            if rotate_interval:
                # check if we have to rotate
                if now - self.last_rotate >= rotate_interval:
                    print "Rotating..."
                    self.next_photo()

            if CHECK_FOR_UPDATES and now - self.last_version_check >= 8 * 3600:
                self.last_version_check = now
                response = VersionCheckerOpener().open(CHECK_URL)
                latest = response.readlines()
                response.close()
                if latest[0].strip() != __version__:
                    self.set_tooltip_announce(''.join(latest[1:]))
                else:
                    pass

            if autodownload_interval:
                if now - self.last_autodownload >= autodownload_interval:
                    print "Time to autodownload."
                    self.last_autodownload = now
                    self.leech_thread = threading.Thread(
                        target=downloader.download_all)
                    self.leech_thread.setDaemon(True)
                    self.leech_thread.start()
                    config.set('autodownload.last_time', now)
                    config.save_config()
        finally:
            return True  # pylint: disable=W0150
Exemplo n.º 4
0
    def timer_event(self, *_args):
        """Called on regular basis to check if it is time to download photos
        or change wallpaper."""
        try:
            reload_config()
            now = time.time()
            rotate_interval = (config.get('rotate.enabled') and
                               config.get('rotate.interval')*60)
            autodownload_interval = (config.get('autodownload.enabled') and
                                     config.get('autodownload.interval')*3600)
            if rotate_interval:
                # check if we have to rotate
                if now-self.last_rotate >= rotate_interval:
                    print "Rotating..."
                    self.next_photo()

            if CHECK_FOR_UPDATES and now-self.last_version_check >= 8*3600:
                self.last_version_check = now
                response = VersionCheckerOpener().open(CHECK_URL)
                latest = response.readlines()
                response.close()
                if latest[0].strip() != __version__:
                    self.set_tooltip_announce(''.join(latest[1:]))
                else:
                    pass

            if autodownload_interval:
                if now-self.last_autodownload >= autodownload_interval:
                    print "Time to autodownload."
                    self.last_autodownload = now
                    self.leech_thread = threading.Thread(
                        target=downloader.download_all)
                    self.leech_thread.setDaemon(True)
                    self.leech_thread.start()
                    config.set('autodownload.last_time', now)
                    config.save_config()
        finally:
            return True  # pylint: disable=W0150
Exemplo n.º 5
0
        if terminate():
            break
        try:
            image, metadata = photo['_plugin']['module'].process_photo(
                config, photo, memfile)
            save_photo(config, photo, image, metadata)
        except IOError, exc:
            print "IOError: ", str(exc)
        else:
            completed += 1

    stats = config.get('webilder.stats')
    stats['downloads'] += completed
    config.set('webilder.stats', stats)
    config.save_config()


import socket

socket.setdefaulttimeout(120)


def main():
    """Command line interface for photo downloader."""
    def notify(_fraction, status, message):
        """Called when the download logic wants to notify us."""
        print message, status

    download_all(notify)
Exemplo n.º 6
0
        if terminate():
            break
        try:
            image, metadata = photo['_plugin']['module'].process_photo(
                config, photo, memfile)
            save_photo(config, photo, image, metadata)
        except IOError, exc:
            print "IOError: ", str(exc)
        else:
            completed += 1

    stats = config.get('webilder.stats')
    stats['downloads'] += completed
    config.set('webilder.stats', stats)
    config.save_config()


import socket
socket.setdefaulttimeout(120)

def main():
    """Command line interface for photo downloader."""
    def notify(_fraction, status, message):
        """Called when the download logic wants to notify us."""
        print message, status
    download_all(notify)

if __name__ == "__main__":
    main()