fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] using run on a machine that doesn't have /bin/bash


From: Christian Vest Hansen
Subject: Re: [Fab-user] using run on a machine that doesn't have /bin/bash
Date: Thu, 27 Nov 2008 22:04:33 +0100

I implemented your suggestion #2 and pushed it to the nongnu.org
repository. I'll push to github when their server gets back up.

On Fri, Nov 21, 2008 at 8:46 PM, Jeff Forcier <address@hidden> wrote:
> I don't really like having to make that decision (can't set fab_shell
> vs opening an edge-case where some strings won't get fully
> interpolated). Brainstorming possible solutions:
>
> 1. explicitly omit fab_shell from the line below: "if key !=
> 'fab_shell': value = value % self"
>    - good: best of both worlds, fab_shell can be set OK, all other
> strings correctly interpolated
>    - bad: hardcoding different behavior for a single config key
>    - bad: can't do interpolation on the _rest of_ fab_shell (though
> that would be a truly odd use-case, given how fab_shell is currently
> used, and is not possible now anyways)
>
> 2. Alter use of fab_shell to omit the interpolation step, so that its
> default value is e.g. "/bin/bash -l -c" and then tack on the literal
> double-quotes-plus-actual-command, via string concat instead of x % y.
>    - good: also gives us best of both worlds, as above
>    - good: allows user to interpolate fab_shell itself, if that was
> for some reason necessary
>    - good: avoids the 'bad' steps in sol'n #1
>    - bad: the two places where we use fab_shell to construct the
> final command to run, become slightly less elegant
>
> Unless someone can spot an actual problem with #2, I think it's a
> clear winner. I was serious about it being only 'slightly' less
> elegant: it still won't be messy or hard to read code, just a bit of
> extra string concatenation instead of a single 'string % mapping'
> call. And I can't think of any other drawbacks off the top of my head.
>
> -Jeff
>
> On Fri, Nov 21, 2008 at 2:24 PM, Christian Vest Hansen
> <address@hidden> wrote:
>> Oh my.... That's a bug.
>>
>> I can't think of any way to fix that other than dropping the eagerness
>> of the standard python string interpolation. This in turn introduces
>> the possibility of _lazy_format() returning strings with unresolved
>> placeholders.
>>
>> What does the rest of the list think about this fix?
>>
>> [PATCH] Don't resolve standard python string interpolation eagerly.
>>
>> This fixes a bug that makes it impossible to set the fab_shell
>> variable, but in turn
>> make it possible for _lazy_format() to return strings with unresolved
>> placeholders.
>> ---
>>  fabric.py |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/fabric.py b/fabric.py
>> index 609273e..36de95c 100644
>> --- a/fabric.py
>> +++ b/fabric.py
>> @@ -95,7 +95,7 @@ class Configuration(dict):
>>         self[key] = value
>>     def __setitem__(self, key, value):
>>         if isinstance(value, types.StringTypes):
>> -            value = (value % self)
>> +            value = value
>>         dict.__setitem__(self, key, value)
>>     def __call__(self, **kwargs):
>>         for k, v in kwargs.items():
>> --
>> 1.6.0.1
>>
>>
>>
>> On Fri, Nov 21, 2008 at 7:48 PM, Don Jackson
>> <address@hidden> wrote:
>>> Yes. It's called the `fab_shell` variable, and it is by default
>>> defined like this:
>>>
>>> /bin/bash -l -c "%s"
>>>
>>> That helps, but I'm still doing something wrong:
>>> set(
>>>   fab_hosts = ['svn01'],
>>> )
>>> set(
>>>   fab_shell = '/bin/sh -l -c "%s"'
>>> )
>>> def pwd():
>>>     "prints cwd"
>>>     run("pwd")
>>>
>>> fab pwd
>>>
>>>
>>>    Fabric v. 0.0.9, Copyright (C) 2008 Christian Vest Hansen.
>>>    Fabric comes with ABSOLUTELY NO WARRANTY; for details type `fab
>>> warranty'.
>>>    This is free software, and you are welcome to redistribute it
>>>    under certain conditions; type `fab license' for details.
>>> Running pwd...
>>> Logging into the following hosts as dcj:
>>>     svn01
>>> [svn01] run: pwd
>>> [svn01] err: /bin/sh: {fab_author:: not found
>>> Error: The run operation failed on svn01.
>>>
>>> On Fri, Nov 21, 2008 at 7:01 AM, Don Jackson
>>> <address@hidden> wrote:
>>>>
>>>> Doesn't seem to work.
>>>>
>>>> $ cat fabfile
>>>> set(
>>>>  fab_hosts = ['svn01'],
>>>> )
>>>>
>>>> def pwd():
>>>>    "prints cwd"
>>>>    run("pwd")
>>>>
>>>> $ fab pwd
>>>>   Fabric v. 0.0.9, Copyright (C) 2008 Christian Vest Hansen.
>>>>   Fabric comes with ABSOLUTELY NO WARRANTY; for details type `fab
>>>> warranty'.
>>>>   This is free software, and you are welcome to redistribute it
>>>>   under certain conditions; type `fab license' for details.
>>>>
>>>> Running pwd...
>>>> Logging into the following hosts as dcj:
>>>>    svn01
>>>> [svn01] run: pwd
>>>> [svn01] err: ksh: /bin/bash: not found
>>>> Error: The run operation failed on svn01.
>>>>
>>>> Is there a variable I can set that will make fabric use another shell?
>>>
>>> _______________________________________________
>>> Fab-user mailing list
>>> address@hidden
>>> http://lists.nongnu.org/mailman/listinfo/fab-user
>>>
>>>
>>
>>
>>
>> --
>> Venlig hilsen / Kind regards,
>> Christian Vest Hansen.
>>
>> _______________________________________________
>> Fab-user mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/fab-user
>>
>>
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]