コード例 #1
0
    def _get_poa(self, tdef):
        """Try to load a POA - possibly trigger a GUI-thing or should the plugin handle getting it if none is already available?"""

        from BaseLib.Core.ClosedSwarm import ClosedSwarm, PaymentIntegration

        try:
            poa = ClosedSwarm.trivial_get_poa(self.s.get_default_state_dir(),
                                              self.s.get_permid(),
                                              tdef.infohash)

            poa.verify()
            if not poa.torrent_id == tdef.infohash:
                raise Exception("Bad POA - wrong infohash")
            print >> sys.stderr, "Loaded poa from ", self.s.get_default_state_dir(
            )
        except:
            # Try to get it or just let the plugin handle it?
            swarm_id = encodestring(tdef.infohash).replace("\n", "")
            my_id = encodestring(self.s.get_permid()).replace("\n", "")
            poa = PaymentIntegration.wx_get_poa(
                "http://seer2.itek.norut.no:9090",
                swarm_id,
                my_id,
                swarm_title=tdef.get_name())

        try:
            ClosedSwarm.trivial_save_poa(self.s.get_default_state_dir(),
                                         self.s.get_permid(), tdef.infohash,
                                         poa)
        except Exception, e:
            print >> sys.stderr, "Failed to save POA", e
コード例 #2
0
    def _get_poa(self, tdef):
        """Try to load a POA - possibly trigger a GUI-thing or should the plugin handle getting it if none is already available?"""

        from BaseLib.Core.ClosedSwarm import ClosedSwarm, PaymentIntegration

        try:
            poa = ClosedSwarm.trivial_get_poa(self.s.get_default_state_dir(), self.s.get_permid(), tdef.infohash)

            poa.verify()
            if not poa.torrent_id == tdef.infohash:
                raise Exception("Bad POA - wrong infohash")
            print >>sys.stderr, "Loaded poa from ", self.s.get_default_state_dir()
        except:
            # Try to get it or just let the plugin handle it?
            swarm_id = encodestring(tdef.infohash).replace("\n", "")
            my_id = encodestring(self.s.get_permid()).replace("\n", "")
            poa = PaymentIntegration.wx_get_poa(
                "http://seer2.itek.norut.no:9090", swarm_id, my_id, swarm_title=tdef.get_name()
            )

        try:
            ClosedSwarm.trivial_save_poa(self.s.get_default_state_dir(), self.s.get_permid(), tdef.infohash, poa)
        except Exception, e:
            print >>sys.stderr, "Failed to save POA", e