Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First Credit mining prototype #2064

Merged
merged 24 commits into from
Jun 28, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7226455
Channel boosting implementation
Oct 9, 2013
168f7cc
sessioncalling arg was removed a while ago.
Aug 18, 2015
bd87ab1
Updates for API changes
Aug 18, 2015
897cdff
Add missing __init__.py
Aug 18, 2015
d713895
Don't fail when a torrent not in the download list finishes.
Aug 18, 2015
9d3201b
Remove DOS newlines from BoostingManager modifications.
Aug 18, 2015
24ebb7b
WIP commit
Aug 24, 2015
2184356
WIP commit
Aug 28, 2015
b7010d8
Fix initial work in BoostingManager that cannot work
ardhipoetra Jun 27, 2016
a31b923
Revamped creditmining GUI
ardhipoetra Jun 27, 2016
9a87521
Extract peerlist to its own function
ardhipoetra Mar 18, 2016
6600773
Create function to translate peers into health
ardhipoetra Jun 27, 2016
d7d9ccf
Create holder in GUI if credit mining is not ready yet
ardhipoetra Jun 27, 2016
ae7576c
Start boosting manager if ready only
ardhipoetra Jun 27, 2016
9b9c01a
Add dirdialog for convenience choosing source
ardhipoetra Jun 27, 2016
c2e894b
Prevent GUI to do task when quitting
ardhipoetra May 9, 2016
a33b4c7
Clean onexit in BoostingManager
ardhipoetra Jun 27, 2016
6cc9d7d
Add and clean documentation in some functions needed
ardhipoetra May 3, 2016
2310579
Add credit mining preferences by SessionConfig
ardhipoetra May 27, 2016
a85ab3c
Refactor policies, constant, and function to different file
ardhipoetra May 31, 2016
66eb87f
Fix resume data to use configparser
ardhipoetra Jun 27, 2016
57e8636
Add logger.conf, Delete bootstraptribler.txt and boostchannel.py
ardhipoetra Jun 14, 2016
b11fd65
Fix switch policy when loading config
ardhipoetra Jun 8, 2016
b9d1940
Credit mining testcase
ardhipoetra Jun 27, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revamped creditmining GUI
Squashed Commits:
- Integrate uniform channel source into GUI
- Add credit mining manager and list
- Integrating gumby with Boostingmanager
- Update info to summary panel
- Fix bugs in credit mining panel and make prettier popular channel @home
- Refreshing-connecting home and Credit Mining Panel
- Beautify home channel list -need to expand horizontally-
- Change credit mining order in GUI
- Remove PostInit in creditmining list
- Fix channel source interpretation

What this commits do is :
- Change BoostingDialog GUI as we don't need channel there
- Create CreditMiningPanel as container for credit mining tab
- Add Credit Mining option in GUI Utility (lists in tab)
- Put CreditMiningPanel in MainFrame
- Put popular channels in Home. Directly affected with credit mining
- Make current credit mining list to adapt new GUI structure
  • Loading branch information
ardhipoetra committed Jun 27, 2016
commit a31b923eb0c161b1a6a81fd8dcd2d94daccd2d32
48 changes: 27 additions & 21 deletions Tribler/Main/Dialogs/BoostingDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
class AddBoostingSource(wx.Dialog):

def __init__(self, parent):
wx.Dialog.__init__(self, parent, -1, 'Add boosting source', size=(475, 475), name="AddBoostingSourceDialog")
wx.Dialog.__init__(self, parent, -1, 'Add boosting source', size=(275, 275), name="AddBoostingSourceDialog")

self.guiutility = GUIUtility.getInstance()
self.channels = []
self.source = ''

text = wx.StaticText(self, -1, 'Please enter a RSS feed URL or select a channel to start boosting swarms:')
self.channel_radio = wx.RadioButton(self, -1, 'Subscribed Channel:', style=wx.RB_GROUP)
self.channel_choice = wx.Choice(self, -1)
self.channel_choice.Bind(wx.EVT_CHOICE, lambda evt: self.channel_radio.SetValue(True))
text = wx.StaticText(self, -1, 'Please enter a RSS feed URL or directory to start boosting swarms:')
# self.channel_radio = wx.RadioButton(self, -1, 'Subscribed Channel:', style=wx.RB_GROUP)
# self.channel_choice = wx.Choice(self, -1)
# self.channel_choice.Bind(wx.EVT_CHOICE, lambda evt: self.channel_radio.SetValue(True))

self.rss_feed_radio = wx.RadioButton(self, -1, 'RSS feed:')
self.rss_feed_edit = wx.TextCtrl(self, -1)
Expand All @@ -37,8 +37,8 @@ def __init__(self, parent):

sourceGrid = wx.FlexGridSizer(2, 2, 0, 0)
sourceGrid.AddGrowableCol(1)
sourceGrid.Add(self.channel_radio, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT | wx.TOP, 5)
sourceGrid.Add(self.channel_choice, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5)
# sourceGrid.Add(self.channel_radio, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT | wx.TOP, 5)
# sourceGrid.Add(self.channel_choice, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5)
sourceGrid.Add(self.rss_feed_radio, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT | wx.TOP, 5)
sourceGrid.Add(self.rss_feed_edit, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5)
sourceGrid.Add(self.rss_dir_radio, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT | wx.TOP, 5)
Expand All @@ -55,25 +55,31 @@ def __init__(self, parent):
vSizer.Add(btnSizer, 0, wx.EXPAND | wx.ALL, 5)
self.SetSizer(vSizer)

def do_db():
return self.guiutility.channelsearch_manager.getMySubscriptions()

def do_gui(delayedResult):
_, channels = delayedResult.get()
self.channels = sorted([(channel.name, channel.dispersy_cid) for channel in channels])
self.channel_choice.SetItems([channel[0] for channel in self.channels])

startWorker(do_gui, do_db, retryOnBusy=True, priority=GUI_PRI_DISPERSY)
# def do_db():
# return self.guiutility.channelsearch_manager.getAllChannels()
#
# def do_gui(delayedResult):
# _, channels = delayedResult.get()
# self.channels = sorted([(channel.name, channel.dispersy_cid) for channel in channels])
# self.channel_choice.SetItems([channel[0] for channel in self.channels])
#
# startWorker(do_gui, do_db, retryOnBusy=True, priority=GUI_PRI_DISPERSY)

def OnOK(self, event):
if self.channel_radio.GetValue():
selection = self.channel_choice.GetSelection()
if selection < len(self.channels):
self.source = self.channels[selection][1]
elif self.rss_feed_radio.GetValue():
# if self.channel_radio.GetValue():
# selection = self.channel_choice.GetSelection()
# if selection < len(self.channels):
# self.source = self.channels[selection][1]
# el

if self.rss_feed_radio.GetValue():
self.source = self.rss_feed_edit.GetValue()
else:
self.source = self.rss_dir_edit.GetValue()

self.guiutility.Notify(
"Successfully add source for credit mining %s" % self.source)

self.EndModal(wx.ID_OK)

def OnCancel(self, event):
Expand Down
7 changes: 4 additions & 3 deletions Tribler/Main/Utility/GuiDBTuples.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(self, torrent_id, infohash, name, length, category, status, num_see
Helper.__init__(self)

assert isinstance(infohash, str), type(infohash)
assert isinstance(name, basestring), type(name)
# assert isinstance(name, basestring), type(name)

self.infohash = infohash
self.name = name
Expand All @@ -127,7 +127,7 @@ def __init__(self, torrent_id, infohash, name, length, category, status, num_see

@cacheProperty
def torrent_id(self):
self._logger.debug("Torrent: fetching getTorrentID from DB %s", self)
self._logger.error("Torrent: fetching getTorrentID from DB %s", self)
return self.torrent_db.getTorrentID(self.infohash)

def update_torrent_id(self, torrent_id):
Expand Down Expand Up @@ -300,7 +300,7 @@ def __init__(self, torrent_id, infohash, name, length=0, category=None, status=N


class CollectedTorrent(Helper):
__slots__ = ('comment', 'trackers', 'creation_date', 'files', 'last_check', 'torrent')
__slots__ = ('comment', 'trackers', 'creation_date', 'files', 'last_check', 'torrent', 'tdef')

def __init__(self, torrent, torrentdef):
assert isinstance(torrent, Torrent)
Expand All @@ -314,6 +314,7 @@ def __init__(self, torrent, torrentdef):
self.creation_date = min(long(time()), torrentdef.get_creation_date())
self.files = torrentdef.get_files_as_unicode_with_length()
self.last_check = -1
self.tdef = torrentdef

def __getattr__(self, name):
return getattr(self.torrent, name)
Expand Down
12 changes: 12 additions & 0 deletions Tribler/Main/tribler_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# see LICENSE.txt for license information
#
from Tribler.Core.Modules.process_checker import ProcessChecker
from Tribler.Policies.BoostingManager import BoostingManager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pylint: 13: C0411: (wrong-import-order), : standard import "import shutil" comes before "from Tribler.Policies.BoostingManager import BoostingManager". This import should go down.

from Tribler.Main.Dialogs.NewVersionDialog import NewVersionDialog

try:
Expand Down Expand Up @@ -263,6 +264,8 @@ def __init__(self, params, installdir, autoload_discovery=True,
# gracefully closes Tribler after 120 seconds.
# wx.CallLater(120*1000, wx.GetApp().Exit)

self.boosting_manager = BoostingManager.get_instance()

self.ready = True

except Exception as e:
Expand Down Expand Up @@ -815,6 +818,15 @@ def OnExit(self):
self.webUI.stop()
self.webUI.delInstance()

if self.boosting_manager:

#remove credit mining data
#TODO(ardhi) : not persistent mode only
import shutil; shutil.rmtree(self.boosting_manager.credit_mining_path, ignore_errors=True)

self.boosting_manager.shutdown()
self.boosting_manager.del_instance()

if self.frame:
self.frame.Destroy()
self.frame = None
Expand Down
Loading