Upload a directory on the remote host.
17740
def send_dir(self, local_path, remote_path, user='root'):
        
        self.enable_user(user)
        return self.ssh_pool.send_dir(user, local_path, remote_path)
51667
def _store_binary(self, local_path, remote):
        """"""
        # Destination directory
        dst_dir = os.path.dirname(remote)

        # Destination file name
        dst_file = os.path.basename(remote)

        # File upload command
        dst_cmd = 'STOR {0}'.format(dst_file)

        with open(local_path, 'rb') as local_file:
            # Change directory if needed
            if dst_dir != dst_file:
                self.chdir(dst_dir, make=True)

            # Upload file & return response
            return self.session.storbinary(dst_cmd, local_file)
84437
def addJsonDirectory(self, directory, test=None):
    """"""

    for filename in os.listdir(directory):
      try:
        fullPath = os.path.join(directory, filename)
        if not test or test(filename, fullPath):
          with open(fullPath) as f:
            jsonData = json.load(f)
            name, _ = os.path.splitext(filename)
            self.addSource(name, jsonData)

      except ValueError:
        continue
428671
def deploy_remote(self, dotfiles):
        """"""
        tempfile_path = None
        tempdir_path = None

        try:
            tempdir_path = tempfile.mkdtemp()
            self.log.debug('Deploying to temp dir %s', tempdir_path)
            self.deploy_local(dotfiles, target_root=tempdir_path)

            if self.args.rsync:
                local_spec = tempdir_path.rstrip('/') + '/'
                remote_spec = self.args.path.rstrip('/') + '/'

                if self.args.user:
                    remote_spec = "{0}@{1}:{2}".format(self.args.user,
                                                       self.args.server,
                                                       remote_spec)
                else:
                    remote_spec = "{0}:{1}".format(self.args.server,
                                                   remote_spec)

                self.log.debug('Using rsync to sync dotfiles to %s',
                               remote_spec)
                self.sh('rsync', '-az', local_spec, remote_spec)

            else:
                fh, tempfile_path = tempfile.mkstemp(suffix='.tar.gz')
                os.close(fh)

                self.log.debug('Creating tar file %s', tempfile_path)
                shutil.make_archive(tempfile_path.replace('.tar.gz', ''),
                                    'gztar', tempdir_path)

                upload_path = '_profile_upload.tgz'
                self.log.debug('Uploading tarball to %s', upload_path)
                self.scp(tempfile_path, upload_path)

                if self.args.path:
                    ssh_command = "'mkdir -p {0} && "\
                                  "tar xf _profile_upload.tgz -C {0}; "\
                                  "rm -f _profile_upload.tgz'"\
                                  "".format(self.args.path)
                else:
                    ssh_command = "tar xf _profile_upload.tgz; "\
                                  "rm -f _profile_upload.tgz"
                self.log.debug('Using ssh to unpack tarball and clean up')
                self.ssh(ssh_command)

        finally:
            if tempdir_path and path.isdir(tempdir_path):
                self.log.debug('Removing temp dir %s', tempdir_path)
                shutil.rmtree(tempdir_path)
            if tempfile_path and path.isfile(tempfile_path):
                self.log.debug('Removing temp file %s', tempfile_path)
                os.unlink(tempfile_path)
963588
def cd(self, remote):
        
        try:
            self.conn.cwd(remote)
        except Exception:
            return False
        else:
            return self.pwd()
400686
def upload(ctx, release, rebuild):
    
    dist_path = Path(DIST_PATH)
    if rebuild is False:
        if not dist_path.exists() or not list(dist_path.glob('*')):
            print("No distribution files found. Please run 'build' command first")
            return
    else:
        ctx.invoke(build, force=True)

    if release:
        args = ['twine', 'upload', 'dist/*']
    else:
        repository = 'https://test.pypi.org/legacy/'
        args = ['twine', 'upload', '--repository-url', repository, 'dist/*']

    env = os.environ.copy()

    p = subprocess.Popen(args, env=env)
    p.wait()
610084
def register_upload_command(self, upload_func):
        
        description = "Uploads local files and folders to a remote host."
        upload_parser = self.subparsers.add_parser('upload', description=description)
        _add_dry_run(upload_parser, help_text="Instead of uploading displays a list of folders/files that "
                                              "need to be uploaded.")
        add_project_name_or_id_arg(upload_parser, help_text_suffix="upload files/folders to.")
        _add_folders_positional_arg(upload_parser)
        _add_follow_symlinks_arg(upload_parser)
        upload_parser.set_defaults(func=upload_func)
1132171
def make_dir(cls, directory_name):
        """"""
        if not os.path.exists(directory_name):
            os.makedirs(directory_name)
1342222
protected function prepareRemoteDirectory($remote_host, $remote_dir)
	{
		$this->log('Initialize remote directory: '. $remote_host .':'. $remote_dir, LOG_INFO, true);

		$output = array();
		$return = null;
		$this->sshExec($remote_host, "mkdir -p $remote_dir", $output, $return, '', '', LOG_DEBUG);

		if (empty($this->data_dirs))
            return;

        $data_dirs = count($this->data_dirs) > 1 ? '{'. implode(',', $this->data_dirs) .'}' : implode(',', $this->data_dirs);

        $cmd = "mkdir -v -m 0775 -p $remote_dir/{$this->data_dir_prefix}/$data_dirs";

        $output = array();
        $return = null;
        $this->sshExec($remote_host, $cmd, $output, $return, '', '', LOG_DEBUG);
	}
840735
def serve_dtool_directory(directory, port):
    """"""
    os.chdir(directory)
    server_address = ("localhost", port)
    httpd = DtoolHTTPServer(server_address, DtoolHTTPRequestHandler)
    httpd.serve_forever()
1211672
def mount(dev, mountpoint, flags='', log=None):
    ''''''
    ensureDirectory(mountpoint)
    systemCall('mount %s %s %s' % (flags, dev, mountpoint),
               log=log)
1211629
def upload(ctx, check, sdist, dry_run):
    """"""
    if check in get_valid_checks():
        check_dir = os.path.join(get_root(), check)
    else:
        check_dir = resolve_path(check)
        if not dir_exists(check_dir):
            abort('`{}` is not an Agent-based Integration or Python package'.format(check))

        check = basepath(check_dir)

    # retrieve credentials
    pypi_config = ctx.obj.get('pypi', {})
    username = pypi_config.get('user') or os.getenv('TWINE_USERNAME')
    password = pypi_config.get('pass') or os.getenv('TWINE_PASSWORD')
    if not (username and password):
        abort('This requires pypi.user and pypi.pass configuration. Please see `ddev config -h`.')

    auth_env_vars = {'TWINE_USERNAME': username, 'TWINE_PASSWORD': password}
    echo_waiting('Building and publishing `{}` to PyPI...'.format(check))

    with chdir(check_dir, env_vars=auth_env_vars):
        result = build_package(check_dir, sdist)
        if result.code != 0:
            abort(result.stdout, result.code)
        echo_waiting('Uploading the package...')
        if not dry_run:
            result = run_command('twine upload --skip-existing dist{}*'.format(os.path.sep))
            if result.code != 0:
                abort(code=result.code)

    echo_success('Success!')
68451
function ftpCwd(inPath, cb) {
    ftp.raw.cwd(inPath, function(err) {
      if (err) {
        ftp.raw.mkd(inPath, function(err) {
          if (err) {
            log.error('Error creating new remote folder ' + inPath + ' --> ' + err);
            cb(err);
          } else {
            log.ok('New remote folder created ' + inPath.yellow);
            ftpCwd(inPath, cb);
          }
        });
      } else {
        cb(null);
      }
    });
  }
723037
def _uploadFile(self,directory,fn,dentry,db,service):
        
        # Create a hash of the file
        if fn not in db:
            print("%s - Not in DB, must run 'add' first!"%(fn))
        else:
            # If already added, see if it's modified, only then
            # do another upload
            if db[fn]['services'][service]['status']==self.ST_UPTODATE:
                if not dentry['status']==self.ST_MODIFIED:
                    logger.info("%s - Up to date, skipping (%s)!"\
                            %(fn,service))
                    return False

            sobj=self.sman.GetServiceObj(service)
            # If nobody manages this file, just skip it
            if (not sobj):
                print("%s - Upload: No service of name [%s] found"%(fn,service))
                return
            # Only change status if correctly uploaded
            if sobj.Upload(directory,fn):
                # Write newest mtime/hash to indicate all is well
                db[fn]['mtime']=dentry['mtime']
                db[fn]['hash']=self._hashfile(os.path.join(directory,fn))
                db[fn]['services'][service]['status']=self.ST_UPTODATE
                logger.debug('%s - uploaded by service: %s'%(fn,sobj.GetName()))
                return True
            else:
                logger.error('%s - Failed to upload by service: %s'%(fn,sobj.GetName()))
                return False


        return False
457696
def upload():
    

    def twine(*args):
        """ run a twine command """
        process = run(sys.executable, '-m', 'twine', *args)

        return process.wait() != 0

    if run(sys.executable, 'setup.py', 'sdist', 'bdist_wheel').wait() != 0:
        error('failed building packages')

    if twine('register', glob.glob('dist/*')[0]):
        error('register failed')

    if twine('upload', '-s', '-i', 'CB164668', '--skip-existing', 'dist/*'):
        error('upload failed')
1040677
def up_by_files(to_sync, remote_dir=DEFAULT_REMOTE_DIR, remote_files=None):
    """"""
    if remote_files is None:
        remote_files = command.map_files_raw(remote_dir=remote_dir)
    for local_file in to_sync:
        _sync_local_file(local_file, remote_dir, remote_files)
1132409
def push(self, dir):
        
        self.stack.append(os.getcwd())
        os.chdir(dir or os.getcwd())