Source

django-fab-deploy / fab_deploy / vcs / none.py

The default branch has multiple heads

theoden 3bf25a1 
Den Ivanov 66832ee 
Mikhail Korobov 7cbb2ab 
theoden a9d9582 
Mikhail Korobov 7cbb2ab 
theoden e83e029 

theoden 3bf25a1 
theoden 848621d 
theoden 3b7bc1f 
theoden 3bf25a1 
Vladimir Mihaile… 2bf747a 

Mikhail Korobov 7484aa6 

Vladimir Mihaile… 2bf747a 
theoden 848621d 



theoden e83e029 
theoden 848621d 













Mikhail Korobov 7484aa6 
theoden 848621d 
theoden a9d9582 
Mikhail Korobov 7484aa6 


Mikhail Korobov 7cbb2ab 
theoden 3bf25a1 
Mikhail Korobov 7484aa6 




Mikhail Korobov 7cbb2ab 
Mikhail Korobov 7484aa6 


Mikhail Korobov 7cbb2ab 
Mikhail Korobov 7484aa6 


theoden a9d9582 





Mikhail Korobov 7484aa6 

theoden a9d9582 
Mikhail Korobov 7484aa6 


Mikhail Korobov 7cbb2ab 
theoden 3bf25a1 
Mikhail Korobov 7484aa6 

Mikhail Korobov 7cbb2ab 
theoden 3bf25a1 
Mikhail Korobov 7484aa6 

Mikhail Korobov 7cbb2ab 
theoden 3bf25a1 
Mikhail Korobov 7484aa6 

Mikhail Korobov 7cbb2ab 
Mikhail Korobov 7484aa6 
# coding: utf-8
from __future__ import with_statement
import os.path
import tempfile
from datetime import datetime
import codecs
import sys

from fabric.api import run, local, env, put, cd, warn
from taskset import TaskSet, task_method

from fab_deploy import utils

class PseudoVcs(TaskSet):
    BRANCH_OPTION = None

    def _extract_from_hgignore(self):
        """ Extracts list of exclusion patterns from .hgignore file. """
        excluded = []
        try:
            for str in codecs.open('.hgignore', 'rb', sys.getdefaultencoding()):
                str = str.strip()
                if str.startswith(('#', 'syntax: glob')) or str=='':
                    continue
                elif str=='syntax: regexp':
                    raise NotImplementedError('Regexp syntax is not supported.')
                else:
                    if str.startswith('*'):
                        excluded.append(str)
                    else:
                        excluded.append(utils._project_path(str))
        except IOError as e:
           warn('.hgignore file was not found. Nothing is excluded.')
        return excluded

    def _exclude_string(self):
        excludes = self._extract_from_hgignore()
        exclude_string = " ".join(['--exclude="%s"' % pattern for pattern in excludes])
        if os.path.exists('.excludes'):
            exclude_string =  "-X .excludes " + exclude_string
        return exclude_string

    @task_method
    def push(self, branch=None):
        """
        Upload the current project to a remote system, tar/gzipping during the move.
        Files listed at :file:`<project root>/.exclude` file wouldn't be uploaded
        (glob patterns are supported in .exclude file).

        This function makes use of the ``/tmp/`` directory and the ``tar`` and
        ``gzip`` programs/libraries; thus it will not work too well on Win32
        systems unless one is using Cygwin or something similar.

        This should be using ``fabric.contrib.project.upload_project``
        but upload_project doesn't support excludes.
        """
        tar_file = os.path.join(
            tempfile.gettempdir(),
            "fab.%s.tar" % datetime.utcnow().strftime('%Y_%m_%d_%H-%M-%S')
        )
        tarCommand = "tar %s -czf %s ." % (self._exclude_string(), tar_file)
        local(tarCommand)
        tgz_name = env.conf.SRC_DIR + '/' + env.conf.INSTANCE_NAME + ".tar.gz"
        put(tar_file, tgz_name)
        os.remove(tar_file)
        with cd(env.conf.SRC_DIR):
            run("tar -xzf " + tgz_name)
            run("rm -f " + tgz_name)

    @task_method
    def configure(self):
        pass

    @task_method
    def init(self):
        pass

    @task_method
    def up(self, branch):
        pass

instance = PseudoVcs()
__all__ = instance.expose_to_current_module()