jborean93 / pypsexec

Remote Windows execution like PsExec on Python
MIT License
119 stars 38 forks source link

adapt to timezone-aware objects #58

Open MeggyCal opened 7 months ago

MeggyCal commented 7 months ago

Python 3.12 now strongly preffers timezone-aware datetime objects and some libraries have already been adapted to that. I didn't investigate which libraries, maybe the change is only a PR and we patched it in our distribution. However, the produced datetimes are now timezone-aware (or will be in near future) and this adapts pypsexec tests to this change.

jborean93 commented 7 months ago

This change seems to only be for testing files and not for datetimes produced by this library. The things it is testing seems to be from its dependency https://github.com/jborean93/smbprotocol which was fixed with https://github.com/jborean93/smbprotocol/pull/252.

While yes our test should be updated it should be updated so it's not using the deprecated datetime.utcfromtimestamp method but instead datetime.fromtimestamp(*args, tzinfo=timezone.utc).

MeggyCal commented 7 months ago

In my point of view it is better for the compatibility when the library accepts also timezone-naive datetimes, so I didn't want the changes to be too widespread. Anyway, should I make more changes? Where, how?

jborean93 commented 7 months ago

The changes in this PR are just for tests and not part of the actual codebase. It also continues to use the deprecated utcfromtimestamp method whereas it should be swapped to the fromtimestamp methods. While this should be fixed this is for tests only so it's not user facing.

MeggyCal commented 7 months ago

True, this is not user-facing, so it is not urgent to merge :smiling_face_with_tear: . And I agree this is more of a hotfix than improvement.

jborean93 commented 7 months ago

What I'm trying to say is I'm happy to merge this but it should be using the non-deprecated API fromtimestamp not the deprecated one utcfromtimestamp. Granted I've also not run CI in this repo for a while so there's bound to be other breakages.

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.52%. Comparing base (c5e8151) to head (13461e9).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #58 +/- ## ========================================== + Coverage 98.15% 98.52% +0.36% ========================================== Files 7 7 Lines 1085 1085 ========================================== + Hits 1065 1069 +4 + Misses 20 16 -4 ``` | [Flag](https://app.codecov.io/gh/jborean93/pypsexec/pull/58/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | Coverage Δ | | |---|---|---| | [](https://app.codecov.io/gh/jborean93/pypsexec/pull/58/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `98.52% <ø> (+0.36%)` | :arrow_up: | | [py3.10](https://app.codecov.io/gh/jborean93/pypsexec/pull/58/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `98.52% <ø> (+0.36%)` | :arrow_up: | | [py3.11](https://app.codecov.io/gh/jborean93/pypsexec/pull/58/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `98.52% <ø> (+0.36%)` | :arrow_up: | | [py3.7](https://app.codecov.io/gh/jborean93/pypsexec/pull/58/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `98.52% <ø> (+0.46%)` | :arrow_up: | | [py3.8](https://app.codecov.io/gh/jborean93/pypsexec/pull/58/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `98.43% <ø> (+0.46%)` | :arrow_up: | | [py3.9](https://app.codecov.io/gh/jborean93/pypsexec/pull/58/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `98.43% <ø> (+0.46%)` | :arrow_up: | | [x64](https://app.codecov.io/gh/jborean93/pypsexec/pull/58/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `98.52% <ø> (+0.36%)` | :arrow_up: | | [x86](https://app.codecov.io/gh/jborean93/pypsexec/pull/58/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `98.05% <ø> (-0.10%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.