document.open();document.writeln('<div onmouseover="document.getElementById(\'snipt-2337\').style.display = \'block\'; return false;" onmouseout="document.getElementById(\'snipt-2337\').style.display = \'none\'; return false;" style="position: relative;">');document.writeln('<div class="highlight" style="background: #202020"><pre style="-moz-border-radius: 5px; border-radius: 5px; -webkit-border-radius: 5px; margin: 0; display: block; font: 11px Monaco, monospace !important; padding: 15px; background-color: #1C1C1C; overflow: auto; color: #D0D0D0;; line-height: 125%"><span style="color: #6ab825; font-weight: normal">def</span> <span style="color: #447fcf">update</span><span style="color: #d0d0d0">():</span>');document.writeln('    <span style="color: #ed9d13">&quot;Update development MySQL database with production clone.&quot;</span>');document.writeln('');document.writeln('    <span style="color: #d0d0d0">require(</span>');document.writeln('        <span style="color: #ed9d13">&#39;prod_mysql_host&#39;</span><span style="color: #d0d0d0">,</span> <span style="color: #ed9d13">&#39;prod_mysql_user&#39;</span><span style="color: #d0d0d0">,</span> <span style="color: #ed9d13">&#39;prod_mysql_pass&#39;</span><span style="color: #d0d0d0">,</span> <span style="color: #ed9d13">&#39;prod_mysql_db&#39;</span><span style="color: #d0d0d0">,</span>');document.writeln('        <span style="color: #ed9d13">&#39;local_mysql_host&#39;</span><span style="color: #d0d0d0">,</span> <span style="color: #ed9d13">&#39;local_mysql_user&#39;</span><span style="color: #d0d0d0">,</span> <span style="color: #ed9d13">&#39;local_mysql_pass&#39;</span><span style="color: #d0d0d0">,</span> <span style="color: #ed9d13">&#39;local_mysql_db&#39;</span>');document.writeln('    <span style="color: #d0d0d0">)</span>');document.writeln('');document.writeln('    <span style="color: #999999; font-style: italic"># Run the database dump on the server and store as file.</span>');document.writeln('    <span style="color: #d0d0d0">run(</span><span style="color: #ed9d13">&quot;mysqldump --user=$(prod_mysql_user) --password=$(prod_mysql_pass) --host $(prod_mysql_host) $(prod_mysql_db) &gt; $(prod_mysql_db).dump&quot;</span><span style="color: #d0d0d0">)</span>');document.writeln('');document.writeln('    <span style="color: #999999; font-style: italic"># Download the database dump from the server and store as file.  Will be stored as $(prod_mysql_db).dump.$(fab_host).</span>');document.writeln('    <span style="color: #d0d0d0">download(</span><span style="color: #ed9d13">&#39;$(prod_mysql_db).dump&#39;</span><span style="color: #d0d0d0">,</span> <span style="color: #ed9d13">&#39;$(prod_mysql_db).dump&#39;</span><span style="color: #d0d0d0">)</span>');document.writeln('');document.writeln('    <span style="color: #999999; font-style: italic"># On our local workstation, create a fresh instance of the database and import the production dump into it.</span>');document.writeln('    <span style="color: #d0d0d0">local(</span><span style="color: #ed9d13">&quot;&quot;&quot;</span>');document.writeln('<span style="color: #ed9d13">        `mysql -u$(local_mysql_user) -p$(local_mysql_pass) -h$(local_mysql_host) &amp;lt;&amp;lt; EOF</span>');document.writeln('<span style="color: #ed9d13">        DROP DATABASE IF EXISTS $(local_mysql_db);</span>');document.writeln('<span style="color: #ed9d13">        CREATE DATABASE $(local_mysql_db);</span>');document.writeln('<span style="color: #ed9d13">        exit`</span>');document.writeln('');document.writeln('<span style="color: #ed9d13">        `mysql -u$(local_mysql_user) -p$(local_mysql_pass) -h$(local_mysql_host) $(local_mysql_db) &amp;lt; $(prod_mysql_db).dump.$(fab_host)`</span>');document.writeln('<span style="color: #ed9d13">    &quot;&quot;&quot;</span><span style="color: #d0d0d0">)</span>');document.writeln('');document.writeln('<span style="color: #6ab825; font-weight: normal">def</span> <span style="color: #447fcf">deploy</span><span style="color: #d0d0d0">(**kwargs):</span>');document.writeln('    <span style="color: #ed9d13">&quot;Deploy code changes to the production server.&quot;</span>');document.writeln('');document.writeln('    <span style="color: #999999; font-style: italic"># If a message is provided (fab deploy:m=&#39;a message&#39;), run an SVN commit, first.</span>');document.writeln('    <span style="color: #6ab825; font-weight: normal">if</span> <span style="color: #ed9d13">&#39;m&#39;</span> <span style="color: #6ab825; font-weight: normal">in</span> <span style="color: #d0d0d0">kwargs:</span>');document.writeln('        <span style="color: #24909d">set</span><span style="color: #d0d0d0">(message</span> <span style="color: #d0d0d0">=</span> <span style="color: #d0d0d0">kwargs[</span><span style="color: #ed9d13">&#39;m&#39;</span><span style="color: #d0d0d0">])</span>');document.writeln('        <span style="color: #d0d0d0">local(</span><span style="color: #ed9d13">&quot;svn ci -m &#39;$(message)&#39;&quot;</span><span style="color: #d0d0d0">)</span>');document.writeln('    <span style="color: #6ab825; font-weight: normal">else</span><span style="color: #d0d0d0">:</span>');document.writeln('        <span style="color: #d0d0d0">local(</span><span style="color: #ed9d13">&quot;echo &#39;WARNING: running deploy without SVN commit.\\n##########&#39;&quot;</span><span style="color: #d0d0d0">)</span>');document.writeln('    <span style="color: #d0d0d0">run(</span><span style="color: #ed9d13">&quot;svn update $(prod_dir)&quot;</span><span style="color: #d0d0d0">)</span>');document.writeln('</pre></div>');document.writeln('');document.writeln('<div style="background-color: #111; color: #D0D0D0; float: right; padding: 5px 10px; -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; font: 11px Arial,Sans-Serif; display: none; position: absolute; bottom: 0; right: 0;" id="snipt-2337">code hosted by <a href="http://snipt.net/nick/common-fabric-functions-for-deploying-and-updating-projects" style="color: #0084FF; text-decoration: none;">snipt.net</a></div>');document.writeln('</div>');document.close();