def test_get_remote_path(self): for path in [ 'sftp://127.0.0.1/srv/www/saupdate', 'sftp://192.168.1.25:22/srv/www/saupdate' ]: result = get_remote_path(path) self.assertEqual(result, '/srv/www/saupdate')
def upload(config, remote_loc, u_filename): """Upload the files""" rcode = False try: sftp, transport = get_sftp_conn(config) remote_dir = get_remote_path(remote_loc) for part in ['sha1', 'asc']: local_file = '%s.%s' % (u_filename, part) remote_file = os.path.join(remote_dir, local_file) sftp.put(local_file, remote_file) sftp.put(remote_dir, os.path.join(remote_dir, u_filename)) rcode = True except BaseException: pass finally: if 'transport' in locals(): transport.close() return rcode
def test_get_remote_path(self): for path in [ 'sftp://127.0.0.1/srv/www/saupdate', 'sftp://192.168.1.25:22/srv/www/saupdate']: result = get_remote_path(path) self.assertEqual(result, '/srv/www/saupdate')