-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use latest JLink installation DLL, not the oldest #19
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea behind this, but I think it needs a bit more work. I'd want the behaviour to be consistent across Windows/Linux/Mac. There's some tests around this, and comments about how the naming convention has changed from version-to-version and platform-to-platform, so we'd want a nice way of figuring out what is what version, then returning the newest versioned one we found. That way behaviour would be consistent, whereas os.listdir
isn't.
lib_path = os.path.join(dir_path, jlink_dir, dll) | ||
if os.path.isfile(lib_path): | ||
yield lib_path | ||
lib_path = os.path.join(dir_path, ds[-1], dll) # use the latest jlink DLL (ds[-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this won't necessarily return the newest version. os.listdir
returns the directories in the order specified by the underlying filesystem. In some cases, this is just the latest directory created, which is generally the latest installed version, but can be an older version if someone switches between versions often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree... However I am not sure I have the bandwidth and the environment to test it also on Linux and Mac.
A logic behavior would be to make the user either to pic a specific version and as default, if nothing is specified, use the latest.
Maybe somebody can improve this and provide implementation for Mac and Linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah, I like the idea of that behaviour. The reason why I said that listdir
might not be the best approach is that the order isn't guaranteed, so if we say that we always return the latest one, then we have to do some sorting in addition to listdir
. To sort properly, we'll need to handle the different file naming conventions that have been had over time.
Is it possible to do this in such a way that a user could specify a
specific version of the DLL? We've had cases in the past where only a very
specific version of the DLL would suffice (I'm thinking back to 4.98e
during the Great Blight of the 5.x release tree).
…On Tue, Feb 13, 2018 at 1:13 PM, Ford ***@***.***> wrote:
***@***.**** requested changes on this pull request.
I like the idea behind this, but I think it needs a bit more work. I'd
want the behaviour to be consistent across Windows/Linux/Mac. There's some
tests around this, and comments about how the naming convention has changed
from version-to-version and platform-to-platform, so we'd want a nice way
of figuring out what is what version, then returning the newest versioned
one we found. That way behaviour would be consistent, whereas os.listdir
isn't.
------------------------------
In pylink/library.py
<#19 (comment)>:
> @@ -114,12 +114,9 @@ def find_library_windows(cls):
# Find all the versioned J-Link directories.
ds = filter(lambda x: x.startswith('JLink'), os.listdir(dir_path))
- for jlink_dir in ds:
- # The DLL always has the same name, so if it is found, just
- # return it.
- lib_path = os.path.join(dir_path, jlink_dir, dll)
- if os.path.isfile(lib_path):
- yield lib_path
+ lib_path = os.path.join(dir_path, ds[-1], dll) # use the latest jlink DLL (ds[-1])
So this won't necessarily return the newest version. os.listdir returns
the directories in the order specified by the underlying filesystem. In
some cases, this is just the latest directory created, which is generally
the latest installed version, but can be an older version if someone
switches between versions often.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#19 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFtLiKqVXBauv1YHJHa6-OS8Ljy7GgB9ks5tUd7KgaJpZM4SD0su>
.
|
I believe so. Either allowing a specific version or using the latest version will require the same code changes; some way of mapping to versions, given that the naming conventions have changed over time. So one will give us the other. |
Sounds like a case for locale.strcoll!
…On Mon, Feb 26, 2018 at 12:00 PM, Ford ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pylink/library.py
<#19 (comment)>:
> @@ -114,12 +114,9 @@ def find_library_windows(cls):
# Find all the versioned J-Link directories.
ds = filter(lambda x: x.startswith('JLink'), os.listdir(dir_path))
- for jlink_dir in ds:
- # The DLL always has the same name, so if it is found, just
- # return it.
- lib_path = os.path.join(dir_path, jlink_dir, dll)
- if os.path.isfile(lib_path):
- yield lib_path
+ lib_path = os.path.join(dir_path, ds[-1], dll) # use the latest jlink DLL (ds[-1])
Yah, I like the idea of that behaviour. The reason why I said that listdir
might not be the best approach is that the order isn't guaranteed, so if we
say that we always return the latest one, then we have to do some sorting
in addition to listdir. To sort properly, we'll need to handle the
different file naming conventions that have been had over time.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#19 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFtLiCbuQy49FkDHmWDWQ0qhBMpTu_Quks5tYvElgaJpZM4SD0su>
.
|
|
In our use case, a problem occurred when using pylink, since it uses the first DLL found in C:\Program Files (x86)\SEGGER. This patch makes it use the newest one.
I think it is legit to suppose, that the newest version of JLink DLL is the less buggy and has the greatest support.