コード例 #1
0
ファイル: home.py プロジェクト: ebcabaybay/swiftarm
    def _showInspectionTool(self):
        import wx.lib.inspection
        itool = wx.lib.inspection.InspectionTool()
        itool.Show()
        try:
            frame = itool._frame

            import Tribler
            frame.locals['Tribler'] = Tribler

            from Tribler.Core.Overlay.SecureOverlay import SecureOverlay
            overlay = SecureOverlay.getInstance()
            frame.locals['overlay'] = overlay

            session = Session.get_instance()
            frame.locals['session'] = session

            from Tribler.Core.BuddyCast.buddycast import BuddyCastFactory
            channelcast = BuddyCastFactory.getInstance().channelcast_core
            frame.locals['channelcast'] = channelcast

            frame.locals['dispersy'] = Dispersy.get_instance()

        except Exception:
            import traceback
            traceback.print_exc()
コード例 #2
0
ファイル: home.py プロジェクト: ebcayabyab-personal/swiftarm
    def _showInspectionTool(self):
        import wx.lib.inspection
        itool = wx.lib.inspection.InspectionTool()
        itool.Show()
        try:
            frame = itool._frame

            import Tribler
            frame.locals['Tribler'] = Tribler

            from Tribler.Core.Overlay.SecureOverlay import SecureOverlay
            overlay = SecureOverlay.getInstance()
            frame.locals['overlay'] = overlay

            session = Session.get_instance()
            frame.locals['session'] = session

            from Tribler.Core.BuddyCast.buddycast import BuddyCastFactory
            channelcast = BuddyCastFactory.getInstance().channelcast_core
            frame.locals['channelcast'] = channelcast

            frame.locals['dispersy'] = Dispersy.get_instance()

        except Exception:
            import traceback
            traceback.print_exc()
コード例 #3
0
ファイル: home.py プロジェクト: ebcayabyab-personal/swiftarm
    def __init__(self, parent):
        self.buildColumns = False
        self.dispersy = Dispersy.get_instance()
        HomePanel.__init__(self, parent, 'Dispersy info' , LIST_BLUE)

        self.SetMinSize((-1, 200))

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self._onTimer, self.timer)
        self.timer.Start(5000, False)
        self.UpdateStats()

        self.mapping = {"total_down":[("Down", lambda info: self.utility.size_format(info["total_down"])),
                                      ("Down avg", lambda info: self.utility.size_format(int(info["total_down"] / info["runtime"])) + "/s")],
                        "total_up":[("Up", lambda info: self.utility.size_format(info["total_up"])),
                                    ("Up avg", lambda info: self.utility.size_format(int(info["total_up"] / info["runtime"])) + "/s")],
                        "drop":[("Dropped", lambda info: "%s ~%.1f%%" % (self.utility.size_format(int(sum(byte_count for _, byte_count in info["drop"].itervalues()))), (100.0 * sum(byte_count for _, byte_count in info["drop"].itervalues()) / info["total_down"]) if info["total_down"] else 0.0))],
                        "walk_success":[("Walker success", lambda info: "%d / %d ~%.1f%%" % (info["walk_success"], info["walk_attempt"], (100.0 * info["walk_success"] / info["walk_attempt"]) if info["walk_attempt"] else 0.0))],
                        "walk_reset":[("Walker resets", lambda info: str(info["walk_reset"]))],
                        "wan_address":[("Address wan", lambda info: "%s:%d" % info["wan_address"])],
                        "lan_address":[("Address lan", lambda info: "%s:%d" % info["lan_address"])],
                        "runtime":[("Runtime", lambda info: self.utility.eta_value(info["runtime"]))],
                        "walk_attempt":[],
                        "outgoing":[],
                        "timestamp":[],
                        "class":[],
                        "success":[],
                        "delay":[],
                        "version":[],
                        "communities":[],
                        "sequence_number":[],
                        "start":[],
                        "walk_fail":[],
                        "attachment":[]}
コード例 #4
0
ファイル: script.py プロジェクト: ebcabaybay/swiftarm
 def execute_scenario_cmds(self, commands):
     torrents = []
     
     for command in commands:
         cur_command = command.split()
     
         if cur_command[0] == 'create':
             log(self._logfile, "creating-community")
             self.my_channel = ChannelCommunity.create_community(self.my_member, integrate_with_tribler = False)
             
             log(self._logfile, "creating-channel-message")
             self.my_channel.create_channel(u'', u'')
         
         elif cur_command[0] == 'publish':
             if self.my_channel:
                 infohash = str(self.torrentindex)
                 infohash += ''.join(choice(letters) for _ in xrange(20-len(infohash)))
                 
                 name = u''.join(choice(letters) for _ in xrange(100))
                 files = []
                 for _ in range(10):
                     files.append((u''.join(choice(letters) for _ in xrange(30)), 123455))
                 
                 trackers = []
                 for _ in range(10):
                     trackers.append(''.join(choice(letters) for _ in xrange(30))) 
                 
                 files = tuple(files)
                 trackers = tuple(trackers)
                 
                 self.torrentindex += 1
                 torrents.append((infohash, int(time()), name, files, trackers))
         
         elif cur_command[0] == 'post':
             if self.joined_community:
                 text = ''.join(choice(letters) for i in xrange(160))
                 self.joined_community._disp_create_comment(text, int(time()), None, None, None, None)
             
         elif cur_command[0] == 'join':
             self.want_to_join = True
             
     if self.want_to_join:
         from Tribler.dispersy.dispersy import Dispersy
         dispersy = Dispersy.get_instance()
         
         log(self._logfile, "trying-to-join-community")
         
         for community in dispersy.get_communities():
             if isinstance(community, PreviewChannelCommunity) and community._channel_id:
                 self._community.disp_create_votecast(community.cid, 2, int(time()))
                 
                 log(self._logfile, "joining-community")
                 self.joined_community = community
                 
                 self.want_to_join = False
                 break
             
     if len(torrents) > 0:
         log(self._logfile, "creating-torrents")
         self.my_channel._disp_create_torrents(torrents)
コード例 #5
0
ファイル: home.py プロジェクト: ebcabaybay/swiftarm
    def __init__(self, parent):
        self.buildColumns = False
        self.dispersy = Dispersy.get_instance()
        HomePanel.__init__(self, parent, 'Dispersy info', LIST_BLUE)

        self.SetMinSize((-1, 200))

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self._onTimer, self.timer)
        self.timer.Start(5000, False)
        self.UpdateStats()

        self.mapping = {
            "total_down":
            [("Down",
              lambda info: self.utility.size_format(info["total_down"])),
             ("Down avg", lambda info: self.utility.size_format(
                 int(info["total_down"] / info["runtime"])) + "/s")],
            "total_up":
            [("Up", lambda info: self.utility.size_format(info["total_up"])),
             ("Up avg", lambda info: self.utility.size_format(
                 int(info["total_up"] / info["runtime"])) + "/s")],
            "drop":
            [("Dropped", lambda info: "%s ~%.1f%%" %
              (self.utility.size_format(
                  int(
                      sum(byte_count
                          for _, byte_count in info["drop"].itervalues()))),
               (100.0 * sum(byte_count for _, byte_count in info["drop"].
                            itervalues()) / info["total_down"])
               if info["total_down"] else 0.0))],
            "walk_success":
            [("Walker success", lambda info: "%d / %d ~%.1f%%" %
              (info["walk_success"], info["walk_attempt"],
               (100.0 * info["walk_success"] / info["walk_attempt"])
               if info["walk_attempt"] else 0.0))],
            "walk_reset": [("Walker resets",
                            lambda info: str(info["walk_reset"]))],
            "wan_address": [("Address wan",
                             lambda info: "%s:%d" % info["wan_address"])],
            "lan_address": [("Address lan",
                             lambda info: "%s:%d" % info["lan_address"])],
            "runtime": [("Runtime",
                         lambda info: self.utility.eta_value(info["runtime"]))
                        ],
            "walk_attempt": [],
            "outgoing": [],
            "timestamp": [],
            "class": [],
            "success": [],
            "delay": [],
            "version": [],
            "communities": [],
            "sequence_number": [],
            "start": [],
            "walk_fail": [],
            "attachment": []
        }
コード例 #6
0
ファイル: community.py プロジェクト: NielsZeilemaker/tribler
 def load_community(cls, master):
     dispersy = Dispersy.get_instance()
     try:
         # test if this community already exists
         classification, = next(dispersy.database.execute(u"SELECT classification FROM community WHERE master = ?", (master.database_id,)))
     except StopIteration:
         # join the community with a new my_member, using a cheap cryptography key
         ec = ec_generate_key(u"NID_secp160r1")
         return cls.join_community(master, Member(ec_to_public_bin(ec), ec_to_private_bin(ec)))
     else:
         if classification == cls.get_classification():
             return super(EffortCommunity, cls).load_community(master)
         else:
             raise RuntimeError("Unable to load an EffortCommunity that has been killed")
コード例 #7
0
 def load_community(cls, master, swift_process):
     dispersy = Dispersy.get_instance()
     try:
         # test if this community already exists
         classification, = next(dispersy.database.execute(u"SELECT classification FROM community WHERE master = ?", (master.database_id,)))
     except StopIteration:
         # join the community with a new my_member, using a cheap cryptography key
         ec = ec_generate_key(u"NID_secp160r1")
         return cls.join_community(master, Member(ec_to_public_bin(ec), ec_to_private_bin(ec)), swift_process)
     else:
         if classification == cls.get_classification():
             return super(EffortCommunity, cls).load_community(master, swift_process)
         else:
             raise RuntimeError("Unable to load an EffortCommunity that has been killed")
コード例 #8
0
    def _showInspectionTool(self):
        import wx.lib.inspection
        itool = wx.lib.inspection.InspectionTool()
        itool.Show()
        try:
            frame = itool._frame

            import Tribler
            frame.locals['Tribler'] = Tribler

            session = Session.get_instance()
            frame.locals['session'] = session
            frame.locals['dispersy'] = Dispersy.get_instance()

        except Exception:
            import traceback
            traceback.print_exc()
コード例 #9
0
ファイル: home.py プロジェクト: duy/tribler
    def _showInspectionTool(self):
        import wx.lib.inspection
        itool = wx.lib.inspection.InspectionTool()
        itool.Show()
        try:
            frame = itool._frame

            import Tribler
            frame.locals['Tribler'] = Tribler

            session = Session.get_instance()
            frame.locals['session'] = session
            frame.locals['dispersy'] = Dispersy.get_instance()

        except Exception:
            import traceback
            traceback.print_exc()
コード例 #10
0
 def __init__(self):
     working_directory = Dispersy.get_instance().working_directory
     super(BarterDatabase, self).__init__(path.join(working_directory, u"barter.db"))
コード例 #11
0
 def __init__(self):
     working_directory = Dispersy.get_instance().working_directory
     super(BarterDatabase,
           self).__init__(path.join(working_directory, u"barter.db"))