On Thu, Jul 12, 2012 at 6:32 AM, Todd DeLuca <[email protected]> wrote:
> The way I deploy to localhost now is to run ssh on my local machine. That > way I can access my local machine "remotely" in fabric scripts. On my mac > laptop, here is how I enabled remote logins via ssh. Go to System > Preferences, choose Sharing. Select Remote login. That's it. This > approach seems to fit into the fabric model well. > > I used to deploy locally by following the advice at > http://stackoverflow.com/questions/6725244/running-fabric-script-locally. > Basically, I would assign env.run = run or env.run = local, depending on > where I was deploying, perhaps in a task something like (warning: untested > code): > In djeploy I use a similar idea. I route all commands through the Command class ( https://bitbucket.org/petersanchez/djeploy/src/8753a0ad4463/djeploy/globals.py#cl-60 ) The commands are set based on an setting called "run_type".. if it's set to local, then all commands will be mapped through the a fabric.operations.local wrapper. It's worked very well for me in various projects. Peter > > ``` > env.run = run > > @task > def localhost(): > env.run = local > > @task > def do_something(): > env.run('path/to/myscript.py') > ``` > > Then I would do invoke it like: > > ``` > fab local do_something > ``` > > This got smellier when I started rsyncing, since I had to write a > local version and remote version of rsync. Then when I started > using `fabric.api.get`, I realized that I would have to write a API > compatible version of `get` and `put` if I wanted to continue down this > path. That pushed me to find the better way described above. > > Hope that helps. > > -Todd > > > On Thu, Jul 12, 2012 at 4:05 AM, Jorge Vargas <[email protected]>wrote: > >> Hello, >> >> We are using fabric for development as well as deployment and I'm >> wondering how people are doing command like this. >> >> @task >> def load_fixtures(): >> """Load initial data.""" >> run("venv/bin/python data/fixtures.py") >> >> This code should work for both the developer machine (ie: run local) and >> the deployment machine (ie: use run) >> >> So far what I have done is something like >> >> @task >> def install_db(command=local): >> """@onetime install of the database""" >> with prefix("source venv/bin/activate"): >> command("python manage.py syncdb --migrate") >> >> However that's a bit of a problem as I can't call that command from fab >> just from other fabric scripts. >> >> _______________________________________________ >> Fab-user mailing list >> [email protected] >> https://lists.nongnu.org/mailman/listinfo/fab-user >> >> > > > -- > Todd DeLuca > http://todddeluca.com > http://wall.hms.harvard.edu/ > > > > _______________________________________________ > Fab-user mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/fab-user > >
_______________________________________________ Fab-user mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/fab-user
