Exemplo n.º 1
0
 def changeLockName(self, oldName, newName):
     self.update()
     oldfilepath = os.path.join(self._path,
                                files.userNameToFileName(oldName))
     newNamepath = os.path.join(self._path,
                                files.userNameToFileName(newName))
     self.UNSAFEsetLockInfo(newNamepath,
                            self.UNSAFEgetLockInfo(oldfilepath))
     os.remove(oldfilepath)
     return self._git.commitPushOrFail("CHANGE LOCK NAME {}".format(
         oldName, newName))
Exemplo n.º 2
0
 def userHasLock(self, glyph):
     filepath = os.path.join(self._path,
                             files.userNameToFileName(glyph.name))
     # UNSAFE is OK because if we have the lock, then the file cannot (in
     # theory!) be changed by someone else
     li = self.UNSAFEgetLockInfo(filepath)
     return li.user == self._username
Exemplo n.º 3
0
 def potentiallyOutdatedLockingUser(self, g):
     """Returns the user having the lock on 'g', or None"""
     filepath = os.path.join(self._path, files.userNameToFileName(g.name))
     li = self.UNSAFEgetLockInfo(filepath)
     if li.lock == 0:
         return None
     return li.user
Exemplo n.º 4
0
 def unlock(self, g):
     filepath = os.path.join(self._path, files.userNameToFileName(g.name))
     li = self.getLockInfo(filepath)
     print("Locker UNLOCK", filepath)
     if not li.lock: return True  # Already unlocked
     if li.user != self._username: return False  # Locked by someone else
     li.lock = 0
     li.user = '******'
     return self.setLockInfo(filepath, li, g, 'unlock')
Exemplo n.º 5
0
 def batchLock(self, glyphs):
     self.update()
     print("Locker BATCH LOCK")
     for g in glyphs:
         filepath = os.path.join(self._path,
                                 files.userNameToFileName(g.name))
         li = self.UNSAFEgetLockInfo(filepath)
         if li.lock: continue
         if li.user == self._username: continue
         li.lock = 1
         li.user = self._username
         self.UNSAFEsetLockInfo(filepath, li, g)
     return self._git.commitPushOrFail("BATCH UNLOCK for {}".format(
         self._username))
Exemplo n.º 6
0
 def lock(self, g):
     """ First returned boolean indicate if lock was succesful.
         Second returned boolean indicate if user already had the lock."""
     filepath = os.path.join(self._path, files.userNameToFileName(g.name))
     li = self.getLockInfo(filepath)
     print("Locker LOCK", filepath)
     if li.lock:
         lockedByMe = li.user == self._username
         return (lockedByMe, lockedByMe
                 )  # return True if its already locked by local user
     li.lock = 1
     li.user = self._username
     # return True if remote repo succesfully updated
     return (self.setLockInfo(filepath, li, g, 'lock'), False)
Exemplo n.º 7
0
 def removeFiles(self, names):
     for name in names:
         fileName = files.userNameToFileName(name)
         filePath = os.path.join(self._path, fileName)
         os.remove(filePath)