Skip to content

Commit 333149a

Browse files
authored
Merge pull request #115 from duncanmmacleod/main-args
Support args in htgettoken.main()
2 parents d021811 + 7cf2e6a commit 333149a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

htgettoken.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ rm -rf $RPM_BUILD_ROOT
8181

8282
%changelog
8383
# - Fix htdecodetoken to work with token files that do not end in a newline.
84+
# - Support args in htgettoken.main() Python entry point.
8485

8586
* Thu Jul 25 2024 Dave Dykstra <dwd@fnal.gov> 2.0-2
8687
- Fix broken httokendecode symlink.

htgettoken/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ def ttl2secs(ttl, msg):
499499

500500

501501
### htgettoken main ####
502-
def main():
502+
def main(args=None):
503503
global options
504504
usagestr = "usage: %prog [-h] [otheroptions]"
505505
parser = OptionParser(usage=usagestr, version=version, prog=prog)
@@ -630,8 +630,10 @@ def main():
630630
# look for default options in the environment
631631
envopts = os.getenv("HTGETTOKENOPTS", "")
632632
envargs = shlex.split(envopts, True)
633+
if args is None:
634+
args = sys.argv[1:]
633635

634-
parseargs(parser, envargs + sys.argv[1:])
636+
parseargs(parser, envargs + list(args))
635637

636638
if options.optserver is not None:
637639
# read additional options from optserver

0 commit comments

Comments
 (0)