Skip to content

Commit

Permalink
Merge pull request #16 from kivy/copy_back
Browse files Browse the repository at this point in the history
copy the generated apk back from remote
  • Loading branch information
tito committed Jun 28, 2013
2 parents ebea195 + 5382991 commit f7d8b95
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion buildozer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,13 +853,15 @@ def run_command(self, args):
self._ensure_buildozer()
self._sync_application_sources()
self._do_remote_commands(args[1:])
self._ssh_sync(os.getcwd(), mode='get')
finally:
self._ssh_close()

def _ssh_connect(self):
self.info('Connecting to {}'.format(self.remote_host))
import paramiko
self._ssh_client = client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.load_system_host_keys()
client.connect(self.remote_host, username=self.remote_user)
self._sftp_client = client.open_sftp()
Expand Down Expand Up @@ -920,10 +922,19 @@ def _ssh_mkdir(self, *args):
self.error('Unable to create remote directory {}'.format(directory))
raise

def _ssh_sync(self, directory):
def _ssh_sync(self, directory, mode='put'):
self.debug('Syncing {} directory'.format(directory))
directory = realpath(directory)
base_strip = directory.rfind('/')
if mode == 'get':
local_dir = join(directory,'bin')
remote_dir = join(self.remote_build_dir, 'bin')
if not os.path.exists(local_dir):
os.path.makedirs(local_dir)
for _file in self._sftp_client.listdir(path=remote_dir):
self._sftp_client.get(join(remote_dir, _file),
join(local_dir, _file))
return
for root, dirs, files in walk(directory):
self._ssh_mkdir(self.remote_build_dir, root[base_strip + 1:])
for fn in files:
Expand Down

0 comments on commit f7d8b95

Please sign in to comment.