Reads local file & update the remote gist (or create a new one)
193673
def put(self):
        
        content = self.local.read()
        if self.gist:
            self.github.update(self.gist, content)
        else:
            self.github.create(content, public=self.public)
118460
def download(self, remote_url, local_path, buffer_size=8 * 1024):
        """"""
        bucket, key = _parse_url(remote_url)

        response_file = self.call("GetObject", bucket=bucket, key=key)['Body']
        with open(local_path, 'wb') as fp:
            buf = response_file.read(buffer_size)
            while buf:
                fp.write(buf)
                buf = response_file.read(buffer_size)
1083944
def scp_file_remote_to_local(self, remote_path, local_path):
        

        scp_command = [
            'scp',
            '-o',
            'StrictHostKeyChecking=no',
            '-i',
            self.browser_config.get('ssh_key_path'),
            '%s@%s:"%s"' %
            (
                self.browser_config.get('username'),
                self.get_ip(),
                remote_path
            ),
            local_path
        ]
        self.info_log(
            "executing command: %s" %
            ' '.join(scp_command)
        )
        p = Popen(scp_command)
        p.wait()
52142
function loadConfigFile(dist, paths, options, callback) {
        if (options.config) {
            fs.readFile(options.config, {encoding: 'utf8'}, function(err, contents) {
                if (err) {
                    callback(err);
                    return;
                }
                
                var config = ini.parse(contents);

                if (config && config.default) {
                    options.accessKeyId = config.default.access_key;
                    options.secretAccessKey = config.default.secret_key;
                }
                if (!options.secretAccessKey || !options.accessKeyId) {
                    callback("Config file missing access_key or secret_key");
                    return;
                }

                invalidate(dist, paths, options, callback);
            });
        } else {
            invalidate(dist, paths, options, callback);
        }
    }
400054
def copy_from_local(self, localsrc, dest, **kwargs):
        
        with io.open(localsrc, 'rb') as f:
            self.create(dest, f, **kwargs)
1356767
def upload(self, local_fn, remote_fn=None, dont_overwrite=False):
    """"""

    # support wildcard through glob
    if '*' in local_fn:
      for local_subfn in glob.glob(local_fn):
        self.upload(local_subfn)
      return

    if remote_fn is None:
      remote_fn = os.path.basename(local_fn)

    if dont_overwrite and self.exists(remote_fn):
      self.log("Remote file %s exists, skipping" % (remote_fn,))
      return

    if not remote_fn.startswith('/'):
      remote_fn = self.taskdir + '/' + remote_fn

    remote_fn = remote_fn.replace('~', self.homedir)
    self.log('uploading ' + local_fn + ' to ' + remote_fn)

    local_fn = os.path.abspath(local_fn)
    self._run_raw("cp -R %s %s" % (local_fn, remote_fn))
774940
function removeRemoteSingleFile(rootFolder, fileName) {
    // Read every local file and create a correct local.json file
    const fileNameWithoutExtension = path.join(path.parse(fileName).dir, path.parse(fileName).name);
    const extension = path.parse(fileName).ext;

    // Read remote
    const remote = path.join(rootFolder, constants.META_DIR, constants.META_REMOTE);
    const remoteData = JSON.parse(fs.readFileSync(remote, 'utf8'));

    // Check if file is in remote
    let inRemote = false;
    for (let index = 0; index < remoteData.files.length; index++) {
        if (remoteData.files[index].name === fileNameWithoutExtension) {
            inRemote = true;
            // lets remove the file
            remoteData.files.splice(index, 1);
            break;
        }
    }

    // If not in remote
    if (!inRemote) {
        throw {
            message: `Can't seem to find '${fileName}' in the remote Google Apps Script file`,
            print: true,
        };
    }

    // Write to local.json
    writeLocalJson(remoteData, rootFolder);
}
780289
def fetch_gist(gist_id, filename=None):
    """"""
    import requests

    url = gist_url(gist_id, filename)
    response = requests.get(url)

    if response.status_code != 200:
        raise Exception('Got a bad status looking up gist.')
    body = response.text
    if not body:
        raise Exception('Unable to get the gist contents.')

    return body
280318
function(args) {
    var mode = (args && args['mode']) || 'update';
    return map(function(code, filename) {
        var lines = code.toString().split("\n");
        var gists = {};
        var currentGist = null;
        var lineNo = 0;
        lines.forEach(function(line) {
            if (line.indexOf("// startgist:") > -1 || line.indexOf("# startgist:") > -1) {
                if (currentGist) {
                    throw new PluginError(PLUGIN_NAME, filename + ":" + lineNo + ": Unexpected startgist: a previous gist was not closed");
                }
                currentGist = {
                    "id": line.split(":")[1].trim(),
                    "filename": line.split(":")[2].trim(),
                    "lines": []
                };
            } else if (line.indexOf("// endgist") > -1 || line.indexOf("# endgist") > -1) {
                if (!currentGist) {
                    throw new PluginError(PLUGIN_NAME, filename + ":" + lineNo + " Unexpected endgist: missing startgist earlier");
                }
                if (!gists[currentGist.id]) {
                    gists[currentGist.id] = {};
                }
                gists[currentGist.id][currentGist.filename] = {
                    'content': leftAlign(currentGist.lines).join("\n")
                };
                currentGist = null;
            } else if (currentGist && line.indexOf("gisthide") == -1) {
                currentGist.lines.push(line);
            }
            lineNo += 1;
        });
        if (currentGist) {
            throw new PluginError(PLUGIN_NAME, "Reached end of file but gist is still open");
        }
        if (mode == 'create') {
            return fs.read(getUserHome() + '/.gistauth', 'b').then(function (auth) {
                return Q.all(Object.keys(gists).map(function(id) {
                    return create(auth, gists[id]);
                }));
            }).done();
        } else if (mode == 'update') {
            return fs.read(getUserHome() + '/.gistauth', 'b').then(function (auth) {
                return Q.all(Object.keys(gists).map(function(id) {
                    return patch(auth, id, gists[id]);
                }));
            }).done();
        } else {
            gutil.log('Gist mock: ', gists);
        }
    });
}
1262297
function addLocalSingleFile(rootFolder, fileName) {
    // Read every local file and create a correct local.json file
    const fileNameWithoutExtension = path.join(path.parse(fileName).dir, path.parse(fileName).name);
    const extension = path.parse(fileName).ext;

    // Get valid extensions for code files
    const extensions = eaft.getCodeExtensions();

    // Get contents of .gasignore file
    const ignoreRegexes = ignore.getIgnoreRegexes(rootFolder);

    // Test if the file is pushable
    if (!eaft.isPushable(extension, fileNameWithoutExtension, extensions, ignoreRegexes)) {
        checkbox.display('red');
        throw {
            message: `Can't push this file to remote because of an invalid extension or name`,
            print: true,
        };
    }

    // Read remote
    const remote = path.join(rootFolder, constants.META_DIR, constants.META_REMOTE);
    const remoteData = fs.readJsonSync(remote, 'utf8');

    // Read the file we are going to include
    let source = '';
    try {
        source = fs.readFileSync(path.join(rootFolder, fileName), 'utf8');
    } catch (err) {
        throw {
            message: `Can't seem to find '${fileName}' in the local filesystem`,
            print: true,
        };
    }

    // Check if file already in remote
    let alreadyInRemote = false;
    for (const file of remoteData.files) {
        if (file.name === fileNameWithoutExtension) {
            file.source = source;
            alreadyInRemote = true;
            break;
        }
    }

    // Add the file if not already in remote
    if (!alreadyInRemote) {
        const extension = path.parse(fileName).ext;
        const type = eaft.getFiletypeFromExtension(extension);
        remoteData.files.push({
            name: fileNameWithoutExtension,
            type,
            source,
        });
    }

    // Write local.json
    writeLocalJson(remoteData, rootFolder);
}
507415
def parse_remote(cls, filename):
        """"""
        blob_file = cls._URL_FORMAT.search(filename)
        return cls._REMOTE_FILE("blob",
                                storage=blob_file.group("storage"),
                                container=blob_file.group("container"),
                                blob=blob_file.group("blob"))
230720
private void updateLocalRepository() throws GitAPIException {

        try {
            Git.open(new File(paasifyRepositoryDirecory)).pull().call();
        } catch (IOException e) {
            log.error("Cannot update local Git repository");
            log.error(e.getMessage());
        }
    }
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)
33855
def update(self):
        """"""
        if not os.path.isdir(os.path.join(self.path)):
            os.makedirs(self.path)
        if not os.path.isdir(os.path.join(self.path, 'refs')):
            subprocess.check_output([
                'git', 'clone', '--bare', self.repo_git, self.path
            ])
        self.run(['gc', '--auto', '--prune=all'])
        self.run(['fetch', '-p', 'origin', '+refs/heads/*:refs/heads/*'])
        # github support
        self.run(['fetch', 'origin', '+refs/pull/*/head:refs/pull/*'])
        # gitlab support
        self.run([
            'fetch', 'origin', '+refs/merge-requests/*/head:refs/pull/*'])
1243319
def update_docs(readme=True, makefiles=True):
    
    if readme:
        _pandoc = get_external_executable("pandoc")
        rst2markdown_github(os.path.join(_HERE, "README.rst"),
                            os.path.join(_HERE, "README.md"),
                            pandoc=_pandoc)

    if makefiles:
        _make = get_external_executable("make")
        project_makefile_dir = os.path.abspath(_HERE)
        project_makefile_rst = os.path.join(
            _HERE,
            'docs',
            'src',
            'project_makefile.rst')
        docs_makefile_dir = os.path.join(_HERE, 'docs', 'src')
        docs_makefile_rst = os.path.join(
            _HERE,
            'docs',
            'src',
            'docs_makefile.rst')

        #: ``help2rst_queue`` stores tuples of
        #: ``(cwd, help_cmd, path_to_rst_file, rst_title_of_new_file)``
        help2rst_queue = [
            (project_makefile_dir, [_make, "help"], project_makefile_rst,
             "Project ``Makefile``"),

            (docs_makefile_dir, [_make, "help"], docs_makefile_rst,
             "Documentation ``Makefile``")]

        for cwd, help_cmd, outfile, title in help2rst_queue:
            console_help2rst(
                cwd,
                help_cmd,
                outfile,
                title,
                format_as_code=True)
309460
def update():
    """"""
    repo_directory = get_config()['repo_directory']
    os.chdir(repo_directory)
    click.echo("Check for updates...")

    local = subprocess.check_output('git rev-parse master'.split()).strip()
    remote = subprocess.check_output(
        'git ls-remote https://github.com/tldr-pages/tldr/ HEAD'.split()
    ).split()[0]
    if local != remote:
        click.echo("Updating...")
        subprocess.check_call('git checkout master'.split())
        subprocess.check_call('git pull --rebase'.split())
        build_index()
        click.echo("Update to the latest and rebuild the index.")
    else:
        click.echo("No need for updates.")
1146860
def ReadRemoteFile(remote_file_path, hostname, ssh_key):
  
  cmd = 'sudo cat %s' % remote_file_path
  exit_code, output = RunCommandOnHost(cmd, hostname, ssh_key)
  if exit_code:
    raise IOError('Can not read remote path: %s' % (remote_file_path))
  return output