old_contents: from process import Process
  from exit import err_exit
  
  
  class SCP(object):
      """Secure copy abstraction."""
  
      def __init__(self, process=None):
          self.process = process or Process()
  
      def has_host(self, location):
          colon = location.find(':')
          slash = location.find('/')
          return colon > 0 and (slash < 0 or slash > colon)
  
      def join(self, distbase, location):
          sep = ''
          if distbase and distbase[-1] not in (':', '/'):
              sep = '/'
          return distbase + sep + location
  
      def run_scp(self, distfile, location):
          if not self.process.quiet:
              print 'copying to %(location)s' % locals()
          rc = self.process.os_system(
              'scp "%(distfile)s" "%(location)s"' % locals())
          if rc != 0:
              err_exit('scp failed')
          return rc
  
  
new_contents: from tempfile import NamedTemporaryFile
  
  from process import Process
  from exit import err_exit
  
  
  class SCP(object):
      """Secure copy and FTP abstraction."""
  
      def __init__(self, process=None):
          self.process = process or Process()
  
      def run_scp(self, distfile, location):
          if not self.process.quiet:
              print 'scp-ing to %(location)s' % locals()
          rc = self.process.os_system(
              'scp "%(distfile)s" "%(location)s"' % locals())
          if rc != 0:
              err_exit('scp failed')
          return rc
  
      def run_sftp(self, distfile, location):
          if not self.process.quiet:
              print 'sftp-ing to %(location)s' % locals()
          with NamedTemporaryFile(prefix='sftp-') as file:
              file.write('put "%(distfile)s"\n' % locals())
              file.write('bye\n')
              cmdfile = file.name
              rc = self.process.os_system(
                  'sftp -b "%(cmdfile)s" "%(location)s"' % locals())
              if rc != 0:
                  err_exit('sftp failed')
              return rc
  
  
subject: Add run_sftp and remove URL manipulation methods from SCP.