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 = '.'
def main(argv): parser = ArgumentParser(description='get information about a gitfs filesystem') parser.add_argument('-r', '--find-root', action='append') cmdline = parser.parse_args(argv[1:]) if 'find_root' in cmdline and cmdline.find_root is not None: for i in cmdline.find_root: c = GitFSClient.getClientByID(i) if c is not None: r = c.getMountPoint() if r is not None: print '%s\n' %r
def main(argv): parser = ArgumentParser( description='get information about a gitfs filesystem') parser.add_argument('-r', '--find-root', action='append') cmdline = parser.parse_args(argv[1:]) if 'find_root' in cmdline and cmdline.find_root is not None: for i in cmdline.find_root: c = GitFSClient.getClientByID(i) if c is not None: r = c.getMountPoint() if r is not None: print '%s\n' % r
def __init__(self, origin, branch="master", path="."): self.origin = origin self.branch = branch self.root = os.path.realpath(path) self.halt = False self.rwlock = Lock() # 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.timer = None self.handlers = { "ping": self._handlePing, "lock": self._handleLock, "unlock": self._handleUnlock, "info": self._handleInfo, } self.lock_timer = None self.lock_lock = Condition() self.locks = {} self.lock_expire_time = time() self.control_dir = self.getControlDirectory(self.root) try: os.mkdir(self.control_dir) except OSError: pass self.control_socket_path = self.getControlSocketPath(self.root) client = GitFSClient(self.root) self.needSyncTime = None try: if client.pingRemote(): # There is another file system mounted. logging.debug("Exiting because file system already mounted.\n") raise FuseOSError(EBUSY) except socket.error as se: logging.debug("socket.error = %s" % se) pass client.close() client = None 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() self.repo = GitRepo(path, origin, branch, sync=True) self.sync_thread = Thread(target=self._sync, args=()) self.sync_thread.start()
def displayAndWait(self): if self.ssh is not None: self.ssh.displayAndWait() if __name__ == '__main__': logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) parser = ArgumentParser(description='execute ') parser.add_argument('-r', '--remote', action='store_true', default = False) parser.add_argument('-p', '--path') parser.add_argument('-i', '--id') parser.add_argument('-c', '--command') cmdline = parser.parse_args(argv[1:]) if cmdline.remote: client = GitFSClient.getClientByID(cmdline.id) if client is None: print >> sys.stderr, 'Unable to locate gitfs file system %s' %cmdline.id exit(1) os.chdir(os.path.join(client.getMountPoint(), cmdline.path)) client.sync() subprocess.call(cmdline.command, shell=True) exit(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()
# 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()
""" 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'
if __name__ == "__main__": logging.basicConfig(stream=sys.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) p, f = os.path.split(cmdline.directory) f = "." + f d = os.path.join(p, f) os.chdir(d) client = GitFSClient(d) 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.lockRemoteAndHold() try: # now do the pull/push combination. # XXXXX Fixme: need a library to access git, not just shelling out. call("git commit -a", shell=True) call('git pull "%s" "%s"' % (info["origin"], info["branch"]), shell=True)
parser.add_argument("directory") cmdline = parser.parse_args(argv[1:]) logging.debug("cmdline=%s" % cmdline) if options["remote"]: os.cwd(options["directory"]) sys.execvp("make".options["args"]) raise Exception("Can't Happen") p, f = os.path.split(cmdline.directory) f = "." + f d = os.path.join(p, f) os.chdir(d) client = GitFSClient(d) 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.lockRemoteAndHold() try: # now do the pull/push combination. # XXXXX Fixme: need a library to access git, not just shelling out. call("git commit -a", shell=True) call('git pull "%s" "%s"' % (info["origin"], info["branch"]), shell=True)
""" 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'
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()