def upload_project(local_dir=None, remote_dir='', use_sudo=False):
 runner = ((use_sudo and sudo) or run)
 local_dir = (local_dir or os.getcwd())
 local_dir = local_dir.rstrip(os.sep)
 (local_path, local_name) = os.path.split(local_dir)
 tar_file = ('%s.tar.gz' % local_name)
 target_tar = os.path.join(remote_dir, tar_file)
 tmp_folder = mkdtemp()
 try:
  tar_path = os.path.join(tmp_folder, tar_file)
  local(('tar -czf %s -C %s %s' % (tar_path, local_path, local_name)))
  put(tar_path, target_tar, use_sudo=use_sudo)
  with cd(remote_dir):
   try:
    runner(('tar -xzf %s' % tar_file))
   finally:
    runner(('rm -f %s' % tar_file))
 finally:
  local(('rm -rf %s' % tmp_folder))

def upload_project ( local_dir = None , remote_dir = '' , use_sudo = False ) : runner = ( ( use_sudo and sudo ) or run ) local_dir = ( local_dir or os . getcwd ( ) ) local_dir = local_dir . rstrip ( os . sep ) ( local_path , local_name ) = os . path . split ( local_dir ) tar_file = ( '%s.tar.gz' % local_name ) target_tar = os . path . join ( remote_dir , tar_file ) tmp_folder = mkdtemp ( ) try : tar_path = os . path . join ( tmp_folder , tar_file ) local ( ( 'tar -czf %s -C %s %s' % ( tar_path , local_path , local_name ) ) ) put ( tar_path , target_tar , use_sudo = use_sudo ) with cd ( remote_dir ) : try : runner ( ( 'tar -xzf %s' % tar_file ) ) finally : runner ( ( 'rm -f %s' % tar_file ) ) finally : local ( ( 'rm -rf %s' % tmp_folder ) )
upload the current project to a remote system via tar/gzip .