From 27e84fb2e485fa7dc3e92e34d1f022bbf59c53f0 Mon Sep 17 00:00:00 2001 From: Yuanle Song Date: Thu, 8 Sep 2016 11:07:29 +0800 Subject: [PATCH] v0.13.0 add fabfile for deployment --- project.clj | 2 +- src/leiningen/new/python/fabfile.py | 36 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/leiningen/new/python/fabfile.py diff --git a/project.clj b/project.clj index f455f77..65257dc 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject python/lein-template "0.12.0" +(defproject python/lein-template "0.13.0" :description "lein template for a python project" :repositories [["snapshots" {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots" diff --git a/src/leiningen/new/python/fabfile.py b/src/leiningen/new/python/fabfile.py new file mode 100644 index 0000000..9a6ff78 --- /dev/null +++ b/src/leiningen/new/python/fabfile.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# coding=utf-8 + +""" +fabric file for server automation. +""" +# pylint: disable=line-too-long + +import os.path +from fabric.api import env, sudo, run, local, hosts, put, cd + +env.use_ssh_config = True +PROD_HOST = 'de01' + + +def get_version_from_setup_file(): + """parse version info from setup.py file. + + Return the version string. + + """ + with open("setup.py", "r") as f: + for line in f: + if "version=" in line: + return line.split("=")[1][1:-3] + raise Exception("version not found in setup.py") + + +@hosts(PROD_HOST) +def deploy(): + version = get_version_from_setup_file() + deb_file = "{{name}}_%s_amd64.deb" % (version,) + if not os.path.exists(deb_file): + local("make deb") + put(deb_file) + run("dpkg -i %s" % (deb_file,)) -- GitLab