예제 #1
0
 def OnTaskBarFlag(self, event):
     """Toggle config data and send metadata to server"""
     self._config["flagimage"] = not self._config["flagimage"]
     self._config.Save(self._twirlpath)
     netops.SendMetadata(
         consts.URL_SEND_META, {
             "username": self._config["username"].encode("utf-8"),
             "userhash": self._config["userhash"],
             "imageid": self._config["imageid"],
             "flagimage": self._config["flagimage"]
         })
예제 #2
0
 def OnTaskBarRate5Stars(self, event):
     """Set config data and send metadata to server"""
     self._config["userrating"] = 5
     self._config.Save(self._twirlpath)
     netops.SendMetadata(
         consts.URL_SEND_META, {
             "username": self._config["username"].encode("utf-8"),
             "userhash": self._config["userhash"],
             "imageid": self._config["imageid"],
             "imagerating": 5
         })
예제 #3
0
    def OnButtonOKButton(self):
        """Update and save config, send all metadata to server,
		then hide frame"""
        meta = {}
        for key in self._config.keys():
            if self._config[key] != self._configtmp[key]:
                meta[key] = self._configtmp[key]
        if meta:
            # Since if frame open, wallpaper downloads are delayed,
            # the image data is always valid
            self._config.update(self._configtmp)
            self._config.Save(self._twirlpath)
            meta.update({
                "username": self._config["username"].encode("utf-8"),
                "userhash": self._config["userhash"],
                "imageid": self._config["imageid"]
            })
            netops.SendMetadata(consts.URL_SEND_META, meta)
        self.Hide()
예제 #4
0
    def TimeCheck(self):
        """Check if the wait period has passed and update image,
		but hold off on update until GUI frame is closed so that user
		may complete any actions based on current image before image
		is changed, unless update initiated by used with New Wallpaper."""

        if time() > self._config['nextchange']\
         and not self._parent.frameops.IsShown():
            #and not self._parent.taskbarops.IsOpen:  	# DOESN'T WORK when taskbar menu
            # dismissed with outside click
            # Download new image to the executable's directory, and
            # name it image.bmp
            imagemeta = netops.SendMetadata(
                consts.URL_REQ_IMAGE, {
                    'username': self._config['username'].encode('utf-8'),
                    'userhash': self._config['userhash']
                })

            # Parse returned data
            try:
                self._config.update({
                    'imageid':
                    imagemeta['imageid'],
                    'imagerating':
                    int(imagemeta['imagerating']),
                    'userrating':
                    int(imagemeta['userrating']),
                    'imageinfo':
                    imagemeta['imageinfo'],
                    'imageurl':
                    imagemeta['imageurl']
                })
                imagedata = netops.DownloadImage(imagemeta['image'])

                # Display new image
                try:
                    DisplayImage(imagedata, self._twirlpath)
                except DisplayError:
                    #self._parent.msgpops.OnFrameShow('Image display failed.')

                    # Send error to server
                    netops.SendMetadata(
                        consts.URL_SEND_META, {
                            'username':
                            self._config['username'].encode('utf-8'),
                            'userhash': self._config['userhash'],
                            'err': 'disp'
                        })

            except:
                self._parent.msgpops.OnFrameShow(
                    'Image download failed.\n\n' +
                    'Please check your internet connection, or check the' +
                    'Twirlpaper.com website for more information.')
                # Send error to server
                netops.SendMetadata(
                    consts.URL_SEND_META, {
                        'username': self._config['username'].encode('utf-8'),
                        'userhash': self._config['userhash'],
                        'err': 'req'
                    })

            # Update change time
            self._config['nextchange'] = time() + self._config['changeevery']