Discussion:
[Fab-user] append() with multi-line strings
Thomas Güttler
2013-09-25 07:30:18 UTC
Permalink
I want to use append() with strings containing newlines.

I tried this:

append('.netrc', 'machine source.foo.lan\n login foo_readonly\n password removed', partial=True)

and I tried it without partial=True.

The lines get added to the file, regardless of existence. They get added again and again.

fab --version
Fabric 1.7.0
Paramiko 1.11.0

Should I split the lines to a list before calling append()?

Regards,
Thomas
Jeff Forcier
2013-09-26 17:55:36 UTC
Permalink
Hi Thomas,

Yes, you should try using the list version of the call, I think that
might work better. The function uses a grep regex behind the scenes
and either it's not supporting multiline, or not setting the flag for
it by default (iirc).

Keep in mind that all of these contrib functions are convenience only
- you can always forego them or write code based on their
implementation :)

Thanks,
Jeff
Post by Thomas Güttler
I want to use append() with strings containing newlines.
append('.netrc', 'machine source.foo.lan\n login foo_readonly\n
password removed', partial=True)
and I tried it without partial=True.
The lines get added to the file, regardless of existence. They get added again and again.
fab --version
Fabric 1.7.0
Paramiko 1.11.0
Should I split the lines to a list before calling append()?
Regards,
Thomas
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org
Thomas Güttler
2013-10-02 09:36:21 UTC
Permalink
Thank your answer.

We (me and some colleagues) had false ideas about what fabric is.

Fabric uses only shell tools at the remote host.

I don't trust shell scripts.

Fabric is good. But in the future we are only using it to call commands,
and not more.

Our usage:

0. Connect to remote host, open ssh tunnel
1. install or update our deploy module (with pip, via ssh tunnel to our custom pypi-server)
2. run a command of our deploy module

We try to avoid append() and other things that modify files.

Fabric is good. It is just not the thing we first thought is would be.

Regards,
Thomas
Post by Jeff Forcier
Hi Thomas,
Yes, you should try using the list version of the call, I think that
might work better. The function uses a grep regex behind the scenes
and either it's not supporting multiline, or not setting the flag for
it by default (iirc).
Keep in mind that all of these contrib functions are convenience only
- you can always forego them or write code based on their
implementation :)
Thanks,
Jeff
Post by Thomas Güttler
I want to use append() with strings containing newlines.
append('.netrc', 'machine source.foo.lan\n login foo_readonly\n
password removed', partial=True)
and I tried it without partial=True.
The lines get added to the file, regardless of existence. They get added again and again.
fab --version
Fabric 1.7.0
Paramiko 1.11.0
Should I split the lines to a list before calling append()?
Regards,
Thomas
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Loading...