carp: Check-in [351a066801]

A python graphical and terminal EncFS front-end

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix bad lock file path
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:351a066801b9a1e83edf47b354e12bf263a9e5a31b9ad8f5338ef2d5c3ee4419
User & Date: milouse 2017-02-17 17:42:11
Context
2017-02-20
08:25
[UPD] Bump version to 0.5.3 check-in: 0a0862df1e user: milouse tags: trunk, v0.5.3
2017-02-17
17:42
Fix bad lock file path check-in: 351a066801 user: milouse tags: trunk
08:42
Fix #5 - is_locked method crashed as subprocess.CalledProcessError was not escaped check-in: 713c4f5c80 user: milouse tags: trunk, v0.5.2
Changes

Changes to carp/stash_manager.py.

400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416




417

418
419
420
421
422
423
424
...
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
        if "mount" in opts and opts["mount"]:
            opts["stash"] = stash_name
            self.stashes[stash_name] = self.init_stash(stash_name)
            return self.mount(opts)

        return True

    def ssh_command(self, stash_name):
        if stash_name not in self.stashes:
            return None
        if not self.stashes[stash_name]["remote_path"]:
            return None

        ssh_parts = self.stashes[stash_name]["remote_path"].split(":")
        if len(ssh_parts) != 2:
            return None





        return ["ssh", ssh_parts[0], "ls", os.path.join(ssh_parts[1], "lock*")]


    def is_locked(self, stash_name):
        ssh_cmd = self.ssh_command(stash_name)
        if not ssh_cmd:
            return False

        try:
................................................................................

        self.locked_by = [re.sub(r"^.*/lock\.(.+)$", "\\1", lock_name)
                          for lock_name in cmd.stdout.decode().split()]

        return True

    def create_lock(self, stash_name):
        ssh_cmd = self.ssh_command(stash_name)
        if not ssh_cmd:
            return False

        ssh_cmd[2] = "touch"
        ssh_cmd[3] = "lock.{}".format(os.uname().nodename)
        subprocess.run(ssh_cmd)

        return self.is_locked(stash_name)

    def remove_lock(self, stash_name):
        ssh_cmd = self.ssh_command(stash_name)
        if not ssh_cmd:
            return False

        ssh_cmd[2] = "rm"
        ssh_cmd[3] = "lock.{}".format(os.uname().nodename)
        subprocess.run(ssh_cmd, stderr=subprocess.DEVNULL)

        return not self.is_locked(stash_name)

    def mount(self, opts):
        test_run = "test" in opts and opts["test"]
        stash_name = opts["stash"]







|









>
>
>
>
|
>







 







|



<
<





|



<
<







400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
...
435
436
437
438
439
440
441
442
443
444
445


446
447
448
449
450
451
452
453
454


455
456
457
458
459
460
461
        if "mount" in opts and opts["mount"]:
            opts["stash"] = stash_name
            self.stashes[stash_name] = self.init_stash(stash_name)
            return self.mount(opts)

        return True

    def ssh_command(self, stash_name, action="ls"):
        if stash_name not in self.stashes:
            return None
        if not self.stashes[stash_name]["remote_path"]:
            return None

        ssh_parts = self.stashes[stash_name]["remote_path"].split(":")
        if len(ssh_parts) != 2:
            return None

        lock_file = "lock*"
        if action != "ls":
            lock_file = "lock.{}".format(os.uname().nodename)

        return ["ssh", ssh_parts[0], action,
                os.path.join(ssh_parts[1], lock_file)]

    def is_locked(self, stash_name):
        ssh_cmd = self.ssh_command(stash_name)
        if not ssh_cmd:
            return False

        try:
................................................................................

        self.locked_by = [re.sub(r"^.*/lock\.(.+)$", "\\1", lock_name)
                          for lock_name in cmd.stdout.decode().split()]

        return True

    def create_lock(self, stash_name):
        ssh_cmd = self.ssh_command(stash_name, "touch")
        if not ssh_cmd:
            return False



        subprocess.run(ssh_cmd)

        return self.is_locked(stash_name)

    def remove_lock(self, stash_name):
        ssh_cmd = self.ssh_command(stash_name, "rm")
        if not ssh_cmd:
            return False



        subprocess.run(ssh_cmd, stderr=subprocess.DEVNULL)

        return not self.is_locked(stash_name)

    def mount(self, opts):
        test_run = "test" in opts and opts["test"]
        stash_name = opts["stash"]