[projects/pld-ftp-admin] pfa-unlocktree: use argparse, add --help

arekm arekm at pld-linux.org
Sat Oct 24 11:46:59 CEST 2026


commit 6915689ee378028493c8d831a29afee2d593069c
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Oct 20 15:45:47 2026 +0200

    pfa-unlocktree: use argparse, add --help

 bin/pfa-unlocktree | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/bin/pfa-unlocktree b/bin/pfa-unlocktree
index fc78aae..3c24bd9 100755
--- a/bin/pfa-unlocktree
+++ b/bin/pfa-unlocktree
@@ -1,19 +1,20 @@
 #!/usr/bin/env python3
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
-from __future__ import print_function
+import argparse
+import os
+import sys
 
-import sys, os
+parser = argparse.ArgumentParser(
+    description='Remove ftpiod locks, e.g. ones left behind by a killed script.')
+parser.add_argument('trees', nargs='+', metavar='tree',
+    help='lock to remove: an ftp tree name like test, or another lock listed by pfa-dump-locks')
+args = parser.parse_args()
+
+# config reads ~/.ftpadmrc on import; parse options first so --help works without it
 sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-import ftptree
 import ftpio
-import config
-
-if len(sys.argv) < 2:
-    print("ERR: not enough parameters given")
-    print("unlock.py tree")
-    sys.exit(1)
 
-for tree in sys.argv[1:]:
+for tree in args.trees:
     ftpio.connect()
     print("Unlock %s: %s" % (tree, ftpio.unlock(tree)))
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/e14cb7d4d74f8bdd9368d9645ecaf49593cf6335



More information about the pld-cvs-commit mailing list