def fetch(self):
        SupportTeam.notify("polling for new media #%s..." % self.hashtag)
        latest_media_id = self.media_repository.latest_media_id()
        recent_media = self.api.tag_recent_media(5, latest_media_id, self.hashtag)

        for instagram_media in recent_media[0]:
            if not self.media_repository.has_media_with_id(instagram_media.id):
                media = Media(
                    id=instagram_media.id, url=str(instagram_media.images["standard_resolution"].url), status="new"
                )
                SupportTeam.notify("%s - new media %s" % (media.id, media.url))
                self.media_repository.create(media)
Beispiel #2
0
    def fetch(self):
        SupportTeam.notify("polling for new media #%s..." % self.hashtag)
        latest_media_id = self.media_repository.latest_media_id()
        recent_media = self.api.tag_recent_media(5, latest_media_id,
                                                 self.hashtag)

        for instagram_media in recent_media[0]:
            if not self.media_repository.has_media_with_id(instagram_media.id):
                media = Media(
                    id=instagram_media.id,
                    url=str(instagram_media.images['standard_resolution'].url),
                    status="new")
                SupportTeam.notify("%s - new media %s" % (media.id, media.url))
                self.media_repository.create(media)
    def send(self, image):
        SupportTeam.notify("%s - cancelling all jobs" % image.media.id)
        self.cancel_all_jobs()

        SupportTeam.notify("%s - turning printer off (5 secs)" % image.media.id)
        self.power.turn_off()
        time.sleep(5)

        SupportTeam.notify("%s - turning printer on (15 secs)" % image.media.id)
        self.power.turn_on()
        time.sleep(15)

        # it takes about a minute to print an image. 1.5 mins is conservative.
        SupportTeam.notify("%s - sent to printer, waiting to print (90 secs)" % image.media.id)
        self.send_file_to_printer(image)
        time.sleep(90)
Beispiel #4
0
    def send(self, image):
        SupportTeam.notify("%s - cancelling all jobs" % image.media.id)
        self.cancel_all_jobs()

        SupportTeam.notify("%s - turning printer off (5 secs)" %
                           image.media.id)
        self.power.turn_off()
        time.sleep(5)

        SupportTeam.notify("%s - turning printer on (15 secs)" %
                           image.media.id)
        self.power.turn_on()
        time.sleep(15)

        # it takes about a minute to print an image. 1.5 mins is conservative.
        SupportTeam.notify("%s - sent to printer, waiting to print (90 secs)" %
                           image.media.id)
        self.send_file_to_printer(image)
        time.sleep(90)
Beispiel #5
0
 def download(self):
     check_call(["rm", "-rf", "/tmp/image-downloading.jpg"])
     check_call(["wget", self.url, "--quiet", "-O", "/tmp/image-downloading.jpg"])
     check_call(["cp", "-f", "/tmp/image-downloading.jpg", "/tmp/image.jpg"])
     SupportTeam.notify("%s - downloaded to /tmp/image.jpg" % self.id)
     return FileSystemImage(self, "/tmp/image.jpg")