LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-07-2014, 10:53 AM   #1
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Python 2.6.6 or Fabric 1.8 question about arrays


I am botching this badly and I need some assistance unprovided by Google searching/Documentation.

So im using python 2.6.6 and fabric 1.8

Here is what i am trying to do:
  • run an svn command on a host and get list of files
  • do some things to those files

Here is what i have as an idea:
Code:
@serial
def patch(revision):
        env.user = 'root'
        with settings(host_string='somehost.lan'):
                with cd('/root/builds'):
                        with run('svn log -r {0}'.format(revision)) as name:
                                line = name.readlines()
                                run($line)
Which does't work.
 
Old 02-11-2014, 11:46 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
And the fix:

Code:
def db_patch(database,patchfile): #expects a database name, and a sql file to import
        env.user = 'root'
        hosts = 'dev','stage','prod'
        for dest in hosts:
        	with settings(host_string='{0}'.format(dest),password='password'):
                	put(local_path='/root/fabric/sql_patch/{0}'.format(patchfile),remote_path='/root/.fabric/sql_patch/{0}'.format(patchfile))
                	run('mysqldump {0} | gzip -c | cat > /root/.fabric/sql_backup/{0}.{1}.gz'.format(database,epoch_time))
                	run('cd /root/.fabric/sql_patch; mysql --verbose --show-warnings {0} < {1} | tee /root/.fabric/sql_patch/{1}-{2}.log;'.format(database,patchfile,epoch_time))
                       	print 'your rollback command is:'
                	print 'fab -f ./database.py db_rollback:database={0},backupfile={0}.{1}.gz'.format(database,epoch_time)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Expanding arrays in python or bash? FireRaven Programming 2 12-13-2011 05:56 AM
Question about outputing arrays with pointers, then just arrays... RHLinuxGUY Programming 1 04-12-2006 05:40 AM
Python: Need help making a simple program using arrays and loops Baix Programming 11 08-13-2005 11:26 PM
Class Arrays in Python rootyard Programming 1 02-13-2004 10:58 PM
QLA2200 Fabric HBA not in Fabric mode phillip rill Linux - Hardware 0 02-11-2004 03:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration