Skip to content

Commit

Permalink
Python: Remove the 'max_port' argument from port4me(). This is (a) to…
Browse files Browse the repository at this point in the history
… harmonize with the R API, and (b) to be conservative for now and only provide a minimal API. We can revisit this later and grow it as needed. [#60]
  • Loading branch information
HenrikBengtsson committed Jan 10, 2024
1 parent 315733a commit d58b54e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 9 additions & 5 deletions python/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Version (development version)

## Significant Changes

* Remove the `max_port` argument from `port4me()`.

## Miscellaneous

* Add unit test asserting that a bound port is detected as such.
* Add unit test asserting that a bound port is detected as such.

## Bug Fixes

* `port4me(test = port)` would throw an `OSError` exception instead of
returning `False` if the port was busy.
* `port4me(test = port)` would throw an `OSError` exception instead
of returning `False` if the port was busy.

* `port4me(list = 0)` would behave like `list = 1`. Now it gives it
produces an error.
* `port4me(list = 0)` would behave like `list = 1`. Now it gives it
produces an error.


# Version 0.6.0 [2023-07-13]
Expand Down
8 changes: 3 additions & 5 deletions python/port4me/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from os import getenv


__version__ = "0.6.0-9009"
__version__ = "0.6.0-9010"
__all__ = ["port4me", "port4me_gen"]


Expand Down Expand Up @@ -136,7 +136,7 @@ def port4me_gen(tool=None, user=None, prepend=None, include=None, exclude=None,


def port4me(tool=None, user=None, prepend=None, include=None, exclude=None, skip=None,
list=None, test=None, max_tries=65535, must_work=True, min_port=1024, max_port=65535):
list=None, test=None, max_tries=65535, must_work=True, min_port=1024):
"""
Find a free TCP port using a deterministic sequence of ports based on the current username.
Expand Down Expand Up @@ -167,15 +167,13 @@ def port4me(tool=None, user=None, prepend=None, include=None, exclude=None, skip
If True, then an error is produced if no port could be found. If False, then `-1` is returned.
min_port : int, optional
Skips any ports that are smaller than this
max_port : int, optional
Skips any ports that are larger than this
"""
if test:
return is_port_free(test)

tries = 1

gen = port4me_gen(tool, user, prepend, include, exclude, min_port, max_port)
gen = port4me_gen(tool, user, prepend, include, exclude, min_port)

if skip is None:
skip = getenv("PORT4ME_SKIP", "0")
Expand Down

0 comments on commit d58b54e

Please sign in to comment.