fabfile.py
changeset 302 3f4bdea2abbf
parent 301 d5ebbcccc41b
equal deleted inserted replaced
90:eb04ac3a8327 302:3f4bdea2abbf
       
     1 # Copyright (c) 2012 netzguerilla.net <iro@netzguerilla.net>
       
     2 # 
       
     3 # This file is part of Iro.
       
     4 # 
       
     5 # Permission is hereby granted, free of charge, to any person obtaining a copy of
       
     6 # this software and associated documentation files (the "Software"), to deal in
       
     7 # the Software without restriction, including without limitation the rights to use,
       
     8 # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
       
     9 # #Software, and to permit persons to whom the Software is furnished to do so,
       
    10 # subject to the following conditions:
       
    11 # 
       
    12 # The above copyright notice and this permission notice shall be included in
       
    13 # all copies or substantial portions of the Software.
       
    14 # 
       
    15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
       
    16 # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
       
    17 # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
       
    18 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
       
    19 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
       
    20 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
       
    21 
       
    22 from fabric.api import local, run, env 
       
    23 from fabric.operations import put
       
    24 
       
    25 from iro import __version__
       
    26 import ngdatabase
       
    27 
       
    28 ngmodules = {"directory": "/home/hefee/hg/ngmod/init",
       
    29         "version":ngdatabase.__version__}
       
    30 
       
    31 env.use_ssh_config = True
       
    32 
       
    33 def vbox():
       
    34     env.hosts = ['192.168.56.101']
       
    35     env.directory = '/home/hefee/iro/'
       
    36     env.activate = 'source /home/hefee/iro/virtualenv/bin/activate'
       
    37     env.deploy_user = 'hefee'
       
    38 
       
    39 
       
    40 def hal():
       
    41     env.hosts = ['sandy@hal.netzguerilla.net']
       
    42     env.directory = "iro"
       
    43 
       
    44 def iro():
       
    45     env.hosts = ['hal']
       
    46     env.directory = '/home/sandy/virtualenv/iro2/'
       
    47     env.activate = 'source /home/sandy/virtualenv/iro2/bin/activate'
       
    48     env.deploy_user = 'sandy'
       
    49 
       
    50 
       
    51 def prepare_deploy():
       
    52     local("python setup.py sdist")
       
    53 
       
    54 def virtualenv(cmd):
       
    55     run("%s && %s"  % (env.activate, cmd))
       
    56 
       
    57 def deploy():
       
    58     prepare_deploy()
       
    59     put("dist/iro-%s.tar.gz"%__version__,"%s/dist/"%env.directory)
       
    60     put("%(directory)s/dist/ngmodules-%(version)s.tar.gz"%ngmodules,"%s/dist/"%env.directory)
       
    61     virtualenv("pip install %s/dist/ngmodules-%s.tar.gz"%(env.directory,ngmodules["version"]))
       
    62     virtualenv("pip install -e 'git+git://github.com/hefee/txjsonrpc.git#egg=txjsonrpc'")
       
    63     virtualenv("pip uninstall -y iro")
       
    64     virtualenv("pip install %s/dist/iro-%s.tar.gz"%(env.directory,__version__))
       
    65 
       
    66 def prepare_tests():
       
    67     put("tests/*","%s/tests/"%env.directory)
       
    68 
       
    69 def startserver():
       
    70     run("cd %s && tar -xzf dist/iro-%s.tar.gz"%(env.directory,__version__))
       
    71     virtualenv("twistd -ny %s/iro-%s/extras/iro.tac"%(env.directory,__version__))
       
    72 
       
    73 def testserver():
       
    74    prepare_tests()
       
    75    virtualenv("python %s/tests/xmlrpc.py"%env.directory)
       
    76 
       
    77 def cleandoc():
       
    78     local("rm -rf _build/* web/dev/* web/*.html")
       
    79 
       
    80 def sphinxdoc():
       
    81     local("sphinx-build -b html -d _build/doctrees doc web/dev/")
       
    82 
       
    83 def createweb():
       
    84     prepare_deploy()
       
    85     cleandoc()
       
    86     local("mv dist/iro-%s.tar.gz web/files/"%__version__)
       
    87     local("python createdoc.py")
       
    88     sphinxdoc()
       
    89     local("tar -czf web.tar.gz web")
       
    90 
       
    91 def pushweb():
       
    92     put("web.tar.gz","/tmp/")
       
    93     run("tar -czf backup/iro.tar.gz iro/*")
       
    94     run("tar -xzf /tmp/web.tar.gz")
       
    95     run("rm -r iro/*")
       
    96     run("mv web/* %s/"%env.directory)
       
    97     run("rmdir web")
       
    98     run("rm /tmp/web.tar.gz")
       
    99 
       
   100 def web():
       
   101     createweb()
       
   102     pushweb()