Ejemplo n.º 1
0
 def run(self):
     prefs = Utility.loadPrefs(Globals.options).get(PLUGIN_NAME)
     if prefs is not None:
         license = prefs.get('license')
         if license:
             setLicense(license)
     return False  # no need to run again
Ejemplo n.º 2
0
 def run(self):
     prefs = Utility.loadPrefs(Globals.options).get(PLUGIN_NAME)
     if prefs is not None:
         license = prefs.get('license')
         if license:
             setLicense(license)
     return False # no need to run again
Ejemplo n.º 3
0
    def fillCollectionFromFlickr(self, view, n=16, apiKey=None):
        """
        Fills the collection with photos from the flickr website.
        """
        if apiKey:
            flickr.setLicense(apiKey)

        if self.userName:
            flickrUserName = flickr.people_findByUsername(
                self.userName.encode('utf8'))
            flickrPhotos = flickr.people_getPublicPhotos(flickrUserName.id, n)
        elif self.tag:
            flickrPhotos = flickr.photos_search(tags=self.tag,
                                                per_page=n,
                                                sort="date-posted-desc")
        else:
            assert (False, "we should have either a userName or tag")

        # flickrPhotosCollection is a collection of all FlickrPhotos. It has
        # an index named flickerIDIndex which indexes all the photos by
        # their flickrID which makes it easy to quickly lookup any photo by
        # index.
        flickrPhotosCollection = schema.ns('flickr',
                                           view).flickrPhotosCollection
        for flickrPhoto in flickrPhotos:
            """
            If we've already downloaded a photo with this id use it instead.
            """
            photoUUID = flickrPhotosCollection.findInIndex(
                'flickrIDIndex',  # name of Index
                'exact',  # require an exact match
                # compare function
                lambda uuid: cmp(flickrPhoto.id,
                                 view.findValue(uuid, 'flickrID')))

            if photoUUID is None:
                photoItem = FlickrPhoto(photo=flickrPhoto, itsView=view)
            else:
                photoItem = view[photoUUID]

            self.add(photoItem)

        view.commit()
Ejemplo n.º 4
0
    def fillCollectionFromFlickr(self, view, n=16, apiKey=None):
        """
        Fills the collection with photos from the flickr website.
        """
        if apiKey:
            flickr.setLicense(apiKey)

        if self.userName:
            flickrUserName = flickr.people_findByUsername(self.userName.encode('utf8'))
            flickrPhotos = flickr.people_getPublicPhotos(flickrUserName.id, n)
        elif self.tag:
            flickrPhotos = flickr.photos_search(tags=self.tag, per_page=n,
                                                sort="date-posted-desc")
        else:
            assert(False, "we should have either a userName or tag")

        # flickrPhotosCollection is a collection of all FlickrPhotos. It has
        # an index named flickerIDIndex which indexes all the photos by
        # their flickrID which makes it easy to quickly lookup any photo by
        # index.
        flickrPhotosCollection = schema.ns('flickr', view).flickrPhotosCollection
        for flickrPhoto in flickrPhotos:
            """
            If we've already downloaded a photo with this id use it instead.
            """
            photoUUID = flickrPhotosCollection.findInIndex(
                'flickrIDIndex', # name of Index
                'exact',         # require an exact match
                                 # compare function
                lambda uuid: cmp(flickrPhoto.id,
                                 view.findValue(uuid, 'flickrID')))

            if photoUUID is None:
                photoItem = FlickrPhoto(photo=flickrPhoto, itsView=view)
            else:
                photoItem = view[photoUUID]

            self.add(photoItem)

        view.commit()
Ejemplo n.º 5
0
def promptLicense():

    dialog = LicenseDialog(wx.GetApp().mainFrame, -1)
    dialog.CenterOnScreen()

    if dialog.ShowModal() == wx.ID_OK:
        params = dialog.getParameters()
    else:
        params = None

    dialog.Destroy()

    if params is not None:
        license = params['license']
        if license:
            prefs = Utility.loadPrefs(Globals.options)
            pluginPrefs = prefs.setdefault(PLUGIN_NAME, {})
            pluginPrefs['license'] = license
            prefs.write()
            setLicense(license)
            return True

    return False
Ejemplo n.º 6
0
def promptLicense():

    dialog = LicenseDialog(wx.GetApp().mainFrame, -1)
    dialog.CenterOnScreen()

    if dialog.ShowModal() == wx.ID_OK:
        params = dialog.getParameters()
    else:
        params = None

    dialog.Destroy()

    if params is not None:
        license = params['license']
        if license:
            prefs = Utility.loadPrefs(Globals.options)
            pluginPrefs = prefs.setdefault(PLUGIN_NAME, {})
            pluginPrefs['license'] = license
            prefs.write()
            setLicense(license)
            return True

    return False