Skip to content

Commit

Permalink
Merge pull request #417 from pigmej/fix-torrent-transport
Browse files Browse the repository at this point in the history
Fixed torrent transport + added tests
  • Loading branch information
loles committed Dec 9, 2015
2 parents 554dc5c + f25e8ab commit 5f1732b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/transport_torrent/scripts/solar_torrent.py
8 changes: 7 additions & 1 deletion solar/core/transports/torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import libtorrent as lt

from solar.core.handlers.base import SOLAR_TEMP_LOCAL_LOCATION
from solar.core.log import log
from solar.core.transports.base import Executor
from solar.core.transports.base import SyncTransport
Expand Down Expand Up @@ -96,7 +97,7 @@ def _start_seeding(self):
seed_args = ';'.join(to_seed)
# TODO: 'g' is just for debug, it should be 's', remove when sure
cmd = ['/usr/bin/python',
'/vagrant/solar/solar/core/transports/helpers/solar_torrent.py',
'/vagrant/solar/core/transports/helpers/solar_torrent.py',
'g',
'"%s"' % seed_args]
log.debug("Will start seeding: %r" % ' '.join(cmd))
Expand All @@ -110,6 +111,11 @@ def _start_remote_fetch(self, resource, use_sudo):
torrents = self._torrents
else:
torrents = self._sudo_torrents
torrents = map(lambda x: (
x[0],
x[1],
x[2].replace(SOLAR_TEMP_LOCAL_LOCATION, '/tmp/')
), torrents)
to_get = ["%s|%s" % (os.path.abspath(
os.path.join(x[2], '..')), x[1]) for x in torrents]
get_args = ';'.join(to_get)
Expand Down
6 changes: 6 additions & 0 deletions solar/dblayer/solar_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ def _connect_other_hash(self, my_resource, my_inp_name, other_resource,
my_resource, my_inp_name, other_resource, other_inp_name, my_type,
other_type)

def _connect_other_list(self, my_resource, my_inp_name, other_resource,
other_inp_name, my_type, other_type):
return self._connect_other_simple(
my_resource, my_inp_name, other_resource, other_inp_name, my_type,
other_type)

def _connect_other_list_hash(self, my_resource, my_inp_name,
other_resource, other_inp_name, my_type,
other_type):
Expand Down
14 changes: 14 additions & 0 deletions solar/dblayer/test/test_real.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,17 @@ def test_nested_two_listdict(rk):
assert 'backends' in sc
assert isinstance(sc['backends'], list)
assert isinstance(sc['something'], int)


def test_connect_other_list(rk):
k1 = next(rk)
k2 = next(rk)

r1 = create_resource(k1, {'name': 'first',
'inputs': {'config': {"trackers": []}}})
r2 = create_resource(k2, {'name': 'second',
'inputs': {"trackers": ["t1", "t2"]}})
r2.connect(r1, {'trackers': 'config:trackers'})
Resource.save_all_lazy()

assert r1.inputs['config']['trackers'] == ["t1", "t2"]

0 comments on commit 5f1732b

Please sign in to comment.