From mhammond at skippinet.com.au Mon May 2 03:59:10 2022
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Mon, 2 May 2022 17:59:10 +1000
Subject: [python-win32] [ANN] pywin32 build 304 released
Message-ID: <8b489081-e055-7203-d923-c57e06b98f55@skippinet.com.au>
Hi all,
I'm happy to announce the release of pywin32 build 304. There are a
number of changes in this release with the significant ones listed below.
Note:
* There are no .exe installers for 32-bit 3.10+ due to Python dropping
support for bdist_wininst.
* arm64 wheels for 3.10 and 3.11 64bit versions are available on pypi.
Downloads are available at:
https://github.com/mhammond/pywin32/releases/tag/b304
and via pypi.
For initial support (eg, to ask questions about the release etc), please
contact this mailing-list (python-win32 at python.org). If you want to
report a bug, please do so at https://github.com/mhammond/pywin32/issues
As always, thanks to everyone who contributed to this release, both in
terms of code and reporting bugs - there were a number of new
contributors which is great to see,
Cheers,
Mark.
Changes:
Since build 303:
----------------
* Fixed Unicode issues in the `dde` module (#1861, @markuskimius )
* Add `PRINTER_INFO_6` support for Set/GetPrinter (#1853, @CristiFati)
* Fixed codepage/mojibake issues when non-ascii characters were included
in COM exceptions raised by Python apps. This should be invisible, but
might break any workarounds which were used, such as using specific
encodings in these strings. (#1823, #1833)
* Fixed a bug triggering `win32print.SetJob` to fail due to data type
(`char*` / `wchar_t*`) mismatch (#1849, @CristiFati)
* Fix eventlog initialization (#1845, #1846, @kxrob)
From steven at manross.net Mon May 2 15:31:15 2022
From: steven at manross.net (Steven Manross)
Date: Mon, 2 May 2022 19:31:15 +0000
Subject: [python-win32] [ANN] pywin32 build 304 released
In-Reply-To: <8b489081-e055-7203-d923-c57e06b98f55@skippinet.com.au>
References: <8b489081-e055-7203-d923-c57e06b98f55@skippinet.com.au>
Message-ID: <7c2e3efde60d45728dbc3833910f8fb5@manross.net>
Thanks for the new version!
Considering I've been on build 227 forever, I tried upgrading my webserver's pywin32 build to 304 with a base of Activestate Python 3.8 (64-bit), and now I'm getting errors in my ASP pages ("500" Server Error), and in ipython (below).
Ive done all the normal things like restarting IIS, restarting the server, etc. Ive also uninstalled, removed site-packages\win32 (and win32com + win32ext) and then reinstalled pywin32 (pip install pywin32==304).
Any thoughts would be appreciated.
I have a backup of the server from last night I can restore from if all else fails.
Hopefully the ipython output helps understand where the error is (specified procedure could not be found).
Please and Thank You for any suggestions,
Steven
----------------------------------------
Test ASP page:
Test
<% @ Language = Python %>
<%
Response.Write("Test 2 ")
%>
--------
C:\Users\someuser>ipython
Python 3.8.2 (default, Aug 25 2020, 15:54:26) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import win32api
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in
----> 1 import win32api
ImportError: DLL load failed while importing win32api: The specified procedure could not be found.
-----Original Message-----
From: python-win32 On Behalf Of Mark Hammond
Sent: Monday, May 02, 2022 12:59 AM
To: python-win32 at python.org
Subject: [python-win32] [ANN] pywin32 build 304 released
Hi all,
I'm happy to announce the release of pywin32 build 304. There are a
number of changes in this release with the significant ones listed below.
Note:
* There are no .exe installers for 32-bit 3.10+ due to Python dropping
support for bdist_wininst.
* arm64 wheels for 3.10 and 3.11 64bit versions are available on pypi.
Downloads are available at:
https://github.com/mhammond/pywin32/releases/tag/b304
and via pypi.
For initial support (eg, to ask questions about the release etc), please
contact this mailing-list (python-win32 at python.org). If you want to
report a bug, please do so at https://github.com/mhammond/pywin32/issues
As always, thanks to everyone who contributed to this release, both in
terms of code and reporting bugs - there were a number of new
contributors which is great to see,
Cheers,
Mark.
Changes:
Since build 303:
----------------
* Fixed Unicode issues in the `dde` module (#1861, @markuskimius )
* Add `PRINTER_INFO_6` support for Set/GetPrinter (#1853, @CristiFati)
* Fixed codepage/mojibake issues when non-ascii characters were included
in COM exceptions raised by Python apps. This should be invisible, but
might break any workarounds which were used, such as using specific
encodings in these strings. (#1823, #1833)
* Fixed a bug triggering `win32print.SetJob` to fail due to data type
(`char*` / `wchar_t*`) mismatch (#1849, @CristiFati)
* Fix eventlog initialization (#1845, #1846, @kxrob)
_______________________________________________
python-win32 mailing list
python-win32 at python.org
https://mail.python.org/mailman/listinfo/python-win32
From mhammond at skippinet.com.au Mon May 2 19:40:40 2022
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Tue, 3 May 2022 09:40:40 +1000
Subject: [python-win32] [ANN] pywin32 build 304 released
In-Reply-To: <7c2e3efde60d45728dbc3833910f8fb5@manross.net>
References: <8b489081-e055-7203-d923-c57e06b98f55@skippinet.com.au>
<7c2e3efde60d45728dbc3833910f8fb5@manross.net>
Message-ID: <3e29d150-5308-2b35-4ee5-d3a466fae384@skippinet.com.au>
On 3/05/2022 5:31 am, Steven Manross wrote:
> Thanks for the new version!
>
> Considering I've been on build 227 forever, I tried upgrading my webserver's pywin32 build to 304 with a base of Activestate Python 3.8 (64-bit), and now I'm getting errors in my ASP pages ("500" Server Error), and in ipython (below).
The README has a section dedicated to this -
https://github.com/mhammond/pywin32/blob/main/README.md#the-specified-procedure-could-not-be-found--entry-point-not-found-errors
- tl;dr, you probably have duplicate pywin32 DLLs installed, possibly
because the different versions were installed using different techniques.
Cheers,
Mark
From steven at manross.net Mon May 2 20:01:08 2022
From: steven at manross.net (Steven Manross)
Date: Tue, 3 May 2022 00:01:08 +0000
Subject: [python-win32] [ANN] pywin32 build 304 released
In-Reply-To: <3e29d150-5308-2b35-4ee5-d3a466fae384@skippinet.com.au>
References: <8b489081-e055-7203-d923-c57e06b98f55@skippinet.com.au>
<7c2e3efde60d45728dbc3833910f8fb5@manross.net>
<3e29d150-5308-2b35-4ee5-d3a466fae384@skippinet.com.au>
Message-ID: <8099a123a79243659fef18b96f908bfd@manross.net>
Solved. Huge thanks for pointing me to what I should have read to begin with. ? ?
Thank you very much!
In case anyone finds this thread...
Solution was to run:
# cd \python38 (where my python was installed):
# python Scripts/pywin32_postinstall.py -install
... per the link Mark provided (post install script is a little above this entry point in the article).
https://github.com/mhammond/pywin32/blob/main/README.md#the-specified-procedure-could-not-be-found--entry-point-not-found-errors
Steven
-----Original Message-----
From: Mark Hammond
Sent: Monday, May 02, 2022 4:41 PM
To: Steven Manross ; python-win32 at python.org
Subject: Re: [python-win32] [ANN] pywin32 build 304 released
On 3/05/2022 5:31 am, Steven Manross wrote:
> Thanks for the new version!
>
> Considering I've been on build 227 forever, I tried upgrading my webserver's pywin32 build to 304 with a base of Activestate Python 3.8 (64-bit), and now I'm getting errors in my ASP pages ("500" Server Error), and in ipython (below).
The README has a section dedicated to this -
https://github.com/mhammond/pywin32/blob/main/README.md#the-specified-procedure-could-not-be-found--entry-point-not-found-errors
- tl;dr, you probably have duplicate pywin32 DLLs installed, possibly
because the different versions were installed using different techniques.
Cheers,
Mark
From baschni at gmail.com Wed May 11 02:58:30 2022
From: baschni at gmail.com (Bastian Schnitzler)
Date: Wed, 11 May 2022 08:58:30 +0200
Subject: [python-win32] Using win32com.shell to browse iphone photos |
problem with pywebview
Message-ID:
Hello,
I want to use win32com to transfer photos from my iphone to my
computer (I found a code snippet here, that worked for me:
https://gitlab.com/lassi.niemisto/iphone-photo-dump/).
In addition I would like to use pywebview to build a GUI.
Behaviour of the shell listing the resource "My computer" is
unexpected when I access the win32com functions through pywebview as
it is not showing my iphone then.
Here is a minimal working example (you may have to replace the String
== "Dieser PC" according to the language of your windows):
from win32com.shell import shell, shellcon
from webview import create_window, start, windows
class Api():
def listFoldersDieserPC(self):
folder = shell.SHGetDesktopFolder()
for item in folder:
print("loop: ", folder.GetDisplayNameOf(item,
shellcon.SHGDN_NORMAL))
if folder.GetDisplayNameOf(item, shellcon.SHGDN_NORMAL) ==
"Dieser PC":
new_folder = folder.BindToObject(item, None,
shell.IID_IShellFolder)
break
# list folders in Dieser PC/This Computer
for item in new_folder:
print("loop: ", new_folder.GetDisplayNameOf(item,
shellcon.SHGDN_NORMAL))
api = Api()
window = create_window('Test', 'index.html', js_api=api, min_size=(600, 450))
api.listFoldersDieserPC()
print("now from the browser")
start()
With index.html:
The first time I call the function api.listFoldersDieserPC directly
from python, the second time through the button in the pywebview
browser window.
This is the output:
loop: Dieser PC
loop: Downloads
loop: Bilder
loop: Musik
loop: Desktop
loop: Dokumente
loop: Videos
loop: Apple iPhone
loop: Local Disk (C:)
now from the browser
loop: Dieser PC
loop: Downloads
loop: Bilder
loop: Musik
loop: Desktop
loop: Dokumente
loop: Videos
loop: Local Disk (C:)
Process finished with exit code 0
It is the same, except that the folder for Apple iPhone is missing on
the second go.
Why is the shell behaving differently here? Is this a bug in win32com
or is pywebview influencing it somehow? What can I do to make it work?
Kind regards
From timr at probo.com Wed May 11 12:26:58 2022
From: timr at probo.com (Tim Roberts)
Date: Wed, 11 May 2022 09:26:58 -0700
Subject: [python-win32] Using win32com.shell to browse iphone photos |
problem with pywebview
In-Reply-To:
References:
Message-ID: <0f5b5e00-1c8b-952c-412d-25223170ace9@probo.com>
Bastian Schnitzler wrote:
> I want to use win32com to transfer photos from my iphone to my
> computer (I found a code snippet here, that worked for me:
> https://gitlab.com/lassi.niemisto/iphone-photo-dump/).
> In addition I would like to use pywebview to build a GUI.
> ...
> It is the same, except that the folder for Apple iPhone is missing on
> the second go.
>
> Why is the shell behaving differently here? Is this a bug in win32com
> or is pywebview influencing it somehow? What can I do to make it work?
Have you tried configuring your app to use a local web server? If you
don't run your own server, then your pywebview app runs inside the
browser's process, and that is a highly protected sandbox.? That's
probably why you don't see external devices.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3389 bytes
Desc: S/MIME Cryptographic Signature
URL:
From Gary.Scorby at finastra.com Wed May 11 17:23:32 2022
From: Gary.Scorby at finastra.com (Scorby, Gary)
Date: Wed, 11 May 2022 21:23:32 +0000
Subject: [python-win32] Python 3.11 and pywin32 304
Message-ID:
I've looked to see if anyone else is having this issue. I haven't found anything. When trying to call a function in the interactive window I get what you see below. Appears to be trying to access a deprecated method. I'd like to start testing with 3.11. The error occurs when I type the left parenthesis after the function name. Is there actually a problem with pywin32, or with me? - Thanks, Gary
PythonWin 3.11.0b1 (main, May 7 2022, 22:58:47) [MSC v.1931 64 bit (AMD64)] on win32.
Portions Copyright 1994-2018 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
>>> def biff(a, b):
... print(a + b)
...
>>> biffFailed to format the args
Traceback (most recent call last):
File "C:\Python311-64\Lib\site-packages\pythonwin\pywin\idle\CallTips.py", line 135, in get_arg_text
arg_getter = getattr(inspect, "getfullargspec", inspect.getargspec)
^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'
"FINASTRA" is the trade name of the FINASTRA group of companies. This email and any attachments have been scanned for known viruses using multiple scanners. This email message is intended for the named recipient only. It may be privileged and/or confidential. If you are not the named recipient of this email please notify us immediately and do not copy it or use it for any purpose, nor disclose its contents to any other person. This email does not constitute the commencement of legal relations between you and FINASTRA. Please refer to the executed contract between you and the relevant member of the FINASTRA group for the identity of the contracting party with which you are dealing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From skippy.hammond at gmail.com Wed May 11 18:34:29 2022
From: skippy.hammond at gmail.com (Mark Hammond)
Date: Thu, 12 May 2022 08:34:29 +1000
Subject: [python-win32] Python 3.11 and pywin32 304
In-Reply-To:
References:
Message-ID:
On 12/05/2022 7:23 am, Scorby, Gary via python-win32 wrote:
> I?ve looked to see if anyone else is having this issue.? I haven?t found
> anything.? When trying to call a function in the interactive window I
> get what you see below.? Appears to be trying to access a deprecated
> method.? I?d like to start testing with 3.11.? The error occurs when I
> type the left parenthesis after the function name. ?Is there actually a
> problem with pywin32, or with me? ? Thanks, Gary
Almost certainly with pythonwin - I opened
https://github.com/mhammond/pywin32/issues/1877
Thanks,
Mark
From mail at wampenseppl.de Sun May 15 06:07:51 2022
From: mail at wampenseppl.de (mail at wampenseppl.de)
Date: Sun, 15 May 2022 12:07:51 +0200 (CEST)
Subject: [python-win32] Reading email body from Outlook: Operation aborted
Message-ID: <20220515100751.009429740110@dd24318.kasserver.com>
Dear all,
(Transparency note: This has been posted to https://python-forum.io/thread-37103.html before)
The following code will print the ReceivedTime as well as the email body on a Win11 machine (pywin32 version 304, personal computer):
import win32com.client
outlook = win32com.client.GetActiveObject('Outlook.Application').GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6).Items
messages = list(inbox)
print(messages[0].ReceivedTime)
print(messages[0].Body)
On a second machine (Win10, same version of pywin32, company device), execution will fail:
PS C:\Users\xxx> & C:/Users/xxx/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/xxx/outlook.py"
2021-05-17 16:47:59.781000+00:00
Traceback (most recent call last):
File "c:\Users\xxx\outlook.py", line 8, in
print(messages[0].Body)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\win32com\client\dynamic.py", line 628, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid, 0, invoke_type, 1)
pywintypes.com_error: (-2147467260, 'Operation aborted', None, None)
It can read the ReceivedTime, but not the Body. I think it has to do with Outlook security policy as set up on the company device. I've already applied the registry keys mentioned at https://www.slipstick.com/developer/change-programmatic-access-options/, but couldn't see any changed behavior. Also, I can't run Outlook (O365 / V2204) as an admin as this will request me to create a new account. I was trying to access Trust Center -> Programmatic Access there. Could anybody kindly guide me to the correct direction, please?
Best regards,
Timo
From steven at manross.net Mon May 16 01:35:58 2022
From: steven at manross.net (Steven Manross)
Date: Mon, 16 May 2022 05:35:58 +0000
Subject: [python-win32] Reading email body from Outlook: Operation
aborted
In-Reply-To: <20220515100751.009429740110@dd24318.kasserver.com>
References: <20220515100751.009429740110@dd24318.kasserver.com>
Message-ID:
The one thing that I see in this code is:
* there is a possible problem with how you are calling the Outlook.Application object, namely you are doing a "GetActiveObject" and this could fail if Outlook is not already open.
If you are sure that Outlook will always be open when you run your python code (or this was an easy way to show an example), then it shouldn't be a problem, but I just wanted to make sure that wasn't throwing a wrench into the mix that you weren't thinking about.
I'm using pywin32 v304 on Python 3.10 (x64) on Windows 10 x64 (21H2) with Outlook 2019 (not the Ofifce 365 version), and your code works fine for me so it's not a W10 thing or a v304 on W10 issue).
I went as far as this code (slightly different at the end but basically the same):
import win32com.client
outlook = win32com.client.GetActiveObject('Outlook.Application').GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6).Items
messages = list(inbox)
for message in messages:
print(message.Subject)
...and all was well.
#snipped output start
Backup Log: XXXXXXXXXX
WSUS: Update Status Summary From XXXXXXXXXX
WSUS: Update Status Summary From XXXXXXX
#snipped output end
Here's another possible problem:
* the attached security warning popped up a few times while I was testing your code, and this could also be giving your python code issues (if the approve button isn?t pressed in X seconds or the deny button is pressed).
Back in the day of Outlook 2003, there were ways to publish something to your Public Folders in a specific folder path to tell Outlook that it should allow programmatic access (no matter what) for user X or Group Y, but just remember, most of the Outlook Automation that people typically have seen is created by hackers, so Microsoft had to lock it down a lot, and as such, this type of warning shouldn't really be disabled except for maybe 1 - 5 minutes at a time by someone running the script who understands exactly what it's doing (and even then you are opening yourself to a security nightmare if that system gets a virus that tries to do some outlook automation).
If you wanted to write a Macro, and sign it with a Code Signing Certificate from a trusted Certificate Authority we MIGHT be able to make something work, but the Outlook automation security is there for a reason and shouldn't be messed with (PLUS: I've never written a Python macro for Outlook).
Note: you can change the Outlook security settings to run Signed Macros relatively easy without any security warnings popping up (provided your system trusts the CA supplying the Code Signing Certificate and the certificate is not expired, etc). I currently have some VBScript code that will move Mail messages to an Exchange public folder and write some data to my SpamAssassin server telling SpamAssassin that a mail is "Good" or "Bad" every time a message (or multiple messages) are selected and a macro button is pressed in the Outlook client (it stops working when I let my certificate expire ? ).
I hope these points help you diagnose this problem further, and or give you more ideas on how to automate your task within the Outlook automation security framework.
Steven
-----Original Message-----
From: python-win32 On Behalf Of mail at wampenseppl.de
Sent: Sunday, May 15, 2022 3:08 AM
To: python-win32 at python.org
Subject: [python-win32] Reading email body from Outlook: Operation aborted
Dear all,
(Transparency note: This has been posted to https://python-forum.io/thread-37103.html before)
The following code will print the ReceivedTime as well as the email body on a Win11 machine (pywin32 version 304, personal computer):
import win32com.client
outlook = win32com.client.GetActiveObject('Outlook.Application').GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6).Items
messages = list(inbox)
print(messages[0].ReceivedTime)
print(messages[0].Body)
On a second machine (Win10, same version of pywin32, company device), execution will fail:
PS C:\Users\xxx> & C:/Users/xxx/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/xxx/outlook.py"
2021-05-17 16:47:59.781000+00:00
Traceback (most recent call last):
File "c:\Users\xxx\outlook.py", line 8, in
print(messages[0].Body)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\win32com\client\dynamic.py", line 628, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid, 0, invoke_type, 1)
pywintypes.com_error: (-2147467260, 'Operation aborted', None, None)
It can read the ReceivedTime, but not the Body. I think it has to do with Outlook security policy as set up on the company device. I've already applied the registry keys mentioned at https://www.slipstick.com/developer/change-programmatic-access-options/, but couldn't see any changed behavior. Also, I can't run Outlook (O365 / V2204) as an admin as this will request me to create a new account. I was trying to access Trust Center -> Programmatic Access there. Could anybody kindly guide me to the correct direction, please?
Best regards,
Timo
_______________________________________________
python-win32 mailing list
python-win32 at python.org
https://mail.python.org/mailman/listinfo/python-win32
-------------- next part --------------
A non-text attachment was scrubbed...
Name: security-warning.png
Type: image/png
Size: 9200 bytes
Desc: security-warning.png
URL:
From sharmaji.ankit777 at gmail.com Wed May 18 10:41:29 2022
From: sharmaji.ankit777 at gmail.com (Ankit Sharma)
Date: Wed, 18 May 2022 20:11:29 +0530
Subject: [python-win32] Package giving Error while deploying to windows
container
Message-ID:
Hi Team,
Hope this mail finds you well!
The issue with Pywin32 library is , it is getting deployed successfully to
window container, However, once we try to use Export file function from the
library , we get following error:
"Environment:
Request Method: GET
Request URL:
http://globalinnovationfitdjango-window.azurewebsites.net/export_report?projectId=2538
Django Version: 3.0.5
Python Version: 3.8.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'corsheaders',
'rest_framework',
'projects',
'channels_menu']
Installed Middleware:
['corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 86,
in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
During handling of the above exception ((-2147221005, 'Invalid class
string', None, None)), another exception occurred:
File "C:\Python\lib\site-packages\django\core\handlers\exception.py",
line 34, in inner
response = get_response(request)
File "C:\Python\lib\site-packages\django\core\handlers\base.py", line
115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Python\lib\site-packages\django\core\handlers\base.py", line
113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python\lib\site-packages\django\views\decorators\csrf.py", line
54, in wrapped_view
return view_func(*args, **kwargs)
File "C:\Python\lib\site-packages\django\views\generic\base.py", line 71,
in view
return self.dispatch(request, *args, **kwargs)
File "C:\Python\lib\site-packages\rest_framework\views.py", line 505, in
dispatch
response = self.handle_exception(exc)
File "C:\Python\lib\site-packages\rest_framework\views.py", line 465, in
handle_exception
self.raise_uncaught_exception(exc)
File "C:\Python\lib\site-packages\rest_framework\views.py", line 476, in
raise_uncaught_exception
raise exc
File "C:\Python\lib\site-packages\rest_framework\views.py", line 502, in
dispatch
response = handler(request, *args, **kwargs)
File "C:\Python\lib\site-packages\rest_framework\decorators.py", line 50,
in handler
return func(*args, **kwargs)
File "C:\app\backend\manage_products\products.py", line 17683, in
export_report
main()
File "C:\app\backend\manage_products\products.py", line 17854, in main
run_excel(f_path, f_name, sheet_name)
File "C:\app\backend\manage_products\products.py", line 17751, in
run_excel
excel = win32.gencache.EnsureDispatch('Excel.Application')
File "C:\Python\lib\site-packages\win32com\client\gencache.py", line 618,
in EnsureDispatch
disp = win32com.client.Dispatch(prog_id)
File "C:\Python\lib\site-packages\win32com\client\__init__.py", line 117,
in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,
userName, clsctx)
File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 106,
in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 88,
in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(
Exception Type: com_error at /export_report
Exception Value: (-2147221005, 'Invalid class string', None, None)
"
This is the log that we can not rectify even after updating our python
version and changing container from Linux based environment to Windows
Based environment.
Can you please help us out in figuring this issue out! or can help us in
suggesting if we can deploy this package in a Linux container. Anything
works.
Hope to get a positive answer.
Thanks,
Ankit
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From timr at probo.com Wed May 18 19:13:20 2022
From: timr at probo.com (Tim Roberts)
Date: Wed, 18 May 2022 16:13:20 -0700
Subject: [python-win32] Package giving Error while deploying to windows
container
In-Reply-To:
References:
Message-ID: <3cdd0298-5ccb-bb8f-3e90-cae20bc8657b@probo.com>
Ankit Sharma wrote:
> The issue with Pywin32 library is , it is getting deployed
> successfully to window container, However, once we try to use Export
> file function from the library , we get following?error:
> ...
> ? File "C:\app\backend\manage_products\products.py", line 17751, in
> run_excel
> ? ? excel = win32.gencache.EnsureDispatch('Excel.Application')
> ...
> Exception Value: (-2147221005, 'Invalid class string', None, None)
>
>
> This is the log that we can not rectify even after updating our python
> version and changing container from Linux based environment to Windows
> Based environment.
>
> Can you please help us out in figuring this issue out! or can help us
> in suggesting if we can deploy this package in a Linux container.
> Anything works.
You are trying to run the Excel application.? To do that, you have to
have Excel installed on the machine where you're running. And, of
course, nothing that uses Win32Com can ever work on Linux.
If you're trying to manipulate Excel files, there are many
cross-platform libraries to do that.? If you really need to RUN Excel,
then it has to be on Windows, and you have to have Excel installed.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3389 bytes
Desc: S/MIME Cryptographic Signature
URL:
From wlfraed at ix.netcom.com Wed May 18 20:10:18 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Wed, 18 May 2022 20:10:18 -0400
Subject: [python-win32] Package giving Error while deploying to windows
container
References:
Message-ID:
On Wed, 18 May 2022 20:11:29 +0530, Ankit Sharma
declaimed the following:
>This is the log that we can not rectify even after updating our python
>version and changing container from Linux based environment to Windows
>Based environment.
>
I have no idea of how this "container" operates. Can you produce a
stand-alone console test case to run in this "container" rather than all
the overhead of django? In fact, you are losing much of the real error
traceback as it appears django is only showing the last call, and then
dumps a second traceback because your framework errored.
Until the test case runs in a console I'd avoid any web-based
operations. Actually -- I'd avoid even the "container" system until the
test case runs on a local desktop machine.
Does your "container" have a licensed copy of Excel?
>
>Can you please help us out in figuring this issue out! or can help us in
>suggesting if we can deploy this package in a Linux container. Anything
>works.
>
To my knowledge pywin32 is a Windows Only library -- it might run under
WINE on a Linux system. Oh... And Excel is also not a Linux application to
my knowledge -- there may be a MacOS version available.
I suspect you will need to find/use one of the Excel reader/writer
packages that DOES NOT REQUIRE Excel to be present, only an .xls/.xlsx file
(OpenPyXL ?). You will likely also need a package that can produce reports
probably to PDF or HTML Reportlab appears to only generate PDF output --
okay for export/download, but not for inline display on a web page (of
course, if you are using django, you should have a templating engine and
should be able to code the web display report using it).
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
From vernondcole at gmail.com Thu May 19 08:40:56 2022
From: vernondcole at gmail.com (Vernon D. Cole)
Date: Thu, 19 May 2022 06:40:56 -0600
Subject: [python-win32] Package giving Error while deploying to windows
container
In-Reply-To:
References:
Message-ID:
Django also runs on Windows, and I have operated it there for testing
purposes, but it is most at home in a Linux environment.
I have never (personally) run it in a container. I prefer the better
performance and ease of use when installed directly on the server.
Containers may deploy more quickly, but you pay a penalty for the rest of
the life of the system.
I cannot imagine why one would want to run * anything * in a Windows
container. That is adding complexity on top of difficulty.
My suggestion is to eliminate Windows from your thinking and run django
directly on Linux.
Use Windows for desktops or laptops, use Linux for servers.
(full disclosure: this message is being typed on an Ubuntu Linux desktop.)
On Wed, May 18, 2022 at 3:49 PM Ankit Sharma
wrote:
> Hi Team,
>
> Hope this mail finds you well!
>
> The issue with Pywin32 library is , it is getting deployed successfully to
> window container, However, once we try to use Export file function from the
> library , we get following error:
>
> "Environment:
>
>
> Request Method: GET
> Request URL:
> http://globalinnovationfitdjango-window.azurewebsites.net/export_report?projectId=2538
>
> Django Version: 3.0.5
> Python Version: 3.8.10
> Installed Applications:
> ['django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sites',
> 'corsheaders',
> 'rest_framework',
> 'projects',
> 'channels_menu']
> Installed Middleware:
> ['corsheaders.middleware.CorsMiddleware',
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware']
>
>
>
> Traceback (most recent call last):
> File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 86,
> in _GetGoodDispatch
> IDispatch = pythoncom.connect(IDispatch)
>
> During handling of the above exception ((-2147221005, 'Invalid class
> string', None, None)), another exception occurred:
> File "C:\Python\lib\site-packages\django\core\handlers\exception.py",
> line 34, in inner
> response = get_response(request)
> File "C:\Python\lib\site-packages\django\core\handlers\base.py", line
> 115, in _get_response
> response = self.process_exception_by_middleware(e, request)
> File "C:\Python\lib\site-packages\django\core\handlers\base.py", line
> 113, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
> File "C:\Python\lib\site-packages\django\views\decorators\csrf.py", line
> 54, in wrapped_view
> return view_func(*args, **kwargs)
> File "C:\Python\lib\site-packages\django\views\generic\base.py", line
> 71, in view
> return self.dispatch(request, *args, **kwargs)
> File "C:\Python\lib\site-packages\rest_framework\views.py", line 505, in
> dispatch
> response = self.handle_exception(exc)
> File "C:\Python\lib\site-packages\rest_framework\views.py", line 465, in
> handle_exception
> self.raise_uncaught_exception(exc)
> File "C:\Python\lib\site-packages\rest_framework\views.py", line 476, in
> raise_uncaught_exception
> raise exc
> File "C:\Python\lib\site-packages\rest_framework\views.py", line 502, in
> dispatch
> response = handler(request, *args, **kwargs)
> File "C:\Python\lib\site-packages\rest_framework\decorators.py", line
> 50, in handler
> return func(*args, **kwargs)
> File "C:\app\backend\manage_products\products.py", line 17683, in
> export_report
> main()
> File "C:\app\backend\manage_products\products.py", line 17854, in main
> run_excel(f_path, f_name, sheet_name)
> File "C:\app\backend\manage_products\products.py", line 17751, in
> run_excel
> excel = win32.gencache.EnsureDispatch('Excel.Application')
> File "C:\Python\lib\site-packages\win32com\client\gencache.py", line
> 618, in EnsureDispatch
> disp = win32com.client.Dispatch(prog_id)
> File "C:\Python\lib\site-packages\win32com\client\__init__.py", line
> 117, in Dispatch
> dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,
> userName, clsctx)
> File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 106,
> in _GetGoodDispatchAndUserName
> return (_GetGoodDispatch(IDispatch, clsctx), userName)
> File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 88,
> in _GetGoodDispatch
> IDispatch = pythoncom.CoCreateInstance(
>
> Exception Type: com_error at /export_report
> Exception Value: (-2147221005, 'Invalid class string', None, None)
> "
>
>
> This is the log that we can not rectify even after updating our python
> version and changing container from Linux based environment to Windows
> Based environment.
>
>
> Can you please help us out in figuring this issue out! or can help us in
> suggesting if we can deploy this package in a Linux container. Anything
> works.
>
> Hope to get a positive answer.
>
> Thanks,
> Ankit
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From timr at probo.com Thu May 19 21:48:10 2022
From: timr at probo.com (Tim Roberts)
Date: Thu, 19 May 2022 18:48:10 -0700
Subject: [python-win32] Package giving Error while deploying to windows
container
In-Reply-To:
References:
Message-ID: <881a40ce-57c4-b938-5c20-a31dacfa4bc4@probo.com>
On 5/19/22 05:40, Vernon D. Cole wrote:
> Django also runs on Windows, and I have operated it there for testing
> purposes, but it is most at home in a Linux environment.
> I have never (personally) run it in a container. I prefer the better
> performance and ease of use when installed directly on the?server.
> Containers may deploy more quickly, but you pay a penalty for the rest
> of the life of the system.
> I cannot imagine why one would want to run * anything * in a Windows
> container. That is adding complexity on top of difficulty.
> My suggestion is to eliminate Windows from your thinking and run
> django directly on Linux.
However, this is not very good advice for an application that is
invoking Microsoft Excel to do its work.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
From steven at manross.net Sun May 22 01:36:28 2022
From: steven at manross.net (Steven Manross)
Date: Sun, 22 May 2022 05:36:28 +0000
Subject: [python-win32] IIS ASP webpage issues with minimal pyscript
In-Reply-To: <849e7c1fa43446f486b03be3ca7b286b@manross.net>
References: <849e7c1fa43446f486b03be3ca7b286b@manross.net>
Message-ID: <26c5f4b3d695435093bf6a8fd01effe3@manross.net>
I'm not sure what changed this time except that I renamed my C:\Python310 dir to C:\Python310--- after uninstalling and rebooting so it would install in a fresh directory, but now my ASP scripts are working. YAY!!
Have a great day.
Chalk another one up to leaving the problem for a few hours, and you finally figure out a way around it. ?
Steven
-----Original Message-----
From: Steven Manross
Sent: Saturday, May 21, 2022 6:28 PM
To: python-win32 at python.org
Subject: IIS ASP webpage issues with minimal pyscript
Howdy,
I have pywin32 ASP Scripts using Python 3.10.4 x64 (from Python.org) running on 2 servers. Both are Win Server 2016 with the most recent patches.
I am using pywin32==304
One server runs pyscript in ASP fine, the other doesn?t (VBScript works fine both servers).
This is the page I am trying to render in Classic ASP:
<%@ LANGUAGE="Python"%>
<%
Response.Write('This is a test')
%>
Note: if I render that Classic ASP code on another server, it renders correctly.
If I make my ASP page just this....
<%@ LANGUAGE="Python"%>
No error appears, but obviously, I want to write something to the webpage, so sadly I have to debug this further.
This is the browser error I get from Chrome:
This site can?t be reached
The webpage at https://whatever.manross.net/mypage.asp might be temporarily down or it may have moved permanently to a new web address.
ERR_UNEXPECTED
In trying to debug this further, I found ?DebugDiagx64? (a Microsoft tool) in order to trace the specific application pool I am having problems with (and enable diagnostic data when the apppool/process dies).
Here?s one of the trace analysis files it came up with (attached) and there were a total of 4 traces:
* w3wp__debug-analysis.mht.txt (.txt was added in case MHT files are active content and stripped by anyone's servers).
* Note: this analysis file renders in IE fine If you alter Internet Options -> Advanced -> Security -> Allow Active Content to run in files on My Computer (requires restart) to enabled
* Iistrace-as-text.txt is just a text file where I pulled out some relevant data from the debugdiag analysis output presuming that not everyone has a windows system or wants to run that active content in a browser.
What I?ve tried in debugging this:
* run: python pyscript.py (and tried adding a --debug -- no errors on either running)
* run: python pywin32_postinstall.py --install (no errors)
* verified Application Pool does not have "Enable 32-bit Applications = True" (found out about that on the other server)
* created a new application pool and assigned it to the site, and made sure that it behaved the same.. it does (both don?t work).
* repaired the installation of Python 3.10.4 from "Add/Remove Programs"
* removed python and reinstalled python after a clean reboot
* iisreset.exe (stop/start IIS completely)
* reboot server a few times
* searching for answers on google for a few hours related to "App Pool crash" "Python" "Classic ASP" and more.
* reading the documentation: https://github.com/mhammond/pywin32/blob/main/README.md again just in case ?
* searched for pywintypes*.* and didn?t find any different versions that I thought would be a problem (note: some Intel SSD software has one in its personal application directory for python 2.7) Python itself is behaving just fine, and can instantiate COM objects as I have been testing/building "CertificateAuthority" python modules on this server in prep for creating a web page. It's just when I start to make ASP pages that it goes crazy.
If anyone has suggestions, I can do just about anything to this PC at any time (other than del /s /q c:\*.*) ?
Thanks for your time.
Steven
From steven at manross.net Thu May 26 20:40:24 2022
From: steven at manross.net (Steven Manross)
Date: Fri, 27 May 2022 00:40:24 +0000
Subject: [python-win32] Import Certificate with Private Key to Current
Computer Certificate store
Message-ID: <6a6db6afeea6451f91746422e21efb02@manross.net>
Howdy,
I am finishing up some work on requesting certificates from an internal Microsoft CA, and then importing the certs to the local windows certificate store, butd was having difficulty determining what function to use to import a Certificate with Private Key (P12/PFX) to a the computer's Certificate store. I've got everything else handled up to this point (I think), but now I am stuck.
I see two possible functions for likely adding the certificate to the store:
http://timgolden.me.uk/pywin32-docs/win32crypt__CertAddSerializedElementToStore_meth.html
* likely the way to go, but I don't see in the documentation how to take my Cert with Key and convert it to the necessary structure
http://timgolden.me.uk/pywin32-docs/win32crypt__PFXImportCertStore_meth.html
* this one I'm not so sure about (not likely what I want to do)
...but also see this:
https://stackoverflow.com/questions/61888404/how-do-i-install-a-certificate-to-trusted-root-certificates-using-python
* however I cannot read the PFX correctly (presumably due to the encrypted nature of the certificate with key).
* I DO have the base64 PEM crt and key files if that helps me in this process
* the CertStore code from this post looks like what I need to get to the CertStore, however
The certificates I'm trying to work with are typically for webserver renewals.
If anyone has knowledge and is willing to share, I'd appreciate it!
Please and Thank you,
Steven
From skippy.hammond at gmail.com Thu May 26 20:45:08 2022
From: skippy.hammond at gmail.com (Mark Hammond)
Date: Fri, 27 May 2022 10:45:08 +1000
Subject: [python-win32] Import Certificate with Private Key to Current
Computer Certificate store
In-Reply-To: <6a6db6afeea6451f91746422e21efb02@manross.net>
References: <6a6db6afeea6451f91746422e21efb02@manross.net>
Message-ID:
Hi!
I know almost nothing about certificate stores, but as luck would have
it, someone did report some issues recently, so it turns out there is a
PR that (a) tries to fix a couple of issues and (b) adds a test that
adds certificates to the store - see
https://github.com/mhammond/pywin32/pull/1863, particularly
test_win32crypt.py, which can hopefully be found at
https://github.com/mhammond/pywin32/pull/1863/files#diff-9f6fa3983d625ad71f59c9b4662dc07ea20602ffb5c3b1aa58e5e59fa759dff7
HTH,
Mark
On 27/05/2022 10:40 am, Steven Manross wrote:
> Howdy,
>
> I am finishing up some work on requesting certificates from an internal Microsoft CA, and then importing the certs to the local windows certificate store, butd was having difficulty determining what function to use to import a Certificate with Private Key (P12/PFX) to a the computer's Certificate store. I've got everything else handled up to this point (I think), but now I am stuck.
>
> I see two possible functions for likely adding the certificate to the store:
> http://timgolden.me.uk/pywin32-docs/win32crypt__CertAddSerializedElementToStore_meth.html
> * likely the way to go, but I don't see in the documentation how to take my Cert with Key and convert it to the necessary structure
> http://timgolden.me.uk/pywin32-docs/win32crypt__PFXImportCertStore_meth.html
> * this one I'm not so sure about (not likely what I want to do)
>
> ...but also see this:
> https://stackoverflow.com/questions/61888404/how-do-i-install-a-certificate-to-trusted-root-certificates-using-python
> * however I cannot read the PFX correctly (presumably due to the encrypted nature of the certificate with key).
> * I DO have the base64 PEM crt and key files if that helps me in this process
> * the CertStore code from this post looks like what I need to get to the CertStore, however
>
> The certificates I'm trying to work with are typically for webserver renewals.
>
> If anyone has knowledge and is willing to share, I'd appreciate it!
>
> Please and Thank you,
> Steven
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
From steven at manross.net Thu May 26 20:48:47 2022
From: steven at manross.net (Steven Manross)
Date: Fri, 27 May 2022 00:48:47 +0000
Subject: [python-win32] Import Certificate with Private Key to Current
Computer Certificate store
In-Reply-To:
References: <6a6db6afeea6451f91746422e21efb02@manross.net>
Message-ID:
I'll give it a shot... Thanks!
Steven
-----Original Message-----
From: Mark Hammond
Sent: Thursday, May 26, 2022 5:45 PM
To: Steven Manross ; python-win32 at python.org
Subject: Re: [python-win32] Import Certificate with Private Key to Current Computer Certificate store
Hi!
I know almost nothing about certificate stores, but as luck would have it, someone did report some issues recently, so it turns out there is a PR that (a) tries to fix a couple of issues and (b) adds a test that adds certificates to the store - see https://github.com/mhammond/pywin32/pull/1863, particularly test_win32crypt.py, which can hopefully be found at
https://github.com/mhammond/pywin32/pull/1863/files#diff-9f6fa3983d625ad71f59c9b4662dc07ea20602ffb5c3b1aa58e5e59fa759dff7
HTH,
Mark
On 27/05/2022 10:40 am, Steven Manross wrote:
> Howdy,
>
> I am finishing up some work on requesting certificates from an internal Microsoft CA, and then importing the certs to the local windows certificate store, butd was having difficulty determining what function to use to import a Certificate with Private Key (P12/PFX) to a the computer's Certificate store. I've got everything else handled up to this point (I think), but now I am stuck.
>
> I see two possible functions for likely adding the certificate to the store:
> http://timgolden.me.uk/pywin32-docs/win32crypt__CertAddSerializedElementToStore_meth.html
> * likely the way to go, but I don't see in the documentation how to take my Cert with Key and convert it to the necessary structure
> http://timgolden.me.uk/pywin32-docs/win32crypt__PFXImportCertStore_meth.html
> * this one I'm not so sure about (not likely what I want to do)
>
> ...but also see this:
> https://stackoverflow.com/questions/61888404/how-do-i-install-a-certificate-to-trusted-root-certificates-using-python
> * however I cannot read the PFX correctly (presumably due to the encrypted nature of the certificate with key).
> * I DO have the base64 PEM crt and key files if that helps me in this process
> * the CertStore code from this post looks like what I need to get to
> the CertStore, however
>
> The certificates I'm trying to work with are typically for webserver renewals.
>
> If anyone has knowledge and is willing to share, I'd appreciate it!
>
> Please and Thank you,
> Steven
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
From steven at manross.net Thu May 26 22:31:32 2022
From: steven at manross.net (Steven Manross)
Date: Fri, 27 May 2022 02:31:32 +0000
Subject: [python-win32] Import Certificate with Private Key to Current
Computer Certificate store
In-Reply-To:
References: <6a6db6afeea6451f91746422e21efb02@manross.net>
Message-ID: <1b5e32711465456aaae48225f46199bb@manross.net>
As much as I don?t like shelling out to a command prompt... ?
CERTUTIL -f -p "" -importpfx "c:\mycertwithpfx.pfx"
There's definitely a different API for Certs with Private keys as best I can tell... I just cant find what it is 100%.
THANKS FOR YOUR HELP!
At least I can get it done (for now).
Steven
-----Original Message-----
From: python-win32 On Behalf Of Steven Manross
Sent: Thursday, May 26, 2022 5:49 PM
To: mhammond at skippinet.com.au; python-win32 at python.org
Subject: Re: [python-win32] Import Certificate with Private Key to Current Computer Certificate store
I'll give it a shot... Thanks!
Steven
-----Original Message-----
From: Mark Hammond
Sent: Thursday, May 26, 2022 5:45 PM
To: Steven Manross ; python-win32 at python.org
Subject: Re: [python-win32] Import Certificate with Private Key to Current Computer Certificate store
Hi!
I know almost nothing about certificate stores, but as luck would have it, someone did report some issues recently, so it turns out there is a PR that (a) tries to fix a couple of issues and (b) adds a test that adds certificates to the store - see https://github.com/mhammond/pywin32/pull/1863, particularly test_win32crypt.py, which can hopefully be found at
https://github.com/mhammond/pywin32/pull/1863/files#diff-9f6fa3983d625ad71f59c9b4662dc07ea20602ffb5c3b1aa58e5e59fa759dff7
HTH,
Mark
On 27/05/2022 10:40 am, Steven Manross wrote:
> Howdy,
>
> I am finishing up some work on requesting certificates from an internal Microsoft CA, and then importing the certs to the local windows certificate store, butd was having difficulty determining what function to use to import a Certificate with Private Key (P12/PFX) to a the computer's Certificate store. I've got everything else handled up to this point (I think), but now I am stuck.
>
> I see two possible functions for likely adding the certificate to the store:
> http://timgolden.me.uk/pywin32-docs/win32crypt__CertAddSerializedElementToStore_meth.html
> * likely the way to go, but I don't see in the documentation how to take my Cert with Key and convert it to the necessary structure
> http://timgolden.me.uk/pywin32-docs/win32crypt__PFXImportCertStore_meth.html
> * this one I'm not so sure about (not likely what I want to do)
>
> ...but also see this:
> https://stackoverflow.com/questions/61888404/how-do-i-install-a-certificate-to-trusted-root-certificates-using-python
> * however I cannot read the PFX correctly (presumably due to the encrypted nature of the certificate with key).
> * I DO have the base64 PEM crt and key files if that helps me in this process
> * the CertStore code from this post looks like what I need to get to
> the CertStore, however
>
> The certificates I'm trying to work with are typically for webserver renewals.
>
> If anyone has knowledge and is willing to share, I'd appreciate it!
>
> Please and Thank you,
> Steven
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
_______________________________________________
python-win32 mailing list
python-win32 at python.org
https://mail.python.org/mailman/listinfo/python-win32
From steven at manross.net Fri May 27 02:55:17 2022
From: steven at manross.net (Steven Manross)
Date: Fri, 27 May 2022 06:55:17 +0000
Subject: [python-win32] Import Certificate with Private Key to Current
Computer Certificate store
In-Reply-To: <1b5e32711465456aaae48225f46199bb@manross.net>
References: <6a6db6afeea6451f91746422e21efb02@manross.net>
<1b5e32711465456aaae48225f46199bb@manross.net>
Message-ID: <39ec7135327f458f8b1130f9a60c44ad@manross.net>
pythonnet for the win!!! (.NET for Python)
P.S. I couldn't install from pip (visual studio dependency issues) but the wheel file below worked like a charm (for python 3.9). Problem solved. ?
https://download.lfd.uci.edu/pythonlibs/a4hvik9m/pythonnet-2.5.2-cp39-cp39-win_amd64.whl
# pip install pythonnet-2.5.2-cp39-cp39-win_amd64.whl
'''
Install a PFX (Certificate with Key) file to the Windows Local Computer (not current user) Personal store
(typically where IIS looks for SSL Certificates)
'''
import clr
from System.Security.Cryptography.X509Certificates import X509Certificate2
from System.Security.Cryptography.X509Certificates import X509Store
from System.Security.Cryptography.X509Certificates import X509KeyStorageFlags
from System.Security.Cryptography.X509Certificates import OpenFlags
from System.Security.Cryptography.X509Certificates import StoreName, StoreLocation
pfx = X509Certificate2()
store = X509Store(StoreName.My, StoreLocation.LocalMachine)
passw = None
pfx.Import('c:/mypfx.pfx', passw, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet)
store.Open(OpenFlags.MaxAllowed)
store.Add(pfx)
store.Close()
Kudos to the below powershell script for the primer that I adapted to Python.NET.
https://gist.github.com/smaglio81/19146391f7f94e2449e16d3318be1ef7
Steven
-----Original Message-----
From: Steven Manross
Sent: Thursday, May 26, 2022 7:32 PM
To: Steven Manross ; mhammond at skippinet.com.au; python-win32 at python.org
Subject: RE: [python-win32] Import Certificate with Private Key to Current Computer Certificate store
As much as I don?t like shelling out to a command prompt... ?
CERTUTIL -f -p "" -importpfx "c:\mycertwithpfx.pfx"
There's definitely a different API for Certs with Private keys as best I can tell... I just cant find what it is 100%.
THANKS FOR YOUR HELP!
At least I can get it done (for now).
Steven
-----Original Message-----
From: python-win32 On Behalf Of Steven Manross
Sent: Thursday, May 26, 2022 5:49 PM
To: mhammond at skippinet.com.au; python-win32 at python.org
Subject: Re: [python-win32] Import Certificate with Private Key to Current Computer Certificate store
I'll give it a shot... Thanks!
Steven
-----Original Message-----
From: Mark Hammond
Sent: Thursday, May 26, 2022 5:45 PM
To: Steven Manross ; python-win32 at python.org
Subject: Re: [python-win32] Import Certificate with Private Key to Current Computer Certificate store
Hi!
I know almost nothing about certificate stores, but as luck would have it, someone did report some issues recently, so it turns out there is a PR that (a) tries to fix a couple of issues and (b) adds a test that adds certificates to the store - see https://github.com/mhammond/pywin32/pull/1863, particularly test_win32crypt.py, which can hopefully be found at
https://github.com/mhammond/pywin32/pull/1863/files#diff-9f6fa3983d625ad71f59c9b4662dc07ea20602ffb5c3b1aa58e5e59fa759dff7
HTH,
Mark
On 27/05/2022 10:40 am, Steven Manross wrote:
> Howdy,
>
> I am finishing up some work on requesting certificates from an internal Microsoft CA, and then importing the certs to the local windows certificate store, butd was having difficulty determining what function to use to import a Certificate with Private Key (P12/PFX) to a the computer's Certificate store. I've got everything else handled up to this point (I think), but now I am stuck.
>
> I see two possible functions for likely adding the certificate to the store:
> http://timgolden.me.uk/pywin32-docs/win32crypt__CertAddSerializedElementToStore_meth.html
> * likely the way to go, but I don't see in the documentation how to take my Cert with Key and convert it to the necessary structure
> http://timgolden.me.uk/pywin32-docs/win32crypt__PFXImportCertStore_meth.html
> * this one I'm not so sure about (not likely what I want to do)
>
> ...but also see this:
> https://stackoverflow.com/questions/61888404/how-do-i-install-a-certificate-to-trusted-root-certificates-using-python
> * however I cannot read the PFX correctly (presumably due to the encrypted nature of the certificate with key).
> * I DO have the base64 PEM crt and key files if that helps me in this process
> * the CertStore code from this post looks like what I need to get to
> the CertStore, however
>
> The certificates I'm trying to work with are typically for webserver renewals.
>
> If anyone has knowledge and is willing to share, I'd appreciate it!
>
> Please and Thank you,
> Steven
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
_______________________________________________
python-win32 mailing list
python-win32 at python.org
https://mail.python.org/mailman/listinfo/python-win32
From sathe.ishaan at gmail.com Fri May 27 11:56:38 2022
From: sathe.ishaan at gmail.com (Ishaan Sathe)
Date: Fri, 27 May 2022 21:26:38 +0530
Subject: [python-win32] Inquiry about Sending HTML format in Appointment in
Outlook Application
Message-ID:
Hii All ,
I am trying to send the Body in the Calendar invite in Outlook as HTML.
Can somebody help me how to do this ?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From steven at manross.net Sat May 28 00:55:56 2022
From: steven at manross.net (Steven Manross)
Date: Sat, 28 May 2022 04:55:56 +0000
Subject: [python-win32] Inquiry about Sending HTML format in Appointment
in Outlook Application
In-Reply-To:
References:
Message-ID: <78488641d1e549649c1d8fd8e75241db@manross.net>
As I recall, Calendar Items are a special kind of MailItem, and there is Body and BodyHTML on a mailItem which represent the ?Text Body? and the ?HTMLBody?.
https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.bodyformat
As well, there is a MailItem.BodyFormat which is supposed to be set to olFormatHTML per the document above.
olBodyFormat enumeration docs are here:
https://docs.microsoft.com/en-us/office/vba/api/outlook.olbodyformat
They have some VBScript in the top URL that should be somewhat easy to convert to Python.
HTH
Steven
From: python-win32 On Behalf Of Ishaan Sathe
Sent: Friday, May 27, 2022 8:57 AM
To: python-win32 at python.org
Subject: [python-win32] Inquiry about Sending HTML format in Appointment in Outlook Application
Hii All ,
I am trying to send the Body in the Calendar invite in Outlook as HTML.
Can somebody help me how to do this ?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: