def scp(reactor, username, host, remote_path, local_path, direction, port=22, identity_file=None):
 if (direction not in (DOWNLOAD, UPLOAD)):
  raise ValueError('Invalid direction argument {!r}. Must be one of ``runner.DOWNLOAD`` or ``runner.UPLOAD``.'.format(direction))
 remote_host_path = ((((username + '@') + host) + ':') + remote_path.path)
 scp_command = (['scp', '-r', '-P', bytes(port)] + SSH_OPTIONS)
 if (identity_file is not None):
  scp_command += ['-i', identity_file.path]
 if (direction is DOWNLOAD):
  scp_command += [remote_host_path, local_path.path]
 else:
  scp_command += [local_path.path, remote_host_path]
 action = SCP_ACTION(username=username, host=host, remote_path=remote_path, local_path=local_path, port=port, identity_file=identity_file)
 failed_reason = []
 def handle_stdout(line):
  SCP_OUTPUT_MESSAGE(line=line).write(action=action)
 def handle_stderr(line):
  "\n        Notice scp's particular way of describing the file-not-found condition\n        and turn it into a more easily recognized form.\n        "
  if ('No such file or directory' in line):
   failed_reason.append(RemoteFileNotFound(remote_path))
  if ('lost connection' in line):
   failed_reason.append(SCPConnectionError())
  SCP_ERROR_MESSAGE(line=line).write(action=action)
 def scp_failed(reason):
  '\n        Check for a known error with the scp attempt and turn the normal\n        failure into a more meaningful one.\n        '
  reason.trap(ProcessTerminated)
  if failed_reason:
   return Failure(failed_reason[(-1)])
  return reason
 with action.context():
  context = DeferredContext(run(reactor, scp_command, handle_stdout=handle_stdout, handle_stderr=handle_stderr))
  context.addErrback(scp_failed)
  return context.addActionFinish()

def scp ( reactor , username , host , remote_path , local_path , direction , port = 22 , identity_file = None ) : if ( direction not in ( DOWNLOAD , UPLOAD ) ) : raise ValueError ( 'Invalid direction argument {!r}. Must be one of ``runner.DOWNLOAD`` or ``runner.UPLOAD``.' . format ( direction ) ) remote_host_path = ( ( ( ( username + '@' ) + host ) + ':' ) + remote_path . path ) scp_command = ( [ 'scp' , '-r' , '-P' , bytes ( port ) ] + SSH_OPTIONS ) if ( identity_file is not None ) : scp_command += [ '-i' , identity_file . path ] if ( direction is DOWNLOAD ) : scp_command += [ remote_host_path , local_path . path ] else : scp_command += [ local_path . path , remote_host_path ] action = SCP_ACTION ( username = username , host = host , remote_path = remote_path , local_path = local_path , port = port , identity_file = identity_file ) failed_reason = [ ] def handle_stdout ( line ) : SCP_OUTPUT_MESSAGE ( line = line ) . write ( action = action ) def handle_stderr ( line ) : if ( 'No such file or directory' in line ) : failed_reason . append ( RemoteFileNotFound ( remote_path ) ) if ( 'lost connection' in line ) : failed_reason . append ( SCPConnectionError ( ) ) SCP_ERROR_MESSAGE ( line = line ) . write ( action = action ) def scp_failed ( reason ) : reason . trap ( ProcessTerminated ) if failed_reason : return Failure ( failed_reason [ ( - 1 ) ] ) return reason with action . context ( ) : context = DeferredContext ( run ( reactor , scp_command , handle_stdout = handle_stdout , handle_stderr = handle_stderr ) ) context . addErrback ( scp_failed ) return context . addActionFinish ( )
yaml: scp upload files via scp requires the jenkins :jenkins-wiki:scp plugin <scp+plugin> .