示例#1
0
 def __init__(self, command, path=os.getcwd()):
     self.command = command;
     path = os.path.realpath(os.path.abspath(path))
     self.client = GitFSClient.getClientByPath(path)
     self.path = self.client.makeRootRelative(path)
     if self.path is None or self.path == '':
         self.path = '.'
示例#2
0
    def __init__(self, origin, branch='master', path='.', mount_point='.'):
        super(GitFS, self).__init__()
        self.origin = origin
        self.branch = branch
        self.root = os.path.realpath(path)
        self.mount_point = mount_point
        self.halt = False
        self.rwlock = Lock()
        self.need_sync_time = None
        # Can't use the default rlock here since we want to acquire/release from different threads
        self.sync_c = Condition(Lock())
        self.timer_c = Condition(Lock())

        self.id = None
        self.timer = None
        self.handlers = {
            'ping': self._handlePing,
            'lock': self._handleLock,
            'unlock': self._handleUnlock,
            'info': self._handleInfo,
            'getConfig': self._getConfig
        }
        self.lock_timer = None
        self.lock_lock = Condition()
        self.locks = {}
        self.lock_expire_time = time()

        self.control_dir = self.getControlDirectory()
        try:
            os.makedirs(self.control_dir)
        except OSError:
            pass

        self.info_dir = self.getInfoDirectory(self.root)
        try:
            os.makedirs(self.info_dir)
        except OSError:
            pass

        self.control_socket_path = self.getControlSocketPath(self.getID(),
                                                             server=True)
        self.lockGitFSDir()
        try:
            try:
                client = GitFSClient.getClientByPath(self.mount_point, False,
                                                     False)
                raise FuseOSError(EBUSY)

            except GitFSError:
                pass

            try:
                os.remove(self.control_socket_path)
            except OSError:
                pass

            self.control_server = None
            self.control_server = ThreadingUnixStreamServer(
                self.control_socket_path,
                type(
                    "GitFSRequestHandler",
                    (PacketizeMixIn, BaseRequestHandler, object),
                    dict(fs=self,
                         dictFromString=self.parseDict,
                         stringFromDict=self.marshalDict,
                         handleDict=lambda s, d: s.fs._handleRequest(s, d))))
            self.control_server.daemon_threads = True

            # setup the threads last so that they don't prevent an exit.
            self.control_thread = Thread(
                target=self.control_server.serve_forever, args=())
            self.control_thread.start()

        finally:
            self.unlockGitFSDir()

        mt = self.getMTab()
        mt[mount_point] = self.getID()
        self.updateMTab(mt)

        self.repo = GitRepo(path, origin, branch, sync=True)
        self.sync_thread = Thread(target=self._sync, args=())
        self.sync_thread.start()
示例#3
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
"""gsync grabs a lock on the filesystem, then does a pull/push.  This syncs the local to the remote.  Useful before
intiating a remote build.
"""

import logging

from argparse import ArgumentParser
from sys import argv, exit, stderr
from GitFSClient import GitFSClient

if __name__ == "__main__":
    logging.basicConfig(stream=stderr, level=logging.DEBUG)
    parser = ArgumentParser(description='sync a local filesystem with the remote sourde.')
    parser.add_argument('directory')
    
    cmdline = parser.parse_args(argv[1:])
    logging.debug('cmdline=%s' %cmdline)

    client = GitFSClient.getClientByPath(cmdline.directory)
    client.sync()
    
示例#4
0
文件: gbuild.py 项目: imclab/GitFS
"""

import logging
import os
import sys

from argparse import ArgumentParser
from sys import argv, exit
from subprocess import call
from GitFSClient import GitFSClient
from gsh import GSH

if __name__ == "__main__":
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
    cwd = os.getcwd()
    client = GitFSClient.getClientByPath(cwd)
    info=client.getInfoRemote()
    logging.debug("received info: %s" %info)
    
    if 'origin' not in info:
        info['origin'] = 'origin'
    if 'branch' not in info:
        info['branch'] = 'master'
        
    client.sync()

    # Now, we need to run the remote version.
    host = client.getConfigForInstance('build_host')
    if host is None:
        host='localhost'
        
示例#5
0
"""

import logging
import os
import sys

from argparse import ArgumentParser
from sys import argv, exit
from subprocess import call
from GitFSClient import GitFSClient
from gsh import GSH

if __name__ == "__main__":
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
    cwd = os.getcwd()
    client = GitFSClient.getClientByPath(cwd)
    info = client.getInfoRemote()
    logging.debug("received info: %s" % info)

    if 'origin' not in info:
        info['origin'] = 'origin'
    if 'branch' not in info:
        info['branch'] = 'master'

    client.sync()

    # Now, we need to run the remote version.
    host = client.getConfigForInstance('build_host')
    if host is None:
        host = 'localhost'
示例#6
0
文件: GitFS.py 项目: rossbiro/GitFS
    def __init__(self, origin, branch="master", path=".", mount_point="."):
        super(GitFS, self).__init__()
        self.origin = origin
        self.branch = branch
        self.root = os.path.realpath(path)
        self.mount_point = mount_point
        self.halt = False
        self.rwlock = Lock()
        self.need_sync_time = None
        # Can't use the default rlock here since we want to acquire/release from different threads
        self.sync_c = Condition(Lock())
        self.timer_c = Condition(Lock())

        self.id = None
        self.timer = None
        self.handlers = {
            "ping": self._handlePing,
            "lock": self._handleLock,
            "unlock": self._handleUnlock,
            "info": self._handleInfo,
            "getConfig": self._getConfig,
        }
        self.lock_timer = None
        self.lock_lock = Condition()
        self.locks = {}
        self.lock_expire_time = time()

        self.control_dir = self.getControlDirectory()
        try:
            os.makedirs(self.control_dir)
        except OSError:
            pass

        self.info_dir = self.getInfoDirectory(self.root)
        try:
            os.makedirs(self.info_dir)
        except OSError:
            pass

        self.control_socket_path = self.getControlSocketPath(self.getID(), server=True)
        self.lockGitFSDir()
        try:
            try:
                client = GitFSClient.getClientByPath(self.mount_point, False, False)
                raise FuseOSError(EBUSY)

            except GitFSError:
                pass

            try:
                os.remove(self.control_socket_path)
            except OSError:
                pass

            self.control_server = None
            self.control_server = ThreadingUnixStreamServer(
                self.control_socket_path,
                type(
                    "GitFSRequestHandler",
                    (PacketizeMixIn, BaseRequestHandler, object),
                    dict(
                        fs=self,
                        dictFromString=self.parseDict,
                        stringFromDict=self.marshalDict,
                        handleDict=lambda s, d: s.fs._handleRequest(s, d),
                    ),
                ),
            )
            self.control_server.daemon_threads = True

            # setup the threads last so that they don't prevent an exit.
            self.control_thread = Thread(target=self.control_server.serve_forever, args=())
            self.control_thread.start()

        finally:
            self.unlockGitFSDir()

        mt = self.getMTab()
        mt[mount_point] = self.getID()
        self.updateMTab(mt)

        self.repo = GitRepo(path, origin, branch, sync=True)
        self.sync_thread = Thread(target=self._sync, args=())
        self.sync_thread.start()