+10 votes
by (100 points)

I want to get the content of a remote file with fabric, without creating a temporary file.

10 Answers

+18 votes
by (100 points)
from StringIO import StringIO
from fabric.api import get

fd = StringIO()
get(remote_path, fd)
+17 votes
by (100 points)

With Python 3 (and fabric3), I get this fatal error when using io.StringIO : string argument expected, got 'bytes' , apparently because Paramiko writes to the file-like object with bytes. So I switched to using io.BytesIO and it works:

from io import BytesIO

def _read_file(file_path, encoding='utf-8'):
    io_obj = BytesIO()
    get(file_path, io_obj)
    return io_obj.getvalue().decode(encoding)
+15 votes
by (100 points)
import tempfile
from fabric.api import get
with tempfile.TemporaryFile() as fd:
    get(remote_path, fd)

See: http://docs.python.org/2/library/tempfile.html#tempfile.TemporaryFile

and: http://docs.fabfile.org/en/latest/api/core/operations.html#fabric.operations.get

+15 votes
by (100 points)

Lib spring-expression is not in lib directory when you build your large java project, but is in your minimal example's. And I noticed that you were using maven 3.0.3, this problem is caused by this bug MNG-5121 .

+11 votes
by (100 points)

might I suggest this jQuery plugin to you since it looks like you're already using jQuery.

+7 votes
by (100 points)

Well, it depends on the context. For example,

$foo = "$dxyabcdef";
$bar = "${dxyabc}def";

$foo will have the value of $dxyabcdef instead of $dxyabc appended with def , this is the value of $bar .

Otherwise, as far as I know, they are the same.

+4 votes
by (100 points)

This feature is implemented on the master branch via PR#5146 which is targetted for mpl 2.1 which should be out in the fall.

If you need it now either run the master branch or vendor that method as a function

axarr = vendored_subplots(fig, ...)
+4 votes
by (100 points)

If you are looking to get the .cover-wrapper to cover the entire page you can use:

.cover-wrapper {
    width: 100%;
    height: 100%; /* For at least Firefox */
    position: absolute;
    top: 0;
    bottom: 0;
    background-color: #0f0;

This will cause it to act more like an overlay.

+4 votes
by (100 points)

do something like

    Private Sub btnBackSpace_Click_1(sender As Object, e As EventArgs) Handles btnBackSpace.Click

    'The procedure works as a backspace for the
    'cash box

    If txtCash.Text < " " Then


        txtCash.Text = Mid(txtCash.Text, 1, Len(txtCash.Text) - 1)

    End If

End Sub

think this help :/

0 votes
by (100 points)

Justin Barber shows you an immediate solution for your problem.

Since you are using NumPy you could however use their generators as well since they appear to be significantly faster (about a factor 5-7 on my machine), e.g.

alea_var_n = np.random.normal(1, 2)